From dc2df478b197588c8b881e2e4d0b1ef6e8c16637 Mon Sep 17 00:00:00 2001 From: Paula Muir Date: Tue, 19 Dec 2023 10:14:21 +0000 Subject: [PATCH] (maint) Update Rubocop --- lib/pdk/cli/util/option_normalizer.rb | 2 +- lib/pdk/config/namespace.rb | 2 +- lib/pdk/report.rb | 2 +- lib/pdk/report/event.rb | 2 +- lib/pdk/util.rb | 2 +- lib/pdk/util/puppet_version.rb | 2 +- spec/support/file_based_namespaces.rb | 2 +- spec/support/validators.rb | 2 +- spec/unit/pdk/report/event_spec.rb | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/pdk/cli/util/option_normalizer.rb b/lib/pdk/cli/util/option_normalizer.rb index d8680581b..533edef53 100644 --- a/lib/pdk/cli/util/option_normalizer.rb +++ b/lib/pdk/cli/util/option_normalizer.rb @@ -44,7 +44,7 @@ def self.report_formats(formats) target = PDK::Report.default_target end - { method: "write_#{format}".to_sym, target: target } + { method: :"write_#{format}", target: target } end end end diff --git a/lib/pdk/config/namespace.rb b/lib/pdk/config/namespace.rb index 712840951..df9075d08 100644 --- a/lib/pdk/config/namespace.rb +++ b/lib/pdk/config/namespace.rb @@ -217,7 +217,7 @@ def include_in_parent? # @api private def read_only! @read_only = true - @mounts.each { |_, child| child.read_only! } + @mounts.each_value(&:read_only!) end private diff --git a/lib/pdk/report.rb b/lib/pdk/report.rb index 4bea9e1c8..8f44b1fec 100644 --- a/lib/pdk/report.rb +++ b/lib/pdk/report.rb @@ -99,7 +99,7 @@ def write_text(target = self.class.default_target) coverage_report = nil report = [] - events.each do |_tool, tool_events| + events.each_value do |tool_events| tool_events.each do |event| if event.rspec_puppet_coverage? coverage_report = event.to_text diff --git a/lib/pdk/report/event.rb b/lib/pdk/report/event.rb index 6585e5939..c2930af00 100644 --- a/lib/pdk/report/event.rb +++ b/lib/pdk/report/event.rb @@ -53,7 +53,7 @@ class Event # @raise [ArgumentError] (see #sanitise_data) def initialize(data) sanitise_data(data).each do |key, value| - instance_variable_set("@#{key}", value) + instance_variable_set(:"@#{key}", value) end end diff --git a/lib/pdk/util.rb b/lib/pdk/util.rb index c649d5839..9b8e7de2d 100644 --- a/lib/pdk/util.rb +++ b/lib/pdk/util.rb @@ -95,7 +95,7 @@ def package_install? def development_mode? require 'pdk/util/version' - (!PDK::Util::Version.git_ref.nil? || PDK::VERSION.end_with?('.pre')) + !PDK::Util::Version.git_ref.nil? || PDK::VERSION.end_with?('.pre') end module_function :development_mode? diff --git a/lib/pdk/util/puppet_version.rb b/lib/pdk/util/puppet_version.rb index 14f83108b..83bfe4a64 100644 --- a/lib/pdk/util/puppet_version.rb +++ b/lib/pdk/util/puppet_version.rb @@ -209,7 +209,7 @@ def find_in_rubygems(requirement) def find_in_package_cache(requirement) require 'pdk/util/ruby_version' - PDK::Util::RubyVersion.versions.each do |ruby_version, _| + PDK::Util::RubyVersion.versions.each_key do |ruby_version| PDK::Util::RubyVersion.use(ruby_version) version = PDK::Util::RubyVersion.available_puppet_versions.find { |r| requirement.satisfied_by?(r) } return { gem_version: version, ruby_version: ruby_version } unless version.nil? diff --git a/spec/support/file_based_namespaces.rb b/spec/support/file_based_namespaces.rb index a99acb5c1..6f84bf09a 100644 --- a/spec/support/file_based_namespaces.rb +++ b/spec/support/file_based_namespaces.rb @@ -50,7 +50,7 @@ it 'does not add or lose any data when round tripping the serialization' do # Force the file to be loaded - expected_settings.each { |k, _| subject[k] } + expected_settings.each_key { |k| subject[k] } # Force a setting to be saved by setting a single known value expect(PDK::Util::Filesystem).to receive(:write_file).with(subject.file, content) key = expected_settings.keys[0] diff --git a/spec/support/validators.rb b/spec/support/validators.rb index 26fc0f313..f12ec19ea 100644 --- a/spec/support/validators.rb +++ b/spec/support/validators.rb @@ -74,7 +74,7 @@ def invoke(report) RSpec::Matchers.define :have_number_of_events do |state, expected_count| def get_event_count(report, state) count = 0 - report.events.each do |_source, events| + report.events.each_value do |events| count += events.count { |event| event.state == state } end diff --git a/spec/unit/pdk/report/event_spec.rb b/spec/unit/pdk/report/event_spec.rb index 160e32999..ec877b789 100644 --- a/spec/unit/pdk/report/event_spec.rb +++ b/spec/unit/pdk/report/event_spec.rb @@ -140,9 +140,9 @@ methods.each do |method| if method == state_method - it { is_expected.to send("be_#{method}") } + it { is_expected.to send(:"be_#{method}") } else - it { is_expected.not_to send("be_#{method}") } + it { is_expected.not_to send(:"be_#{method}") } end end end