Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) Fix rubocop lint warnings #1298

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/pdk/cli/util/option_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/pdk/config/namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ def include_in_parent?
# @api private
def read_only!
@read_only = true
@mounts.each { |_, child| child.read_only! }
# pass the read_only! method as a block to the each_value method. This means that
# for each value in the @mounts hash, the read_only! method will be called on that value.
@mounts.each_value(&:read_only!)
end

private
Expand Down
10 changes: 7 additions & 3 deletions lib/pdk/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@ def write_junit(target = self.class.default_target)
# This report is designed for interactive use by a human and so excludes
# all passing events in order to be consise.
#
# @param target [#write] an IO object that the report will be written to.
# Defaults to PDK::Report.default_target.
# @param target [String, IO] The IO target to write the report to.
# If a String is provided, the report will be written to a file with the given path.
# If an IO object is provided, the report will be written to the IO object.
# If no target is provided, the default target PDK::Report.default_target will be used.
#
# @return [void]
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
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
6 changes: 5 additions & 1 deletion lib/pdk/util/puppet_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,14 @@ def find_in_rubygems(requirement)
version.nil? ? nil : { gem_version: version, ruby_version: PDK::Util::RubyVersion.default_ruby_version }
end

# Finds the specified requirement in the package cache.
#
# @param requirement [Gem::Requirement] The requirement to search for.
# @return [Hash] A hash containing the gem version and ruby version if found, or nil if not found.
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?
Expand Down
2 changes: 1 addition & 1 deletion spec/support/file_based_namespaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion spec/support/validators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down