diff --git a/.rubocop.yml b/.rubocop.yml index dec415e..0db293a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b6152f3..18a2561 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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' diff --git a/HISTORY.md b/HISTORY.md index 69675c0..bfaaf1c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 diff --git a/README.md b/README.md index 3be55d6..837778c 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/Rakefile b/Rakefile index 6272b62..7a73848 100644 --- a/Rakefile +++ b/Rakefile @@ -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}" @@ -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 @@ -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 diff --git a/metadata.json b/metadata.json index 9df7844..22de80d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,5 +1,5 @@ { - "name": "puppet-windows_eventlog", + "name": "puppetlabs-windows_eventlog", "version": "4.0.0", "author": "puppetlabs", "license": "MIT", diff --git a/spec/defines/windows_eventlog/windows_eventlog_spec.rb b/spec/defines/windows_eventlog/windows_eventlog_spec.rb index 12107a6..693581b 100644 --- a/spec/defines/windows_eventlog/windows_eventlog_spec.rb +++ b/spec/defines/windows_eventlog/windows_eventlog_spec.rb @@ -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 @@ -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 @@ -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 @@ -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' @@ -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' @@ -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' @@ -94,13 +94,13 @@ 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' @@ -108,7 +108,7 @@ 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' @@ -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' @@ -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' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3fbb31c..8d07e44 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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