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 0798540..9d9ce40 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 c6424b3..76c3a84 100644 (file)
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 #
 # Cookbook Name:: accounts
 # Recipe:: default
index e6d1c00..46df483 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 4710e5e..41eae5a 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 4dcf0bd..9b7599b 100644 (file)
@@ -1,5 +1,3 @@
-# coding: utf-8
-
 #
 # Cookbook Name:: imagery
 # Recipe:: gb_os_sv
index 9f17df9..cc9b7f0 100644 (file)
@@ -1,5 +1,3 @@
-# coding: utf-8
-
 #
 # Cookbook Name:: kibana
 # Recipe:: default
index 79c3066..ea95ed1 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 e2f74d9..e776505 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 0d7c9b6..4a9623f 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 f5bbd11..f575dad 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 7017c63..dd0f663 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 b8a06cf..0611ccc 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 8d4159b..0850ed2 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 3eeb776..dac457e 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 dc692a7..7c45022 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 3cf5429..92103bb 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 4b389a4..79f96b5 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 3d542df..b84b86c 100644 (file)
@@ -1,5 +1,3 @@
-# coding: utf-8
-
 name "paulla"
 description "Role applied to all servers at PauLLA"
 
index 6bb0b45..ea2dece 100644 (file)
@@ -1,5 +1,3 @@
-# coding: utf-8
-
 name "teleservice"
 description "Role applied to all servers at Teleservice"