Zfilipin has uploaded a new change for review. https://gerrit.wikimedia.org/r/259716
Change subject: RuboCop: fixed Style/IfUnlessModifier offense ...................................................................... RuboCop: fixed Style/IfUnlessModifier offense Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. Change-Id: Ibdb9cbfdebd126469dcef3b176b4b7252ae26cc7 See: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier Bug: T112651 --- M .rubocop_todo.yml M modules/backup/Rakefile M modules/bacula/Rakefile M modules/base/Rakefile M modules/base/files/monitoring/check_puppetrun M modules/install_server/Rakefile M modules/mirrors/Rakefile M modules/nrpe/Rakefile M modules/osm/Rakefile M modules/postgresql/Rakefile M modules/servermon/Rakefile M modules/service/Rakefile M modules/squid3/Rakefile M modules/strongswan/Rakefile M modules/wmflib/Rakefile M modules/wmflib/lib/puppet/parser/functions/ipresolve.rb M modules/wmflib/lib/puppet/parser/functions/os_version.rb M modules/wmflib/lib/puppet/parser/functions/ssl_ciphersuite.rb M utils/hiera_lookup 19 files changed, 22 insertions(+), 72 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/16/259716/1 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1ad9f5f..72a434d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -158,12 +158,6 @@ Style/HashSyntax: Enabled: false -# Offense count: 22 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. -Style/IfUnlessModifier: - Enabled: false - # Offense count: 276 # Cop supports --auto-correct. # Configuration parameters: Width. diff --git a/modules/backup/Rakefile b/modules/backup/Rakefile index d9226a8..9baeaf5 100644 --- a/modules/backup/Rakefile +++ b/modules/backup/Rakefile @@ -14,9 +14,7 @@ task :setup do FileUtils.mkdir_p('spec/fixtures/modules/%s' % modulename) symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/bacula/Rakefile b/modules/bacula/Rakefile index d9226a8..9baeaf5 100644 --- a/modules/bacula/Rakefile +++ b/modules/bacula/Rakefile @@ -14,9 +14,7 @@ task :setup do FileUtils.mkdir_p('spec/fixtures/modules/%s' % modulename) symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/base/Rakefile b/modules/base/Rakefile index 165b532..653c1b1 100644 --- a/modules/base/Rakefile +++ b/modules/base/Rakefile @@ -21,9 +21,7 @@ FileUtils.ln_s('../../../../%s' % x, 'spec/fixtures/modules/%s' % x) end symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/base/files/monitoring/check_puppetrun b/modules/base/files/monitoring/check_puppetrun index 21961c7..c31e344 100755 --- a/modules/base/files/monitoring/check_puppetrun +++ b/modules/base/files/monitoring/check_puppetrun @@ -62,13 +62,9 @@ exit 3 end -if File.exists?(adminlockfile) - enabled = false -end +enabled = false if File.exists?(adminlockfile) -if File.exists?(runlockfile) - running = true -end +running = true if File.exists?(runlockfile) lastrun = File.stat(statefile).mtime.to_i if File.exists?(statefile) @@ -96,9 +92,7 @@ def time_ago(s) units = {86400 => 'day', 3600 => 'hour', 60 => 'minute', 1 => 'second'} - if s == 0 - return "0 seconds" - end + return "0 seconds" if s == 0 units.sort.reverse.each do |len, unit| return "#{s / len} #{unit}#{'s' if s / len > 1}" if s >= len end diff --git a/modules/install_server/Rakefile b/modules/install_server/Rakefile index 0542f30..4d063aa 100644 --- a/modules/install_server/Rakefile +++ b/modules/install_server/Rakefile @@ -21,9 +21,7 @@ FileUtils.ln_s('../../../../%s' % x, 'spec/fixtures/modules/%s' % x) end symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/mirrors/Rakefile b/modules/mirrors/Rakefile index 0542f30..4d063aa 100644 --- a/modules/mirrors/Rakefile +++ b/modules/mirrors/Rakefile @@ -21,9 +21,7 @@ FileUtils.ln_s('../../../../%s' % x, 'spec/fixtures/modules/%s' % x) end symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/nrpe/Rakefile b/modules/nrpe/Rakefile index d9226a8..9baeaf5 100644 --- a/modules/nrpe/Rakefile +++ b/modules/nrpe/Rakefile @@ -14,9 +14,7 @@ task :setup do FileUtils.mkdir_p('spec/fixtures/modules/%s' % modulename) symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/osm/Rakefile b/modules/osm/Rakefile index d9226a8..9baeaf5 100644 --- a/modules/osm/Rakefile +++ b/modules/osm/Rakefile @@ -14,9 +14,7 @@ task :setup do FileUtils.mkdir_p('spec/fixtures/modules/%s' % modulename) symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/postgresql/Rakefile b/modules/postgresql/Rakefile index d9226a8..9baeaf5 100644 --- a/modules/postgresql/Rakefile +++ b/modules/postgresql/Rakefile @@ -14,9 +14,7 @@ task :setup do FileUtils.mkdir_p('spec/fixtures/modules/%s' % modulename) symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/servermon/Rakefile b/modules/servermon/Rakefile index 165b532..653c1b1 100644 --- a/modules/servermon/Rakefile +++ b/modules/servermon/Rakefile @@ -21,9 +21,7 @@ FileUtils.ln_s('../../../../%s' % x, 'spec/fixtures/modules/%s' % x) end symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/service/Rakefile b/modules/service/Rakefile index c3293b0..729fb3d 100644 --- a/modules/service/Rakefile +++ b/modules/service/Rakefile @@ -14,9 +14,7 @@ task :setup do # TODO: create a virtualenv to run this all symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/squid3/Rakefile b/modules/squid3/Rakefile index 5bed768..d3eefa2 100644 --- a/modules/squid3/Rakefile +++ b/modules/squid3/Rakefile @@ -19,9 +19,7 @@ FileUtils.ln_s('../../../../%s' % x, 'spec/fixtures/modules/%s' % x) end symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/strongswan/Rakefile b/modules/strongswan/Rakefile index a0c3b79..12e9770 100644 --- a/modules/strongswan/Rakefile +++ b/modules/strongswan/Rakefile @@ -14,9 +14,7 @@ task :setup do FileUtils.mkdir_p('spec/fixtures/modules/%s' % modulename) symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/wmflib/Rakefile b/modules/wmflib/Rakefile index a0c3b79..12e9770 100644 --- a/modules/wmflib/Rakefile +++ b/modules/wmflib/Rakefile @@ -14,9 +14,7 @@ task :setup do FileUtils.mkdir_p('spec/fixtures/modules/%s' % modulename) symlinks.each do |x| - if !File.exist?(x[0]) - FileUtils.ln_s(x[1], x[0]) - end + FileUtils.ln_s(x[1], x[0]) if !File.exist?(x[0]) end end diff --git a/modules/wmflib/lib/puppet/parser/functions/ipresolve.rb b/modules/wmflib/lib/puppet/parser/functions/ipresolve.rb index 7470ff5..05772f1 100644 --- a/modules/wmflib/lib/puppet/parser/functions/ipresolve.rb +++ b/modules/wmflib/lib/puppet/parser/functions/ipresolve.rb @@ -51,16 +51,12 @@ end def read(key) - if is_valid?key - return @cache[key].value - end + return @cache[key].value if is_valid?key return nil end def read_stale(key) - if @cache.key?(key) - return @cache[key].value - end + return @cache[key].value if @cache.key?(key) return nil end end @@ -94,9 +90,7 @@ rescue # If resolution fails and we do have a cached stale value, use it res = @cache.read_stale(cache_key) - if res.nil? - fail("DNS lookup failed for #{name} #{type}") - end + fail("DNS lookup failed for #{name} #{type}") if res.nil? res.to_s end else diff --git a/modules/wmflib/lib/puppet/parser/functions/os_version.rb b/modules/wmflib/lib/puppet/parser/functions/os_version.rb index 4e97602..e01f8f7 100644 --- a/modules/wmflib/lib/puppet/parser/functions/os_version.rb +++ b/modules/wmflib/lib/puppet/parser/functions/os_version.rb @@ -70,9 +70,7 @@ next unless self_id == other_id - if os_versions[other_id].key?(other_release) - other_was_codename = true - end + other_was_codename = true if os_versions[other_id].key?(other_release) other_release = os_versions[other_id][other_release] || other_release diff --git a/modules/wmflib/lib/puppet/parser/functions/ssl_ciphersuite.rb b/modules/wmflib/lib/puppet/parser/functions/ssl_ciphersuite.rb index bb6ba2c..ccb78f8 100644 --- a/modules/wmflib/lib/puppet/parser/functions/ssl_ciphersuite.rb +++ b/modules/wmflib/lib/puppet/parser/functions/ssl_ciphersuite.rb @@ -224,9 +224,7 @@ end output.push("ssl_ciphers #{cipherlist};") output.push('ssl_prefer_server_ciphers on;') - if set_dhparam - output.push('ssl_dhparam /etc/ssl/dhparam.pem;') - end + output.push('ssl_dhparam /etc/ssl/dhparam.pem;') if set_dhparam unless hsts_days.nil? hsts_seconds = hsts_days * 86400 output.push("add_header Strict-Transport-Security \"max-age=#{hsts_seconds}\";") diff --git a/utils/hiera_lookup b/utils/hiera_lookup index 1fa0528..8df4933 100755 --- a/utils/hiera_lookup +++ b/utils/hiera_lookup @@ -73,8 +73,6 @@ abort(usage "\nError: KEY is required") if key.match('^--') hiera = Hiera.new(:config => cfg) -if not verbose || get_scope().include?('::debug') - Hiera.logger = "noop" -end +Hiera.logger = "noop" if not verbose || get_scope().include?('::debug') puts hiera.lookup(key, nil, get_scope(), nil, :priority) -- To view, visit https://gerrit.wikimedia.org/r/259716 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibdb9cbfdebd126469dcef3b176b4b7252ae26cc7 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Zfilipin <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
