diff --git a/.rubocop.yml b/.rubocop.yml index 9ba0432..c2a2c07 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,40 +1,8 @@ --- inherit_from: .rubocop_todo.yml -require: - - rubocop-performance - - rubocop-rake - - rubocop-rspec - -AllCops: - NewCops: enable - DisplayCopNames: true - ExtraDetails: true - DisplayStyleGuide: true - TargetRubyVersion: '2.7' - Exclude: - - vendor/**/* - - .vendor/**/* - -# this currently doesn't work with the way we handle our secrets -Gemspec/RequireMFA: - Enabled: false - -# current Vox Pupuli default is to use `add_development_dependency` in the gemspec -Gemspec/DevelopmentDependencies: - Enabled: false - -Style/TrailingCommaInHashLiteral: - Enabled: True - EnforcedStyleForMultiline: consistent_comma - -Style/TrailingCommaInArrayLiteral: - Enabled: True - EnforcedStyleForMultiline: consistent_comma - -Style/TrailingCommaInArguments: - Enabled: True - EnforcedStyleForMultiline: comma +inherit_gem: + voxpupuli-rubocop: rubocop.yml Metrics: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index dfac7ba..0fbcd7f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-05-02 19:00:08 UTC using RuboCop version 1.50.2. +# on 2024-05-02 19:12:37 UTC using RuboCop version 1.62.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 @@ -27,6 +27,7 @@ Lint/DuplicateMethods: - 'lib/hiera/backend/eyaml/subcommand.rb' # Offense count: 5 +# Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: - 'lib/hiera/backend/eyaml/parser/encrypted_tokens.rb' @@ -50,6 +51,8 @@ Lint/ShadowingOuterLocalVariable: - 'lib/hiera/backend/eyaml_backend.rb' # Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. Lint/UselessAssignment: Exclude: - 'features/support/env.rb' @@ -61,12 +64,14 @@ Lint/UselessAssignment: # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. Lint/UselessMethodDefinition: Exclude: - 'lib/hiera/backend/eyaml/parser/token.rb' # Offense count: 1 -# Configuration parameters: CheckForMethodsWithNoSideEffects. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects. Lint/Void: Exclude: - 'lib/hiera/backend/eyaml/parser/token.rb' @@ -101,10 +106,11 @@ Naming/HeredocDelimiterNaming: - 'lib/hiera/backend/eyaml/subcommands/unknown_command.rb' # Offense count: 1 -# Configuration parameters: AllowedPatterns. +# Configuration parameters: EnforcedStyle, AllowedPatterns. # SupportedStyles: snake_case, camelCase Naming/MethodName: - EnforcedStyle: snake_case + Exclude: + - 'lib/hiera/backend/eyaml/encryptors/pkcs7.rb' # Offense count: 1 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. @@ -201,6 +207,7 @@ Style/ClassVars: # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. Style/CollectionCompact: Exclude: - 'lib/hiera/backend/eyaml/parser/parser.rb' @@ -305,7 +312,13 @@ Style/RedundantArgument: # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowComments. +Style/RedundantFilterChain: + Exclude: + - 'lib/hiera/backend/eyaml/edithelper.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect, AllowComments. Style/RedundantInitialize: Exclude: - 'lib/hiera/backend/eyaml/parser/token.rb' diff --git a/Gemfile b/Gemfile index b1be99a..d7dcba8 100644 --- a/Gemfile +++ b/Gemfile @@ -18,8 +18,8 @@ gemspec group :development do gem 'activesupport' - gem 'aruba', '~> 2.1' - gem 'cucumber', '~> 8' + gem 'aruba', '~> 2.2' + gem 'cucumber', '~> 9.2' gem 'hiera-eyaml-plaintext' gem 'puppet', *location_for(ENV['PUPPET_VERSION']) if ENV['PUPPET_VERSION'] end diff --git a/Rakefile b/Rakefile index da46006..2398d2e 100644 --- a/Rakefile +++ b/Rakefile @@ -45,14 +45,7 @@ else end begin - require 'rubocop/rake_task' + require 'voxpupuli/rubocop/rake' rescue LoadError - # Do nothing if no required gem installed -else - RuboCop::RakeTask.new(:rubocop) do |task| - # These make the rubocop experience maybe slightly less terrible - task.options = ['--display-cop-names', '--display-style-guide', '--extra-details'] - # Use Rubocop's Github Actions formatter if possible - task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true' - end + # the voxpupuli-rubocop gem is optional end diff --git a/hiera-eyaml.gemspec b/hiera-eyaml.gemspec index 3db9bd6..95eb4c4 100644 --- a/hiera-eyaml.gemspec +++ b/hiera-eyaml.gemspec @@ -17,17 +17,11 @@ Gem::Specification.new do |gem| gem.require_paths = ['lib'] gem.add_runtime_dependency 'highline', '~> 2.1' - gem.add_runtime_dependency 'optimist', '~> 3.0', '>= 3.0.1' + gem.add_runtime_dependency 'optimist', '~> 3.1' - gem.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' - # 1.51 requires Ruby 2.7 - gem.add_development_dependency 'rubocop', '~> 1.50.0' - # 1.18 requires Ruby 2.7 - gem.add_development_dependency 'rspec-expectations', '~> 3.12.3' - gem.add_development_dependency 'rubocop-performance', '~> 1.17', '>= 1.17.1' - gem.add_development_dependency 'rubocop-rake', '~> 0.6.0' - # 2.21 requires Ruby 2.7 - gem.add_development_dependency 'rubocop-rspec', '~> 2.20.0' + gem.add_development_dependency 'rake', '~> 13.2', '>= 13.2.1' + gem.add_development_dependency 'rspec-expectations', '~> 3.13' + gem.add_development_dependency 'voxpupuli-rubocop', '2.6.0' gem.required_ruby_version = '>= 2.7', ' < 4' end diff --git a/lib/hiera/backend/eyaml/edithelper.rb b/lib/hiera/backend/eyaml/edithelper.rb index a5cbed1..522923a 100644 --- a/lib/hiera/backend/eyaml/edithelper.rb +++ b/lib/hiera/backend/eyaml/edithelper.rb @@ -15,7 +15,7 @@ def self.find_editor editor = editor.dup if editor.frozen? # values from ENV are frozen editor.gsub!(/([^\\]|^)~/, '\1' + ENV.fetch('HOME', nil)) # replace ~ with home unless escaped editor.gsub!(/(^|[^\\])"/, '\1') # remove unescaped quotes during processing - editor.gsub!(/\\ /, ' ') # unescape spaces since we quote paths + editor.gsub!('\\ ', ' ') # unescape spaces since we quote paths pieces = editor.split(' ') paths = # get possible paths, starting with longest pieces.each_with_index.map do |_, x| diff --git a/lib/hiera/backend/eyaml/encryptors/pkcs7.rb b/lib/hiera/backend/eyaml/encryptors/pkcs7.rb index dfaaabb..025eccf 100644 --- a/lib/hiera/backend/eyaml/encryptors/pkcs7.rb +++ b/lib/hiera/backend/eyaml/encryptors/pkcs7.rb @@ -77,7 +77,7 @@ def self.create_keys cert.not_before = Time.now cert.not_after = if 1.size == 8 # 64bit Time.now + (50 * 365 * 24 * 60 * 60) - else # 32bit + else # 32bit Time.at(0x7fffffff) end cert.public_key = key.public_key diff --git a/lib/hiera/backend/eyaml/parser/encrypted_tokens.rb b/lib/hiera/backend/eyaml/parser/encrypted_tokens.rb index 4d778e5..29133df 100644 --- a/lib/hiera/backend/eyaml/parser/encrypted_tokens.rb +++ b/lib/hiera/backend/eyaml/parser/encrypted_tokens.rb @@ -66,7 +66,7 @@ def to_encrypted(args = {}) case format when :block @cipher = @cipher.gsub(/\s/, '') - chevron = args[:use_chevron].nil? || args[:use_chevron] ? ">\n" : '' + chevron = (args[:use_chevron].nil? || args[:use_chevron]) ? ">\n" : '' "#{label_string}#{chevron}" + @indentation + "ENC[#{@encryptor.tag},#{@cipher}]".scan(/.{1,60}/).join("\n" + @indentation) when :string ciphertext = @cipher.gsub(/[\n\r]/, '') @@ -85,7 +85,7 @@ def to_decrypted(args = {}) case format when :block - chevron = args[:use_chevron].nil? || args[:use_chevron] ? ">\n" : '' + chevron = (args[:use_chevron].nil? || args[:use_chevron]) ? ">\n" : '' "#{label_string}#{chevron}" + indentation + "DEC#{index}::#{@encryptor.tag}[" + @plain_text + ']!' when :string "#{label_string}DEC#{index}::#{@encryptor.tag}[" + @plain_text + ']!' diff --git a/lib/hiera/backend/eyaml/plugins.rb b/lib/hiera/backend/eyaml/plugins.rb index c153861..f034b09 100644 --- a/lib/hiera/backend/eyaml/plugins.rb +++ b/lib/hiera/backend/eyaml/plugins.rb @@ -25,10 +25,10 @@ def self.options def self.find gem_version = Gem::Version.new(Gem::VERSION) this_version = Gem::Version.create(Hiera::Backend::Eyaml::VERSION) - index = gem_version >= Gem::Version.new('1.8.0') ? Gem::Specification : Gem.source_index + index = (gem_version >= Gem::Version.new('1.8.0')) ? Gem::Specification : Gem.source_index [index].flatten.each do |source| - specs = gem_version >= Gem::Version.new('1.6.0') ? source.latest_specs(true) : source.latest_specs + specs = (gem_version >= Gem::Version.new('1.6.0')) ? source.latest_specs(true) : source.latest_specs specs.each do |spec| spec = spec.to_spec if spec.respond_to?(:to_spec) diff --git a/lib/hiera/backend/eyaml/subcommands/edit.rb b/lib/hiera/backend/eyaml/subcommands/edit.rb index d5fa921..3fc8313 100644 --- a/lib/hiera/backend/eyaml/subcommands/edit.rb +++ b/lib/hiera/backend/eyaml/subcommands/edit.rb @@ -39,7 +39,7 @@ def self.preamble This is eyaml edit mode. This text (lines starting with #{prefix} at the top of the file) will be removed when you save and exit. - To edit encrypted values, change the content of the DEC()::PKCS7[]! - block#{tags.size > 1 ? " (or #{tags.drop(1).collect { |tag| "DEC()::#{tag}[]!" }.join(' or ')})." : '.'} + block#{(tags.size > 1) ? " (or #{tags.drop(1).collect { |tag| "DEC()::#{tag}[]!" }.join(' or ')})." : '.'} WARNING: DO NOT change the number in the parentheses. - To add a new encrypted value copy and paste a new block from the appropriate example below. Note that: