]> git.openstreetmap.org Git - chef.git/commitdiff
Fix rubocop warnings
authorTom Hughes <tom@compton.nu>
Tue, 14 Nov 2017 19:11:00 +0000 (19:11 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 14 Nov 2017 19:11:00 +0000 (19:11 +0000)
19 files changed:
.rubocop.yml
cookbooks/accounts/recipes/default.rb
cookbooks/civicrm/recipes/default.rb
cookbooks/hardware/recipes/default.rb
cookbooks/imagery/recipes/gb_os_sv.rb
cookbooks/kibana/recipes/default.rb
cookbooks/munin/files/default/plugins/api_calls_
cookbooks/munin/files/default/plugins/api_calls_num
cookbooks/munin/files/default/plugins/api_calls_status
cookbooks/munin/files/default/plugins/api_waits_
cookbooks/munin/files/default/plugins/passenger_memory
cookbooks/munin/files/default/plugins/passenger_processes
cookbooks/munin/files/default/plugins/passenger_queues
cookbooks/munin/files/default/plugins/passenger_requests
cookbooks/mysql/libraries/mysql.rb
cookbooks/planet/files/default/replication-bin/replicate-changesets
cookbooks/wordpress/providers/site.rb
roles/paulla.rb
roles/teleservice.rb

index 07985407d1cf89d05b7de06242a8b9c020d7f26b..9d9ce40b0ac2f6b99f34911552a1f00b999a63e4 100644 (file)
@@ -13,7 +13,7 @@ Layout/ExtraSpacing:
 Layout/IndentHeredoc:
   EnforcedStyle: squiggly
 
-Style/FileName:
+Naming/FileName:
   Exclude:
     - 'cookbooks/trac/files/default/trac-authenticate'
     - 'cookbooks/planet/files/default/replication-bin/replicate-changesets'
index c6424b3edf750269201e9439cdc6584310ed5d53..76c3a84609b1cfce337f0d900a972f85f152a1cb 100644 (file)
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 #
 # Cookbook Name:: accounts
 # Recipe:: default
index e6d1c001518bc1cfa83d16e18461bbdc18d5077f..46df483cdcd06c9bb8bf6d2d60ec36614e7716d1 100644 (file)
@@ -129,7 +129,7 @@ directory extensions_directory do
   mode 0o755
 end
 
-node[:civicrm][:extensions].each do |_, details|
+node[:civicrm][:extensions].each_value do |details|
   git "#{extensions_directory}/#{details[:name]}" do
     action :sync
     repository details[:repository]
index 4710e5ef5494675d2c62c457af84453cc00443a9..41eae5a5b63c245888978d7fcbb9df6487c87ab9 100644 (file)
@@ -424,7 +424,7 @@ if disks.count.positive?
   # an Areca controller as they only allow one thing to
   # talk to the controller at a time and smartd will
   # throw errors if it clashes with munin
-  disks = disks.reject { |disk| disk[:smart] && disk[:smart].start_with?("areca,") }
+  disks = disks.reject { |disk| disk[:smart]&.start_with?("areca,") }
 
   disks.each do |disk|
     munin_plugin "smart_#{disk[:munin]}" do
index 4dcf0bd0b39390e5609bda2dd92b16c548a0f9e6..9b7599bed1b7cf36ee53bdc739da15102f1e4ffe 100644 (file)
@@ -1,5 +1,3 @@
-# coding: utf-8
-
 #
 # Cookbook Name:: imagery
 # Recipe:: gb_os_sv
index 9f17df934666bc32c1da4f5af5cafb192514c72c..cc9b7f0205d11732499bbc2ac79fc77f98dfc33f 100644 (file)
@@ -1,5 +1,3 @@
-# coding: utf-8
-
 #
 # Cookbook Name:: kibana
 # Recipe:: default
index 79c306635d319afacdbb47847ede2934b15b574d..ea95ed137d4f5133684613538ea13e3d7fcae0a5 100755 (executable)
@@ -62,7 +62,7 @@ else
     end
   end
 
-  CALL_TYPES.keys.each do |type|
+  CALL_TYPES.each_key do |type|
     count = counts[type] || 0
     puts "#{type}.value #{count}"
   end
index e2f74d9fff691727ac88c0d059ce6d2fc851efa8..e776505d23926ac80a3e5288500fe25f13b376bb 100755 (executable)
@@ -27,7 +27,7 @@ if ARGV[0] == "config"
 else
   statistics = JSON.parse(File.read("/srv/www.openstreetmap.org/rails/tmp/statistics.json"))
 
-  CALL_TYPES.keys.each do |type|
+  CALL_TYPES.each_key do |type|
     count = statistics["uri"][type.to_s] || 0
     puts "#{type}.value #{count}"
   end
index 0d7c9b645c2c07e008e1b23a0d60e2ed7a35cbf1..4a9623f9b877d33d9606f355e3afeb7bb541b512 100755 (executable)
@@ -40,7 +40,7 @@ if ARGV[0] == "config"
 else
   statistics = JSON.parse(File.read("/srv/www.openstreetmap.org/rails/tmp/statistics.json"))
 
-  HTTP_STATUSES.keys.each do |code|
+  HTTP_STATUSES.each_key do |code|
     count = statistics["status"][code] || 0
     puts "http#{code}.value #{count}"
   end
index f5bbd1104560d499fbc24599736fbbbf19b8a6b7..f575dad1c6df39a3b0e36df4ebe4e35822b6a3c7 100755 (executable)
@@ -63,7 +63,7 @@ else
     end
   end
 
-  CALL_TYPES.keys.each do |type|
+  CALL_TYPES.each_key do |type|
     count = counts[type] || [0]
     avg = count.inject(0) { |acc, elem| acc + elem } / (1.0 * count.length)
     puts "#{type}.value #{avg}"
index 7017c63e087131f715f04002f9a1789eb00cf723..dd0f663811f92de247bbdc72faf8f34bcc61920b 100755 (executable)
@@ -6,20 +6,20 @@
 require "English"
 
 def output_config
-  puts <<~END
+  puts <<~CONFIG
     graph_args --base 1024 -l 0 --vertical-label bytes --upper-limit 4056231936
     graph_category passenger
     graph_title Passenger memory
 
     memory.label memory
-  END
+  CONFIG
   exit 0
 end
 
 def output_values
   status = `/usr/sbin/passenger-memory-stats | tail -1`
   unless $CHILD_STATUS.success?
-    $stderr.puts "failed executing passenger-memory-stats"
+    warn "failed executing passenger-memory-stats"
     exit 1
   end
   status =~ /(\d+\.\d+)/
index b8a06cf3af9c3ce05aaeb9ab9b17721cb30ee017..0611ccc0e7ac4f54a5f2fa3e45b04bdf00a4fa64 100755 (executable)
@@ -3,7 +3,7 @@
 require "English"
 
 def output_config
-  puts <<~END
+  puts <<~CONFIG
     graph_category passenger
     graph_title Passenger processes
     graph_order active inactive
@@ -14,14 +14,14 @@ def output_config
     active.draw AREA
     inactive.label idle servers
     inactive.draw STACK
-  END
+  CONFIG
   exit 0
 end
 
 def output_values
   status = `/usr/sbin/passenger-status`
   unless $CHILD_STATUS.success?
-    $stderr.puts "failed executing passenger-status"
+    warn "failed executing passenger-status"
     exit 1
   end
   status =~ /active\s+=\s+(\d+)/
index 8d4159b463db107049ca604e37462502fb30c2e9..0850ed2735f1deec94546140fcb30f21395edb6a 100755 (executable)
@@ -3,20 +3,20 @@
 require "English"
 
 def output_config
-  puts <<~END
+  puts <<~CONFIG
     graph_category passenger
     graph_title Passenger queues
     graph_vlabel count
 
     global.label global
-  END
+  CONFIG
   exit 0
 end
 
 def output_values
   status = `/usr/sbin/passenger-status`
   unless $CHILD_STATUS.success?
-    $stderr.puts "failed executing passenger-status"
+    warn "failed executing passenger-status"
     exit 1
   end
   status =~ /Requests in top-level queue :\s+(\d+)/
index 3eeb776d6e0ecf83b2c542b1c9e38f106ae2c92f..dac457e33a8c543f41361cea24eff6368a376270 100755 (executable)
@@ -3,7 +3,7 @@
 require "English"
 
 def output_config
-  puts <<~END
+  puts <<~CONFIG
     graph_args --base 1000
     graph_category passenger
     graph_title Passenger requests
@@ -13,14 +13,14 @@ def output_config
     requests.type DERIVE
     requests.max 1000000
     requests.min 0
-  END
+  CONFIG
   exit 0
 end
 
 def output_values
   status = `/usr/sbin/passenger-status`
   unless $CHILD_STATUS.success?
-    $stderr.puts "failed executing passenger-status"
+    warn "failed executing passenger-status"
     exit 1
   end
   total_requests = 0
index dc692a780f03c37a7a6c47f3a1422de50d39fdc0..7c45022fd4fc2b36980d0aa4753893d8240158e5 100644 (file)
@@ -55,7 +55,7 @@ class Chef
 
     def query(sql, options = {})
       # Run the query
-      result = execute(options.merge(:command => sql, :xml => :true))
+      result = execute(options.merge(:command => sql, :xml => true))
 
       # Parse the output
       document = REXML::Document.new(result.stdout)
@@ -119,7 +119,7 @@ class Chef
     def canonicalise_user(user)
       local, host = user.split("@")
 
-      host = "%" unless host
+      host ||= "%"
 
       local = "'#{local}'" unless local =~ /^'.*'$/
       host = "'#{host}'" unless host =~ /^'.*'$/
index 3cf54291ff26eb4305eca4ee3d40b5d70f6fda6f..92103bb1f8f06709503d6aa71cb61ab97d9e1259 100755 (executable)
@@ -277,7 +277,7 @@ class Replicator
         move_tmp_files_into_place!
 
         fl.flock(File::LOCK_UN)
-      rescue
+      rescue StandardError
         STDERR.puts("Error! Couldn't update state.")
         fl.flock(File::LOCK_UN)
         raise
index 4b389a4be107f38ff72b342d82c497ac8f415133..79f96b5d2119356d537ac80c84508ae249090a21 100644 (file)
@@ -155,14 +155,14 @@ action :create do
     interpreter "php"
     cwd site_directory
     user "wordpress"
-    code <<-EOS
+    code <<-WP_FAIL2BAN
     <?php
     @include "wp-config.php";
     @include_once "wp-includes/functions.php";
     @include_once "wp-admin/includes/plugin.php";
     activate_plugin("wp-fail2ban/wp-fail2ban.php", '', false, false);
     ?>
-    EOS
+    WP_FAIL2BAN
     subscribes :run, "wordpress_plugin[wp-fail2ban]"
   end
 end
index 3d542df25c330af80ee49e8b2bffabae7dcbefad..b84b86c96ca6d91f046a5e84b423b2f604b8d16a 100644 (file)
@@ -1,5 +1,3 @@
-# coding: utf-8
-
 name "paulla"
 description "Role applied to all servers at PauLLA"
 
index 6bb0b45dad71f5c0a40554892a0dbfce53fd15fe..ea2dece10828260223a330d063bfedc0f3723829 100644 (file)
@@ -1,5 +1,3 @@
-# coding: utf-8
-
 name "teleservice"
 description "Role applied to all servers at Teleservice"