From 85a9a63eb5d8690fd7945bba901b10ef8c3326c9 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Fri, 22 Apr 2016 21:54:18 +0300 Subject: More rubocop fixes. --- lib/custodian/alerts/graphite.rb | 2 +- lib/custodian/alerts/mauve.rb | 14 +++++++------- lib/custodian/alerts/redis-state.rb | 30 +++++++++++++++--------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/custodian/alerts/graphite.rb b/lib/custodian/alerts/graphite.rb index 9d69c28..0244047 100644 --- a/lib/custodian/alerts/graphite.rb +++ b/lib/custodian/alerts/graphite.rb @@ -23,7 +23,7 @@ module Custodian # Constructor - save the test-object away. # def initialize(obj) - @test = obj + @test = obj end diff --git a/lib/custodian/alerts/mauve.rb b/lib/custodian/alerts/mauve.rb index 5a00557..be19eec 100644 --- a/lib/custodian/alerts/mauve.rb +++ b/lib/custodian/alerts/mauve.rb @@ -213,7 +213,7 @@ module Custodian test_host = test.target test_type = test.get_type - alert = Mauve::Proto::Alert.new + alert = Mauve::Proto::Alert.new # # Mauve only lets us use IDs which are <= 255 characters in length @@ -234,9 +234,9 @@ module Custodian # # If we're raising then add the error # - if failure + if failure - alert.detail = "

The #{test_type} test failed against #{test_host}.

" + alert.detail = "

The #{test_type} test failed against #{test_host}.

" # # The text from the job-defition @@ -246,7 +246,7 @@ module Custodian # # Add the user-detail if present # - alert.detail = "#{alert.detail}

#{user_text}

" if !user_text.nil? + alert.detail = "#{alert.detail}

#{user_text}

" if !user_text.nil? # # Add the test-failure message @@ -257,7 +257,7 @@ module Custodian # Determine if this is inside/outside the bytemark network # location = expand_inside_bytemark(test_host) - if !location.nil? && location.length + if !location.nil? && location.length alert.detail = "#{alert.detail}\n#{location}" end end @@ -282,7 +282,7 @@ module Custodian # We'll also make the host a link that can be clicked in the alert we raise. # target = host - if target =~ /^([a-z]+):\/\/([^\/]+)/ + if target =~ /^([a-z]+):\/\/([^\/]+)/ target = $2.dup host = "#{host}" end @@ -339,7 +339,7 @@ module Custodian # Return the formatted message # ips.each do |ipaddr| - if Custodian::Util::Bytemark.inside?(ipaddr.to_s) + if Custodian::Util::Bytemark.inside?(ipaddr.to_s) result += "

#{host} resolves to #{ipaddr} which is inside the Bytemark network.

" else result += "

#{host} resolves to #{ipaddr} which is OUTSIDE the Bytemark network.

" diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb index 793bb73..2008fee 100644 --- a/lib/custodian/alerts/redis-state.rb +++ b/lib/custodian/alerts/redis-state.rb @@ -71,7 +71,7 @@ module Custodian puts 'ERROR Loading redis rubygem!' end - @test = obj + @test = obj end @@ -88,7 +88,7 @@ module Custodian # test_s = @test.to_s - @redis.sadd( "known_tests", test_s ) + @redis.sadd('known_tests', test_s) # # Get the current state of this test - so that if the state @@ -101,16 +101,16 @@ module Custodian # # The current state # - current = @redis.get( "#{key}.current" ) || "unknown" - @redis.set( "#{key}.current", "FAIL" ) + current = @redis.get("#{key}.current") || 'unknown' + @redis.set("#{key}.current", 'FAIL') - count = @redis.get( "#{key}.count" ) || "0" - @redis.set( "#{key}.count", (count.to_i + 1)) + count = @redis.get("#{key}.count") || '0' + @redis.set("#{key}.count", (count.to_i + 1)) # # Bump the execution count for this test. # - if ( current != "FAIL" ) + if (current != 'FAIL') # # The state has changed to raise. @@ -120,7 +120,7 @@ module Custodian tmp['result'] = 'FAIL' tmp['reason'] = @test.error - @redis.lpush( "#{key}.history", tmp.to_json) + @redis.lpush("#{key}.history", tmp.to_json) @redis.ltrim('#{key}.history', 0, 8192) end @@ -140,7 +140,7 @@ module Custodian # test_s = @test.to_s - @redis.sadd( "known_tests", test_s ) + @redis.sadd('known_tests', test_s) # # Get the current state of this test - so that if the state @@ -153,13 +153,13 @@ module Custodian # # The current state # - current = @redis.get( "#{key}.current" ) || "unknown" - @redis.set( "#{key}.current", "OK" ) + current = @redis.get("#{key}.current") || 'unknown' + @redis.set("#{key}.current", 'OK') - count = @redis.get( "#{key}.count" ) || "0" - @redis.set( "#{key}.count", (count.to_i + 1 )) + count = @redis.get("#{key}.count") || '0' + @redis.set("#{key}.count", (count.to_i + 1)) - if ( current != "OK" ) + if (current != 'OK') # # The state has changed to raise. @@ -169,7 +169,7 @@ module Custodian tmp['result'] = 'OK' tmp['reason'] = @test.error - @redis.lpush( "#{key}.history", tmp.to_json) + @redis.lpush("#{key}.history", tmp.to_json) @redis.ltrim('#{key}.history', 0, 100) end end -- cgit v1.2.1