From: Tom Hughes Date: Fri, 6 Feb 2015 00:21:36 +0000 (+0000) Subject: Update rubocop and fix new warnings X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/f9a223297545b98090c533f10991d60334087fcb?ds=sidebyside Update rubocop and fix new warnings --- diff --git a/Gemfile.lock b/Gemfile.lock index 9f8087d56..84ec64fad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,12 +6,12 @@ GEM parser (>= 2.2.0.pre.3, < 3.0) parser (2.2.0.2) ast (>= 1.1, < 3.0) - powerpack (0.0.9) + powerpack (0.1.0) rainbow (2.0.0) - rubocop (0.28.0) + rubocop (0.29.0) astrolabe (~> 1.3) - parser (>= 2.2.0.pre.7, < 3.0) - powerpack (~> 0.0.6) + parser (>= 2.2.0.1, < 3.0) + powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.4) ruby-progressbar (1.7.1) diff --git a/cookbooks/munin/files/default/plugins/api_calls_ b/cookbooks/munin/files/default/plugins/api_calls_ index 58797b833..689f5120c 100755 --- a/cookbooks/munin/files/default/plugins/api_calls_ +++ b/cookbooks/munin/files/default/plugins/api_calls_ @@ -54,7 +54,7 @@ if ARGV[0] == 'config' else counts = uris_from_status(server) .collect { |x| categorise_uri(x) } - .each_with_object(Hash.new) do |h, e| + .each_with_object({}) do |h, e| if h.key? e h[e] += 1 else diff --git a/cookbooks/munin/files/default/plugins/api_calls_num b/cookbooks/munin/files/default/plugins/api_calls_num index b1d454228..1c3a28e05 100755 --- a/cookbooks/munin/files/default/plugins/api_calls_num +++ b/cookbooks/munin/files/default/plugins/api_calls_num @@ -64,7 +64,7 @@ else delta_t = (max_time - min_time).to_f * 24 * 60 counts = lines .collect { |x| categorise_uri(x) } - .each_with_object(Hash.new) do |h, e| + .each_with_object({}) do |h, e| if h.key? e h[e] += 1 else diff --git a/cookbooks/munin/files/default/plugins/api_waits_ b/cookbooks/munin/files/default/plugins/api_waits_ index 5eaa81a57..eb2a63686 100755 --- a/cookbooks/munin/files/default/plugins/api_waits_ +++ b/cookbooks/munin/files/default/plugins/api_waits_ @@ -54,7 +54,7 @@ if ARGV[0] == 'config' else counts = uri_and_times_from_status(server) .collect { |x, y| [categorise_uri(x), y] } - .each_with_object(Hash.new) do |h, e| + .each_with_object({}) do |h, e| category, time = e if h.key? category h[category] += [time] diff --git a/cookbooks/networking/recipes/default.rb b/cookbooks/networking/recipes/default.rb index 9eebca8c7..50fa35cfb 100644 --- a/cookbooks/networking/recipes/default.rb +++ b/cookbooks/networking/recipes/default.rb @@ -116,8 +116,8 @@ search(:node, "networking:interfaces").collect do |n| n.interfaces.each do |interface| next unless interface[:role] == "external" && interface[:zone] - zones[interface[:zone]] ||= Hash.new - zones[interface[:zone]][interface[:family]] ||= Array.new + zones[interface[:zone]] ||= {} + zones[interface[:zone]][interface[:family]] ||= [] zones[interface[:zone]][interface[:family]] << interface[:address] end end diff --git a/cookbooks/planet/files/default/replication-bin/replicate-changesets b/cookbooks/planet/files/default/replication-bin/replicate-changesets index b25f97aab..87acbcccb 100644 --- a/cookbooks/planet/files/default/replication-bin/replicate-changesets +++ b/cookbooks/planet/files/default/replication-bin/replicate-changesets @@ -120,7 +120,7 @@ class Replicator fl.flock(File::LOCK_EX) sequence = (@state.key?('sequence') ? @state['sequence'] + 1 : 0) - data_file = @config['data_dir'] + sprintf("/%03d/%03d/%03d.osm.gz", sequence / 1000000, (sequence / 1000) % 1000, (sequence % 1000)) + data_file = @config['data_dir'] + format("/%03d/%03d/%03d.osm.gz", sequence / 1000000, (sequence / 1000) % 1000, (sequence % 1000)) tmp_state = @config['state_file'] + ".tmp" tmp_data = "/tmp/changeset_data.osm.tmp" # try and write the files to tmp locations and then