Skip to content

Commit

Permalink
Merge pull request #78 from puppetlabs/CAT-1326-update-rubocop-config
Browse files Browse the repository at this point in the history
(CAT-1326) - Rubocop config update and fixing warnings
  • Loading branch information
Ramesh7 authored Aug 17, 2023
2 parents f245462 + 8fa5ad3 commit dc11f5c
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 102 deletions.
26 changes: 26 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
---
inherit_from: .rubocop_todo.yml

require:
- rubocop-performance
- rubocop-rspec
AllCops:
NewCops: enable
DisplayCopNames: true
ExtraDetails: true
DisplayStyleGuide: true
TargetRubyVersion: '2.6'
Include:
- "**/*.rb"
Exclude:
- bin/*
- ".vendor/**/*"
- "**/Gemfile"
- "**/Rakefile"
- pkg/**/*
- spec/fixtures/**/*
- vendor/**/*
- "**/Puppetfile"
- "**/Vagrantfile"
- "**/Guardfile"
Layout/LineLength:
Description: People have wide screens, use them.
Max: 255
102 changes: 27 additions & 75 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,45 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-08-16 09:21:34 UTC using RuboCop version 1.48.1.
# on 2023-08-17 11:27:18 UTC using RuboCop version 1.48.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 4
# Configuration parameters: Severity, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/DuplicatedGem:
Exclude:
- 'Gemfile'

# Offense count: 1
Lint/MixedRegexpCaptureTypes:
Exclude:
- 'Gemfile'

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 123

# Offense count: 1
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
Naming/HeredocDelimiterNaming:
Exclude:
- 'Rakefile'

# Offense count: 13
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns.
# SupportedStyles: snake_case, camelCase
Naming/VariableName:
Exclude:
- 'Rakefile'

# Offense count: 1
Security/Eval:
Exclude:
- 'Gemfile'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Security/JSONLoad:
RSpec/BeforeAfterAll:
Exclude:
- 'Rakefile'
- 'spec/spec_helper.rb'
- 'spec/rails_helper.rb'
- 'spec/support/**/*.rb'
- 'spec/acceptance/windows_eventlog_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, conditionals
Style/AndOr:
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'Rakefile'
- 'spec/acceptance/windows_eventlog_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
# Offense count: 2
# Configuration parameters: IgnoredMetadata.
RSpec/DescribeClass:
Exclude:
- 'Rakefile'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'Rakefile'
- '**/spec/features/**/*'
- '**/spec/requests/**/*'
- '**/spec/routing/**/*'
- '**/spec/system/**/*'
- '**/spec/views/**/*'
- 'spec/acceptance/windows_eventlog_spec.rb'
- 'spec/defines/windows_eventlog/windows_eventlog_spec.rb'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/RedundantInterpolation:
Exclude:
- 'Rakefile'
RSpec/MultipleExpectations:
Max: 2

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
# Offense count: 11
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Exclude:
- 'Rakefile'

# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 255
- 'spec/defines/windows_eventlog/windows_eventlog_spec.rb'
2 changes: 1 addition & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [v1.2.0](https://github.com/voxpupuli/puppet-windows_eventlog/tree/v1.2.0) (2017-02-11)
## [v1.2.0](https://github.com/puppetlabs/puppetlabs-windows_eventlog/tree/v1.2.0) (2017-02-11)

This is the last release with Puppet3 support!
* Sync metadata.json license to be same as LICENSE
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

Puppet module for managing windows event logs

[![Build Status](https://travis-ci.org/voxpupuli/puppet-windows_eventlog.svg?branch=master)](https://travis-ci.org/voxpupuli/puppet-windows_eventlog)

## Module Description

The purpose of this module is to manage each of the Windows event logs,
Expand Down
20 changes: 9 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').a
def changelog_user
return unless Rake.application.top_level_tasks.include? 'changelog'

returnVal = nil || JSON.load(File.read('metadata.json'))['author']
returnVal = nil || JSON.parse(File.read('metadata.json'))['author']
raise 'unable to find the changelog_user in .sync.yml, or the author in metadata.json' if returnVal.nil?

puts "GitHubChangelogGenerator user:#{returnVal}"
Expand All @@ -22,8 +22,8 @@ def changelog_project

returnVal = nil
returnVal ||= begin
metadata_source = JSON.load(File.read('metadata.json'))['source']
metadata_source_match = metadata_source && metadata_source.match(%r{.*/([^/]*?)(?:\.git)?\Z})
metadata_source = JSON.parse(File.read('metadata.json'))['source']
metadata_source_match = metadata_source&.match(%r{.*/([^/]*?)(?:\.git)?\Z})

metadata_source_match && metadata_source_match[1]
end
Expand All @@ -37,24 +37,22 @@ end
def changelog_future_release
return unless Rake.application.top_level_tasks.include? 'changelog'

returnVal = 'v%s' % JSON.load(File.read('metadata.json'))['version']
returnVal = format('v%s', JSON.parse(File.read('metadata.json'))['version'])
raise 'unable to find the future_release (version) in metadata.json' if returnVal.nil?

puts "GitHubChangelogGenerator future_release:#{returnVal}"
returnVal
end

PuppetLint.configuration.send('disable_relative')
PuppetLint.configuration.send(:disable_relative)

if Bundler.rubygems.find_name('github_changelog_generator').any?
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
if Rake.application.top_level_tasks.include? 'changelog' and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'"
end
raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include?('changelog') && ENV['CHANGELOG_GITHUB_TOKEN'].nil?

config.user = "#{changelog_user}"
config.project = "#{changelog_project}"
config.future_release = "#{changelog_future_release}"
config.user = changelog_user.to_s
config.project = changelog_project.to_s
config.future_release = changelog_future_release.to_s
config.exclude_labels = ['maintenance']
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
config.add_pr_wo_labels = true
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "puppet-windows_eventlog",
"name": "puppetlabs-windows_eventlog",
"version": "4.0.0",
"author": "puppetlabs",
"license": "MIT",
Expand Down
22 changes: 11 additions & 11 deletions spec/defines/windows_eventlog/windows_eventlog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

it do
expect do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\File')
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\File')
end.to raise_error(Puppet::Error)
end
end
Expand All @@ -24,7 +24,7 @@

it do
expect do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\File')
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\File')
end.to raise_error(Puppet::PreformattedError)
end
end
Expand All @@ -37,7 +37,7 @@

it do
expect do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\File')
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\File')
end.to raise_error(Puppet::PreformattedError)
end
end
Expand All @@ -49,7 +49,7 @@
end

it do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\Retention').with(
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\Retention').with(
'ensure' => 'present',
'type' => 'dword',
'data' => '1'
Expand All @@ -64,7 +64,7 @@
end

it do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\Retention').with(
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\Retention').with(
'ensure' => 'present',
'type' => 'dword',
'data' => '0'
Expand All @@ -79,7 +79,7 @@
end

it do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\AutoBackupLogFiles').with(
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\AutoBackupLogFiles').with(
'ensure' => 'present',
'type' => 'dword',
'data' => '-1'
Expand All @@ -94,21 +94,21 @@
end

it do
is_expected.to contain_registry_key('HKLM\System\CurrentControlSet\Services\Eventlog\Application').with(
expect(subject).to contain_registry_key('HKLM\System\CurrentControlSet\Services\Eventlog\Application').with(
'ensure' => 'present'
)
end

it do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\File').with(
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\File').with(
'ensure' => 'present',
'type' => 'expand',
'data' => '%SystemRoot%\system32\winevt\Logs\Application.evtx'
)
end

it do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\MaxSize').with(
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Application\MaxSize').with(
'ensure' => 'present',
'type' => 'dword',
'data' => '2222'
Expand All @@ -123,7 +123,7 @@
end

it 'infers the log_path using $name' do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Something\File').with(
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Something\File').with(
'ensure' => 'present',
'type' => 'expand',
'data' => '%SystemRoot%\system32\winevt\Logs\Something.evtx'
Expand All @@ -138,7 +138,7 @@
end

it 'infers the log_path using $log_path_template and $name' do
is_expected.to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Custom1\File').with(
expect(subject).to contain_registry_value('HKLM\System\CurrentControlSet\Services\Eventlog\Custom1\File').with(
'ensure' => 'present',
'type' => 'expand',
'data' => 'C:\Logs\Custom1'
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

RSpec.configure do |c|
c.default_facts = default_facts
c.before :each do
c.before do
# set to strictest setting for testing
# by default Puppet runs at warning level
Puppet.settings[:strict] = :warning
Expand Down

0 comments on commit dc11f5c

Please sign in to comment.