]> git.openstreetmap.org Git - chef.git/commitdiff
Fix some issues identified by rubocop
authorTom Hughes <tom@compton.nu>
Mon, 2 Feb 2015 22:25:07 +0000 (22:25 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 2 Feb 2015 22:28:20 +0000 (22:28 +0000)
29 files changed:
cookbooks/accounts/recipes/default.rb
cookbooks/apache/providers/conf.rb
cookbooks/apache/providers/module.rb
cookbooks/apache/providers/site.rb
cookbooks/chef/libraries/edit_file.rb
cookbooks/civicrm/recipes/default.rb
cookbooks/dev/recipes/default.rb
cookbooks/exim/recipes/default.rb
cookbooks/hardware/attributes/default.rb
cookbooks/hardware/recipes/default.rb
cookbooks/incron/recipes/default.rb
cookbooks/mediawiki/definitions/mediawiki_extension.rb
cookbooks/mediawiki/definitions/mediawiki_site.rb
cookbooks/munin/providers/plugin.rb
cookbooks/munin/recipes/default.rb
cookbooks/mysql/providers/database.rb
cookbooks/networking/libraries/interfaces.rb
cookbooks/nfs/recipes/default.rb
cookbooks/nominatim/recipes/default.rb
cookbooks/openvpn/recipes/default.rb
cookbooks/osqa/recipes/default.rb
cookbooks/otrs/recipes/default.rb
cookbooks/postgresql/providers/table.rb
cookbooks/sysctl/recipes/default.rb
cookbooks/sysfs/recipes/default.rb
cookbooks/tile/files/default/ruby/expire.rb
cookbooks/tile/recipes/default.rb
cookbooks/trac/recipes/default.rb
cookbooks/web/recipes/rails.rb

index 50e3d375a6d95a2724d8f7347b68efb06ea759f3..9627d1d081ae9872b71168383bebdcc8a8196ad7 100644 (file)
@@ -30,9 +30,8 @@ search(:accounts, "*:*").each do |account|
 
   if details[:status]
     group_members = details[:members] || account["members"] || []
-    user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name.to_s}"
+    user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name}"
     manage_home = details[:manage_home] || account["manage_home"] || node[:accounts][:manage_home]
-    groups = details[:groups] || account["groups"] || []
 
     group_members = group_members.collect { |m| m.to_s }.sort
 
index d249079d961144cc0e9cc067f4caa1b065afc5a8..806a7076adf37636d1080fc2a5159cb3631674f3 100644 (file)
@@ -108,5 +108,5 @@ def enabled_name
 end
 
 def enabled?
-  ::File.exists?(enabled_name)
+  ::File.exist?(enabled_name)
 end
index 17008371ec844d55698c49fcd2364f87432db2f6..166aa4a4739adfced8ea204d0c4936ffc739d85c 100644 (file)
@@ -60,7 +60,7 @@ action :enable do
       owner "root"
       group "root"
       notifies :reload, "service[apache2]"
-      only_if { ::File.exists?(available_name("conf")) }
+      only_if { ::File.exist?(available_name("conf")) }
     end
 
     new_resource.updated_by_last_action(true)
@@ -106,9 +106,9 @@ def enabled_name(extension)
 end
 
 def installed?
-  ::File.exists?(available_name("load"))
+  ::File.exist?(available_name("load"))
 end
 
 def enabled?
-  ::File.exists?(enabled_name("load"))
+  ::File.exist?(enabled_name("load"))
 end
index 86fecbfcf73376718984ac6c34a7d4395fe3c749..9c33032514f64ac553c0d00144d19ac4c73b07de 100644 (file)
@@ -94,5 +94,5 @@ def enabled_name
 end
 
 def enabled?
-  ::File.exists?(enabled_name)
+  ::File.exist?(enabled_name)
 end
index ea200c845cc74567c55606ed4fdf264e1b04e24d..a3c892d719f4332c696813364dc7ac85ecdac343 100644 (file)
@@ -3,7 +3,7 @@ class Chef
     def edit_file(file, &block)
       Chef::DelayedEvaluator.new do
         ::File.new(file).collect do |line|
-          line = block.call(line)
+          block.call(line)
         end.join("")
       end
     end
index 382cb53b442b78b35a464054871a1e4e0e8da2ad..6c2d5ecbeff97050b4eff04d2560f166c4fa3b67 100644 (file)
@@ -27,7 +27,6 @@ package "wkhtmltopdf"
 passwords = data_bag_item("civicrm", "passwords")
 
 database_password = passwords["database"]
-admin_password = passwords["admin"]
 site_key = passwords["key"]
 
 mysql_user "civicrm@localhost" do
index d660718e6ca35910dd94e0a58e2feae0576b8d98..1290e11f9bc31eeb1e7f8eaf238b0a74fe20c6f9 100644 (file)
@@ -106,7 +106,7 @@ search(:accounts, "*:*").each do |account|
   port = 7000 + account["uid"].to_i
 
   if ["user","administrator"].include?(details[:status])
-    user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name.to_s}"
+    user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name}"
 
     if File.directory?("#{user_home}/public_html")
       template "/etc/php5/fpm/pool.d/#{name}.conf" do
@@ -220,7 +220,7 @@ if node[:postgresql][:clusters][:"9.1/main"]
     template "apache.apis.erb"
   end
 
-  node[:postgresql][:clusters].each do |name,details|
+  node[:postgresql][:clusters].each_key do |name|
     postgresql_munin name do
       cluster name
       database "ALL"
index af0070bd94dfc67c2a2c33a9d467ead5f06fa234..b53da4e039492a151c3be1f982f724e5032b0d4e 100644 (file)
@@ -38,8 +38,8 @@ template "/tmp/exim.ssl.cnf" do
   owner "root"
   group "root"
   mode 0644
-   not_if do
-    File.exists?("/etc/ssl/certs/exim.pem") and File.exists?("/etc/ssl/private/exim.key")
+  not_if do
+    File.exist?("/etc/ssl/certs/exim.pem") and File.exist?("/etc/ssl/private/exim.key")
   end 
 end
 
@@ -48,7 +48,7 @@ execute "/etc/ssl/certs/exim.pem" do
   user "root"
   group "ssl-cert"
   not_if do
-    File.exists?("/etc/ssl/certs/exim.pem") and File.exists?("/etc/ssl/private/exim.key")
+    File.exist?("/etc/ssl/certs/exim.pem") and File.exist?("/etc/ssl/private/exim.key")
   end
 end
 
index 46b5893a8746398535b02ab02c4cc7184465e59e..2a4e8e2724eef198c7d9b45df0c651b372ea72ae 100644 (file)
@@ -33,7 +33,7 @@ if node[:kernel][:modules].include?("ipmi_si")
   default[:hardware][:modules] |= [ "ipmi_devintf" ]
 end
 
-if File.exists?("/proc/xen")
+if File.exist?("/proc/xen")
   default[:hardware][:watchdog] = "xen_wdt"
 elsif node[:kernel][:modules].include?("i6300esb")
   default[:hardware][:watchdog] = "none"
index a508fff6b55e7e3be4770a48f3469bb7e8a8de58..441dbd1e3ad8104ac9d6c7e319d4e01e2e8066b3 100644 (file)
@@ -253,7 +253,7 @@ end
   end
 end
 
-if File.exists?("/etc/mdadm/mdadm.conf")
+if File.exist?("/etc/mdadm/mdadm.conf")
   mdadm_conf = edit_file "/etc/mdadm/mdadm.conf" do |line|
     line.gsub!(/^MAILADDR .*$/, "MAILADDR admins@openstreetmap.org")
 
index d4a17617935a5294df64dfdab51a91f8040e38e0..29ba1e80781c9672c41f0e3c0d4458bfec350ab9 100644 (file)
@@ -26,7 +26,7 @@ end
 
 incrontabs = {}
 
-node[:incron].each do |name,details|
+node[:incron].each_value do |details|
   user = details[:user]
   path = details[:path]
   mask = details[:events].join(",")
index 37c93e41d3ca383379f3b339017a49e158197a99..134bc4497c92061360bcd9e9dd2ba5c9d0002c2d 100644 (file)
@@ -20,7 +20,6 @@
 define :mediawiki_extension, :action => [ :enable ], :variables => {} do
   name = params[:name]
   site = params[:site]
-  site_directory = node[:mediawiki][:sites][site][:site_directory]
   mediawiki_directory = node[:mediawiki][:sites][site][:directory]
   extension_directory = "#{mediawiki_directory}/extensions/#{name}"
   source = params[:source]
index f8f03c18efe85089314ab0e704b3d37ac56ef73a..8b746701074cc155b0b626d23ba026af407d3fef 100644 (file)
@@ -93,7 +93,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do
     user node[:mediawiki][:user]
     group node[:mediawiki][:group]
     not_if do
-      File.exists?("#{mediawiki[:directory]}/LocalSettings-install.php")
+      File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php")
     end
     notifies :create, 'ruby_block[rename-installer-localsettings]', :immediately
   end
@@ -135,7 +135,7 @@ define :mediawiki_site, :action => [ :create, :enable ] do
       #
     end
     not_if do
-      File.exists?("#{mediawiki[:directory]}/LocalSettings-install.php")
+      File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php")
     end
     notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/install.php"), :immediately
     action :create
index 4361514fb0400400e7d370845ed1132b5e0c5d6b..c058524b91a4a9303a6bdbc4971cf51b23a44d0e 100644 (file)
@@ -73,11 +73,11 @@ end
 
 def target_path
   case
-  when ::File.exists?(target)
+  when ::File.exist?(target)
     target
-  when ::File.exists?("/usr/local/share/munin/plugins/#{target}")
+  when ::File.exist?("/usr/local/share/munin/plugins/#{target}")
     "/usr/local/share/munin/plugins/#{target}"
-  when ::File.exists?("/usr/share/munin/plugins/#{target}")
+  when ::File.exist?("/usr/share/munin/plugins/#{target}")
     "/usr/share/munin/plugins/#{target}"
   else
     nil
index ac6c4d843558183e7bfba4de5fcd914a09ffbad2..e48c7806db5d962f2f9617b0107a68b13edfc3d2 100644 (file)
@@ -90,7 +90,7 @@ end
 # apcpdu_
 munin_plugin "cpu"
 
-if File.exists?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
+if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
   munin_plugin "cpuspeed"
 else
   munin_plugin "cpuspeed" do
@@ -127,7 +127,7 @@ else
   end
 end
 
-disks = node[:block_device].select do |name,attributes|
+disks = node[:block_device].select do |_,attributes|
   [ "ATA", "FUJITSU", "SEAGATE", "DELL", "COMPAQ", "IBM-ESXS" ].include?(attributes[:vendor])
 end
 
@@ -142,7 +142,7 @@ else
   end
 end
 
-if File.exists?("/sbin/hpasmcli")
+if File.exist?("/sbin/hpasmcli")
   munin_plugin "hpasmcli2_temp" do
     target "hpasmcli2_"
   end
@@ -277,7 +277,7 @@ sensors_temp = false
 sensors_volt = false
 
 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
-  hwmon = "#{hwmon}/device" unless File.exists?("#{hwmon}/name")
+  hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
 
   sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
   sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
index 29b38f70e4c4988b97f4ff9aaeb079ee7574e5fb..556e40454673f27c1a6ebf8c2cf4c394198094ac 100644 (file)
@@ -40,7 +40,7 @@ action :create do
     [@mysql.canonicalise_user(user), privileges]
   end]
 
-  @current_resource.permissions.each do |user,privileges|
+  @current_resource.permissions.each_key do |user|
     unless new_permissions[user]
       converge_by("revoke all for #{user} on #{new_resource}") do
         Chef::Log.info("Revoking all for #{user} on #{new_resource}")
index cc9c11a232a33b4795bb2bf252e33dfe48f8f0ea..67b2bd2373176e2fd69ab93697170d2de6025f77 100644 (file)
@@ -6,7 +6,7 @@ class Chef
       networking = construct_attributes[:networking] || {}
       networking_interfaces = networking[:interfaces] || []
 
-      networking_interfaces.each do |name,interface|
+      networking_interfaces.each_value  do |interface|
         if options[:role].nil? or interface[:role].to_s == options[:role].to_s
           if options[:family].nil? or interface[:family].to_s == options[:family].to_s
             if block.nil?
index 0b4c9ffe4ca05530599d48379f779ad66990e646..1719a967cb94cefcf9dd8a6e675c16b3f26f5a87 100644 (file)
@@ -31,7 +31,7 @@ node[:nfs].each do |mountpoint,details|
     group "root"
     mode 0755
     recursive true
-    not_if { File.exists?(mountpoint) }
+    not_if { File.exist?(mountpoint) }
   end
 
   mount mountpoint do
index bb5ff5c946e586929628e95a7b43b578869b9e99..682352a6d9601e651e68520872ab1daae2c1f6bb 100644 (file)
@@ -137,7 +137,7 @@ package "libboost-thread-dev"
 
 execute "php-pear-db" do
   command "pear install DB"
-  not_if { File.exists?("/usr/share/php/DB") }
+  not_if { File.exist?("/usr/share/php/DB") }
 end
 
 execute "compile_nominatim" do
index fbf6af9b6109e031b1e8ad6b7e4a89a0df80dce7..a1a52f13e455c42204f1a6720eddec6cb0f4449a 100644 (file)
@@ -46,7 +46,7 @@ node[:openvpn][:tunnels].each do |name,details|
       creates "/etc/openvpn/#{name}.key"
     end
 
-    if File.exists?("/etc/openvpn/#{name}.key")
+    if File.exist?("/etc/openvpn/#{name}.key")
       node.set[:openvpn][:keys][name] = IO.read("/etc/openvpn/#{name}.key")
     end
   elsif peer and peer[:openvpn]
index de65ad99b7248e379dcab3f173f3d68bf60cc957..e283f37952b63d5b9077c9953d60ac30362ec037 100644 (file)
@@ -40,7 +40,6 @@ apache_module "wsgi"
 node[:osqa][:sites].each do |site|
   name = site[:name]
   directory = site[:directory] || "/srv/#{name}"
-  osqa_revision = site[:revision] || node[:osqa][:revision]
   site_user = site[:user] || node[:osqa][:user]
   site_user = Etc.getpwuid(site_user).name if site_user.is_a?(Integer)
   site_group = site[:group] || node[:osqa][:group] || Etc.getpwnam(site_user).gid
index 5f74ae9f602ef8d14a7c6a669b2d66184e4d7557..a3ebf21f431d2c0351b6c7229305b0d7fcf8632c 100644 (file)
@@ -41,7 +41,6 @@ apache_module "headers"
 
 version = node[:otrs][:version]
 user = node[:otrs][:user]
-group = node[:otrs][:group]
 database_cluster = node[:otrs][:database_cluster]
 database_name = node[:otrs][:database_name]
 database_user = node[:otrs][:database_user]
index 4a2b43f5dd3dd885b161fcf16acde33792d23685..bcd39a959e92cb13433e2dc5175f96306dde9d7c 100644 (file)
@@ -42,7 +42,7 @@ action :create do
       end
     end
 
-    @current_resource.permissions.each do |user,privileges|
+    @current_resource.permissions.each_key do |user|
       unless new_resource.permissions[user]
         converge_by("revoke all for #{user} on #{new_resource}") do
           Chef::Log.info("Revoking all for #{user} on #{new_resource}")
index d2797a289af5db4943627630739dece3b7bf5aa9..920402a6ebb0450ad5909811140c7f30288c3d34 100644 (file)
@@ -47,7 +47,7 @@ node[:sysctl].each_value do |group|
     file sysctl_file do
       content "#{value}\n"
       atomic_update false
-      only_if { File.exists?(sysctl_file) }
+      only_if { File.exist?(sysctl_file) }
     end
   end
 end
index f0290d4e7b166930a025269d22139bf964580929..a3de9b40dbb9f5e76570e9757f184d2250079cfd 100644 (file)
@@ -39,7 +39,7 @@ node[:sysfs].each_value do |group|
     file sysfs_file do
       content "#{value}\n"
       atomic_update false
-      only_if { File.exists?(sysfs_file) }
+      only_if { File.exist?(sysfs_file) }
     end
   end
 end
index 8fb0033cd1cbd883d837947cc9ff49c2949e9709..4e5cba2db1a6a7636d91ae0c04c219c145a216f0 100755 (executable)
@@ -93,7 +93,7 @@ module Expire
     end
   end
 
-  def Expire.do_expire(change_file, min_zoom, max_zoom, &block)
+  def Expire.do_expire(change_file, min_zoom, max_zoom, &_)
     # read in the osm change file
     doc = XML::Document.file(change_file)
     
@@ -142,7 +142,7 @@ module Expire
     set = Set.new nodes.values
     
     # expire tiles and shrink to the set of parents
-    (max_zoom).downto(min_zoom) do |z|
+    (max_zoom).downto(min_zoom) do |_|
       # allow the block to work on the set, returning the set at the next
       # zoom level
       set = yield set
index 6cb1b9acbd21620ee2f96a0f6092094856aceb96..bf5431d068d3269e2d1b3b14a4aa5f9f588addc2 100644 (file)
@@ -145,7 +145,7 @@ directory "/srv/tile.openstreetmap.org/data" do
   mode 0755
 end
 
-node[:tile][:data].each do |name,data|
+node[:tile][:data].each_value do |data|
   url = data[:url]
   file = "/srv/tile.openstreetmap.org/data/#{File.basename(url)}"
   directory = "/srv/tile.openstreetmap.org/data/#{data[:directory]}"
@@ -513,7 +513,7 @@ template "/usr/local/bin/cleanup-tiles" do
   mode 0755
 end
 
-tile_directories = node[:tile][:styles].collect do |name,style|
+tile_directories = node[:tile][:styles].collect do |_,style|
   style[:tile_directories].collect { |directory| directory[:name] }
 end.flatten.sort.uniq
 
index 42cff06493bf8a8734a576e7ba15b68ede8a387d..d61feab0e9fa13eca03286917636bea8200db62b 100644 (file)
@@ -60,7 +60,7 @@ execute "trac-deploy-#{site_name}" do
   command "trac-admin /var/lib/trac deploy #{site_directory}"
   user "root"
   group "root"
-  not_if { File.exists?(site_directory) }
+  not_if { File.exist?(site_directory) }
 end
 
 cookbook_file "/usr/local/bin/trac-authenticate" do
index 1a8ef4122989c1861ba6cddc61e52b6142c65255..dd4260900c99c1cfe5319f1c845ec6a6b537f1c6 100644 (file)
@@ -37,7 +37,7 @@ end
 
 rails_directory = "#{node[:web][:base_directory]}/rails"
 
-piwik_configuration = data_bag_item("web", "piwik").to_hash.reject do |k,v|
+piwik_configuration = data_bag_item("web", "piwik").to_hash.reject do |k,_|
   ["chef_type", "data_bag", "id"].include?(k)
 end