Skip to content

Commit d385ecd

Browse files
authored
Merge pull request #184 from bastelfreak/rubocop3
make code more readable
2 parents bf7b684 + 650f5cb commit d385ecd

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ inherit_gem:
77
Layout/LineLength:
88
Enabled: false
99

10+
Style/IfUnlessModifier:
11+
Enabled: false
12+
1013
# To match the gem name
1114
Naming/FileName:
1215
Exclude:

lib/rspec-puppet-facts.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ def self.common_facts
259259

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

262-
@common_facts[:augeasversion] = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD).get('/augeas/version') if augeas?
262+
if augeas?
263+
@common_facts[:augeasversion] = Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD).get('/augeas/version')
264+
end
263265
@common_facts = stringify_keys(@common_facts) if RSpec.configuration.facterdb_string_keys
264266

265267
@common_facts
@@ -296,7 +298,9 @@ def self.mcollective?
296298
# @return [Array<Hash>]
297299
# @api private
298300
def self.meta_supported_os
299-
raise StandardError, 'Unknown operatingsystem support in the metadata file!' unless metadata['operatingsystem_support'].is_a? Array
301+
unless metadata['operatingsystem_support'].is_a? Array
302+
raise StandardError, 'Unknown operatingsystem support in the metadata file!'
303+
end
300304

301305
metadata['operatingsystem_support']
302306
end
@@ -308,7 +312,9 @@ def self.meta_supported_os
308312
# @api private
309313
def self.metadata
310314
return @metadata if @metadata
311-
raise StandardError, "Can't find metadata.json... dunno why" unless File.file? metadata_file
315+
unless File.file? metadata_file
316+
raise StandardError, "Can't find metadata.json... dunno why"
317+
end
312318

313319
content = File.read metadata_file
314320
@metadata = JSON.parse content
@@ -375,6 +381,9 @@ def self.facter_version_to_loose_requirement_string(version)
375381
elsif /\A[0-9]+\Z/.match?(version)
376382
# Interpret 3 as < 4
377383
"< #{version.to_i + 1}"
384+
else # rubocop:disable Style/EmptyElse
385+
# This would be the same as the strict requirement
386+
nil
378387
end
379388
end
380389

0 commit comments

Comments
 (0)