Skip to content

Commit

Permalink
Merge pull request #184 from bastelfreak/rubocop3
Browse files Browse the repository at this point in the history
make code more readable
  • Loading branch information
bastelfreak authored Jun 10, 2024
2 parents bf7b684 + 650f5cb commit d385ecd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
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

0 comments on commit d385ecd

Please sign in to comment.