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

make code more readable #184

Merged
merged 1 commit into from
Jun 10, 2024
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
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inherit_gem:
Layout/LineLength:
Enabled: false

Style/IfUnlessModifier:
Enabled: false

# To match the gem name
Naming/FileName:
Exclude:
Expand Down
15 changes: 12 additions & 3 deletions lib/rspec-puppet-facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def self.common_facts

@common_facts[:mco_version] = MCollective::VERSION if mcollective?

@common_facts[:augeasversion] = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD).get('/augeas/version') if augeas?
if augeas?
@common_facts[:augeasversion] = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD).get('/augeas/version')
end
@common_facts = stringify_keys(@common_facts) if RSpec.configuration.facterdb_string_keys

@common_facts
Expand Down Expand Up @@ -296,7 +298,9 @@ def self.mcollective?
# @return [Array<Hash>]
# @api private
def self.meta_supported_os
raise StandardError, 'Unknown operatingsystem support in the metadata file!' unless metadata['operatingsystem_support'].is_a? Array
unless metadata['operatingsystem_support'].is_a? Array
raise StandardError, 'Unknown operatingsystem support in the metadata file!'
end

metadata['operatingsystem_support']
end
Expand All @@ -308,7 +312,9 @@ def self.meta_supported_os
# @api private
def self.metadata
return @metadata if @metadata
raise StandardError, "Can't find metadata.json... dunno why" unless File.file? metadata_file
unless File.file? metadata_file
raise StandardError, "Can't find metadata.json... dunno why"
end

content = File.read metadata_file
@metadata = JSON.parse content
Expand Down Expand Up @@ -375,6 +381,9 @@ 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 # rubocop:disable Style/EmptyElse
# This would be the same as the strict requirement
nil
end
end

Expand Down