diff --git a/.rubocop.yml b/.rubocop.yml index 131c57b2..7bbc9e09 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,6 +7,9 @@ inherit_gem: Layout/LineLength: Enabled: false +Style/IfUnlessModifier: + Enabled: false + # To match the gem name Naming/FileName: Exclude: diff --git a/lib/rspec-puppet-facts.rb b/lib/rspec-puppet-facts.rb index 1829838a..81a34fd2 100644 --- a/lib/rspec-puppet-facts.rb +++ b/lib/rspec-puppet-facts.rb @@ -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 @@ -296,7 +298,9 @@ def self.mcollective? # @return [Array] # @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 @@ -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 @@ -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