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

rubocop: Fix Style cops #180

Merged
merged 1 commit into from
Jun 9, 2024
Merged

Conversation

bastelfreak
Copy link
Member

No description provided.

@bastelfreak bastelfreak self-assigned this Jun 9, 2024

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/RedundantSort:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't #181 solve that?

@@ -379,9 +371,6 @@ def self.facter_version_to_loose_requirement_string(version)
elsif /\A[0-9]+\Z/.match?(version)
# Interpret 3 as < 4
"< #{version.to_i + 1}"
else
# This would be the same as the strict requirement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally wrote this because it explicitly documents the flow. Is it worth keeping that?

@bastelfreak bastelfreak merged commit 6913f88 into voxpupuli:master Jun 9, 2024
7 checks passed
unless metadata['operatingsystem_support'].is_a? Array
fail StandardError, 'Unknown operatingsystem support in the metadata file!'
end
raise StandardError, 'Unknown operatingsystem support in the metadata file!' unless metadata['operatingsystem_support'].is_a? Array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this is less readable. Can we disable the guard condition cop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless File.file? metadata_file
fail StandardError, "Can't find metadata.json... dunno why"
end
raise StandardError, "Can't find metadata.json... dunno why" unless File.file? metadata_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -397,13 +386,13 @@ def self.facter_version_for_puppet_version(puppet_version)
fd = File.open(json_path, 'rb:UTF-8')
data = JSON.parse(fd.read)

version_map = data.map { |_, versions|
version_map = data.map do |_, versions|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #183 I do more refactoring that I think helps. I'd expect .map.compact to be flagged in rubocop-performance.

if augeas?
@common_facts[:augeasversion] = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD).get('/augeas/version')
end
@common_facts[:augeasversion] = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD).get('/augeas/version') if augeas?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy with the condition given the line length. AFAIK the guard condition cop supports line lengths, but we disabled that cop so the guard condition cop is too trigger happy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants