From: Tom Hughes Date: Wed, 4 Feb 2015 21:34:21 +0000 (+0000) Subject: More rubocop cleanup X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/069e33163e0b09a7d647a98c2fde284a16a43b99 More rubocop cleanup --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e819633a2..4d8a94292 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -78,20 +78,8 @@ Style/Next: Style/NumericLiterals: MinDigits: 11 -# Offense count: 23 -Style/RegexpLiteral: - MaxSlashes: 4 - -# Offense count: 8 -Style/SelfAssignment: - Enabled: false - # Offense count: 6548 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/StringLiterals: Enabled: false - -# Offense count: 3 -Style/UnlessElse: - Enabled: false diff --git a/cookbooks/apache/providers/module.rb b/cookbooks/apache/providers/module.rb index d8072bc6e..0a85f7ee4 100644 --- a/cookbooks/apache/providers/module.rb +++ b/cookbooks/apache/providers/module.rb @@ -40,7 +40,7 @@ action :install do notifies :reload, "service[apache2]" if enabled? end - updated = updated || t.updated_by_last_action? + updated ||= t.updated_by_last_action? end new_resource.updated_by_last_action(updated) diff --git a/cookbooks/chef/libraries/remote_directory.rb b/cookbooks/chef/libraries/remote_directory.rb index 65cb9c86d..730535d44 100644 --- a/cookbooks/chef/libraries/remote_directory.rb +++ b/cookbooks/chef/libraries/remote_directory.rb @@ -19,7 +19,7 @@ class Chef name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/ end ) - files_to_purge = files_to_purge - files_transferred + files_to_purge -= files_transferred purge_unmanaged_files(files_to_purge) end end diff --git a/cookbooks/exim/recipes/default.rb b/cookbooks/exim/recipes/default.rb index 9c687a3c9..da8ba5c9c 100644 --- a/cookbooks/exim/recipes/default.rb +++ b/cookbooks/exim/recipes/default.rb @@ -61,14 +61,14 @@ end relay_to_domains = node[:exim][:relay_to_domains] node[:exim][:routes].each_value do |route| - relay_to_domains = relay_to_domains | route[:domains] if route[:host] + relay_to_domains |= route[:domains] if route[:host] end relay_from_hosts = node[:exim][:relay_from_hosts] if node[:exim][:smarthost_name] search(:node, "exim_smarthost_via:#{node[:exim][:smarthost_name]}\\:*").each do |host| - relay_from_hosts = relay_from_hosts | host.ipaddresses(:role => :external) + relay_from_hosts |= host.ipaddresses(:role => :external) end end diff --git a/cookbooks/munin/files/default/plugins/api_calls_ b/cookbooks/munin/files/default/plugins/api_calls_ index f56fa4831..58797b833 100755 --- a/cookbooks/munin/files/default/plugins/api_calls_ +++ b/cookbooks/munin/files/default/plugins/api_calls_ @@ -32,13 +32,13 @@ def categorise_uri(line) uri = line.split(" ")[1] case uri - when /api\/0\.6\/map/ then :map - when /api\/0\.6\/changeset\/[0-9]*\/upload/ then :upload - when /api\/0\.6\/amf/ then :amf - when /api\/0\.6\/(node|way|relation)\/[0-9]*\/history/ then :history - when /api\/0\.6\/(node|way|relation)\/[0-9]*\/full/ then :full - when /api\/0\.6\/trackpoints/ then :trkpts - when /api\/0\.6\// then :other + when %r{api/0\.6/map} then :map + when %r{api/0\.6/changeset/[0-9]*/upload} then :upload + when %r{api/0\.6/amf} then :amf + when %r{api/0\.6/(node|way|relation)/[0-9]*/history} then :history + when %r{api/0\.6/(node|way|relation)/[0-9]*/full} then :full + when %r{api/0\.6/trackpoints} then :trkpts + when %r{api/0\.6/} then :other else :web end end diff --git a/cookbooks/munin/files/default/plugins/api_calls_num b/cookbooks/munin/files/default/plugins/api_calls_num index 0e5034a63..b1d454228 100755 --- a/cookbooks/munin/files/default/plugins/api_calls_num +++ b/cookbooks/munin/files/default/plugins/api_calls_num @@ -42,13 +42,13 @@ def categorise_uri(line) uri = line.split(" ")[1] case uri - when /api\/0\.6\/map/ then :map - when /api\/0\.6\/changeset\/[0-9]*\/upload/ then :upload - when /api\/0\.6\/amf/ then :amf - when /api\/0\.6\/(node|way|relation)\/[0-9]*\/history/ then :history - when /api\/0\.6\/(node|way|relation)\/[0-9]*\/full/ then :full - when /api\/0\.6\/trackpoints/ then :trkpts - when /api\/0\.6\// then :other + when %r{api/0\.6/map} then :map + when %r{api/0\.6/changeset/[0-9]*/upload} then :upload + when %r{api/0\.6/amf} then :amf + when %r{api/0\.6/(node|way|relation)/[0-9]*/history} then :history + when %r{api/0\.6/(node|way|relation)/[0-9]*/full} then :full + when %r{api/0\.6/trackpoints} then :trkpts + when %r{api/0\.6/} then :other else :web end end diff --git a/cookbooks/munin/files/default/plugins/api_waits_ b/cookbooks/munin/files/default/plugins/api_waits_ index f78152665..5eaa81a57 100755 --- a/cookbooks/munin/files/default/plugins/api_waits_ +++ b/cookbooks/munin/files/default/plugins/api_waits_ @@ -32,13 +32,13 @@ def categorise_uri(line) uri = line.split(" ")[1] case uri - when /api\/0\.6\/map/ then :map - when /api\/0\.6\/changeset\/[0-9]*\/upload/ then :upload - when /api\/0\.6\/amf/ then :amf - when /api\/0\.6\/(node|way|relation)\/[0-9]*\/history/ then :history - when /api\/0\.6\/(node|way|relation)\/[0-9]*\/full/ then :full - when /api\/0\.6\/trackpoints/ then :trkpts - when /api\/0\.6\// then :other + when %r{api/0\.6/map} then :map + when %r{api/0\.6/changeset/[0-9]*/upload/} then :upload + when %r{api/0\.6/amf} then :amf + when %r{api/0\.6/(node|way|relation)/[0-9]*/history} then :history + when %r{api/0\.6/(node|way|relation)/[0-9]*/full} then :full + when %r{api/0\.6/trackpoints} then :trkpts + when %r{api/0\.6/} then :other else :web end end diff --git a/cookbooks/munin/providers/plugin.rb b/cookbooks/munin/providers/plugin.rb index 193983471..293719066 100644 --- a/cookbooks/munin/providers/plugin.rb +++ b/cookbooks/munin/providers/plugin.rb @@ -42,7 +42,7 @@ action :create do variables new_resource.conf_variables end - updated = updated || c.updated_by_last_action? + updated ||= c.updated_by_last_action? end new_resource.updated_by_last_action(updated) @@ -61,7 +61,7 @@ action :delete do action :delete end - updated = updated || c.updated_by_last_action? + updated ||= c.updated_by_last_action? end new_resource.updated_by_last_action(updated) diff --git a/cookbooks/nodejs/providers/package.rb b/cookbooks/nodejs/providers/package.rb index ec20d157d..5e3ca0684 100644 --- a/cookbooks/nodejs/providers/package.rb +++ b/cookbooks/nodejs/providers/package.rb @@ -40,7 +40,7 @@ action :install do package_name = new_resource.package_name end - unless @packages.include?(new_resource.package_name) + if !@packages.include?(new_resource.package_name) shell_out!("npm install --global #{package_name}") new_resource.updated_by_last_action(true) else diff --git a/cookbooks/osqa/recipes/default.rb b/cookbooks/osqa/recipes/default.rb index e283f3795..db96e2e79 100644 --- a/cookbooks/osqa/recipes/default.rb +++ b/cookbooks/osqa/recipes/default.rb @@ -101,7 +101,7 @@ node[:osqa][:sites].each do |site| line.gsub!(/^( *)'PASSWORD': '.*',/, "\\1'PASSWORD': '#{database_password}',") line.gsub!(/^ALLOWED_HOSTS = .*/, "ALLOWED_HOSTS = ('help.openstreetmap.org',)") line.gsub!(/^CACHE_BACKEND = .*/, "CACHE_BACKEND = 'memcached://127.0.0.1:11211/'") - line.gsub!(/^APP_URL = 'http:\/\/'/, "APP_URL = 'http://#{name}'") + line.gsub!(%r{^APP_URL = 'http://'}, "APP_URL = 'http://#{name}'") line.gsub!(/^TIME_ZONE = 'America\/New_York'/, "TIME_ZONE = 'Europe/London'") line.gsub!(/^DISABLED_MODULES = \[([^\]]+)\]/, "DISABLED_MODULES = [\\1, 'localauth', 'facebookauth', 'oauthauth']") diff --git a/cookbooks/postgresql/providers/database.rb b/cookbooks/postgresql/providers/database.rb index a63197afe..c2b000d13 100644 --- a/cookbooks/postgresql/providers/database.rb +++ b/cookbooks/postgresql/providers/database.rb @@ -33,7 +33,7 @@ def load_current_resource end action :create do - unless @pg.databases.include?(new_resource.database) + if !@pg.databases.include?(new_resource.database) @pg.execute(:command => "CREATE DATABASE \"#{new_resource.database}\" OWNER \"#{new_resource.owner}\" TEMPLATE template0 ENCODING '#{new_resource.encoding}' LC_COLLATE '#{new_resource.collation}' LC_CTYPE '#{new_resource.ctype}'") new_resource.updated_by_last_action(true) else diff --git a/cookbooks/postgresql/providers/user.rb b/cookbooks/postgresql/providers/user.rb index 11c783e22..791368255 100644 --- a/cookbooks/postgresql/providers/user.rb +++ b/cookbooks/postgresql/providers/user.rb @@ -39,7 +39,7 @@ action :create do createrole = new_resource.createrole ? "CREATEROLE" : "NOCREATEROLE" replication = new_resource.replication ? "REPLICATION" : "NOREPLICATION" - unless @pg.users.include?(new_resource.user) + if !@pg.users.include?(new_resource.user) @pg.execute(:command => "CREATE ROLE \"#{new_resource.user}\" LOGIN #{password} #{superuser} #{createdb} #{createrole}") new_resource.updated_by_last_action(true) else diff --git a/cookbooks/spamassassin/recipes/default.rb b/cookbooks/spamassassin/recipes/default.rb index 2c7e49dd5..dd1e19eb1 100644 --- a/cookbooks/spamassassin/recipes/default.rb +++ b/cookbooks/spamassassin/recipes/default.rb @@ -42,11 +42,11 @@ trusted_networks = node[:exim][:relay_from_hosts] if node[:exim][:smarthost_name] search(:node, "exim_smarthost_via:#{node[:exim][:smarthost_name]}\\:*").each do |host| - trusted_networks = trusted_networks | host.ipaddresses(:role => :external) + trusted_networks |= host.ipaddresses(:role => :external) end end -trusted_networks = trusted_networks - ["127.0.0.1", "::1"] +trusted_networks -= ["127.0.0.1", "::1"] template "/etc/spamassassin/local.cf" do source "local.cf.erb" diff --git a/cookbooks/web/recipes/cgimap.rb b/cookbooks/web/recipes/cgimap.rb index 891609fd0..365c2b560 100644 --- a/cookbooks/web/recipes/cgimap.rb +++ b/cookbooks/web/recipes/cgimap.rb @@ -92,7 +92,7 @@ cgimap_init = edit_file "#{cgimap_directory}/scripts/cgimap.init" do |line| line.gsub!(/^CGIMAP_LOGFILE=.*;/, "CGIMAP_LOGFILE=#{log_directory}/cgimap.log;") line.gsub!(/^CGIMAP_MEMCACHE=.*;/, "CGIMAP_MEMCACHE=rails1,rails2,rails3;") - line.gsub!(/\/home\/rails\/bin\/map/, "#{cgimap_directory}/map") + line.gsub!(%r{/home/rails/bin/map}, "#{cgimap_directory}/map") if database_readonly line.gsub!(/--daemon/, "--daemon --readonly")