]> git.openstreetmap.org Git - chef.git/commitdiff
More rubocop cleanup
authorTom Hughes <tom@compton.nu>
Wed, 4 Feb 2015 21:34:21 +0000 (21:34 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 4 Feb 2015 22:45:09 +0000 (22:45 +0000)
14 files changed:
.rubocop_todo.yml
cookbooks/apache/providers/module.rb
cookbooks/chef/libraries/remote_directory.rb
cookbooks/exim/recipes/default.rb
cookbooks/munin/files/default/plugins/api_calls_
cookbooks/munin/files/default/plugins/api_calls_num
cookbooks/munin/files/default/plugins/api_waits_
cookbooks/munin/providers/plugin.rb
cookbooks/nodejs/providers/package.rb
cookbooks/osqa/recipes/default.rb
cookbooks/postgresql/providers/database.rb
cookbooks/postgresql/providers/user.rb
cookbooks/spamassassin/recipes/default.rb
cookbooks/web/recipes/cgimap.rb

index e819633a2818498e5b271407e3d4aec1dad05e2c..4d8a942928a5aec78ad9bd33c2a109744688900d 100644 (file)
@@ -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
index d8072bc6ef84b1e28caaa75f1d80c7af389183aa..0a85f7ee4ce1c004642a0d7837dae00f7043ce85 100644 (file)
@@ -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)
index 65cb9c86d9b2f2e09721b8308f15686356cb6975..730535d445445f6cbe0a7446661bebea39c2bc56 100644 (file)
@@ -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
index 9c687a3c9cdc118e119d96a1e417b474264bc79e..da8ba5c9cb981a3aabe96ba30f5a901bfd50355d 100644 (file)
@@ -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
 
index f56fa4831cac708d54239a70579972af49ba66a0..58797b8330ffa276cfed75f6b1e52b380aec3881 100755 (executable)
@@ -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
index 0e5034a6316778e18f4bbb4c794e2b7094cf2d12..b1d45422845e37eee924aa028819403d79baac3c 100755 (executable)
@@ -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
index f78152665ba06afb28828b9cd9648e76a70b57b5..5eaa81a57c486530daf41d53f3236d794a779ff6 100755 (executable)
@@ -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
index 193983471f7a9e0d60f4b3e419a0bdab3a2cc48b..2937190665a63025bbebe5ce350e34df90f6048d 100644 (file)
@@ -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)
index ec20d157d023b9aa382aa1dee6aeb065e87b8471..5e3ca068468a9377f44ca1a0d464b8354cb45edd 100644 (file)
@@ -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
index e283f37952b63d5b9077c9953d60ac30362ec037..db96e2e7921427b6ccb4ed18a8d8faa2f2ee05e8 100644 (file)
@@ -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']")
 
index a63197afe63325dd2bd8b027fa3d605134beaa65..c2b000d13d86b54f6e5412c90645b3d49eef69d8 100644 (file)
@@ -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
index 11c783e22264f1b132dae4b1c8ec7ce0c1d41df1..79136825528c9617fdd6732c15e9046475c5419b 100644 (file)
@@ -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
index 2c7e49dd58cf3a73755fa3b83db60b5757d1938c..dd1e19eb1bff77fb8a475f562f288944594c44a0 100644 (file)
@@ -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"
index 891609fd0f589d22a689a88cc5a52d183bf80d4e..365c2b5600b87d93cc8987886bb4c0c9a181e6bc 100644 (file)
@@ -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")