From edf0e675123e4869e2739d1bab0ed57b3b9f664c Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 9 Mar 2015 13:09:46 +0000 Subject: Do not use parentheses for method calls with no arguments. This is neater. Flagged by rubocop --- bin/custodian-dequeue | 6 +++--- bin/custodian-enqueue | 8 ++++---- bin/custodian-queue | 6 +++--- bin/multi-ping | 2 +- lib/custodian/alerts/file.rb | 2 +- lib/custodian/alerts/graphite.rb | 4 ++-- lib/custodian/alerts/mauve.rb | 8 ++++---- lib/custodian/alerts/redis-state.rb | 2 +- lib/custodian/alerts/smtp.rb | 4 ++-- lib/custodian/parser.rb | 2 +- lib/custodian/protocoltest/dns.rb | 12 ++++++------ lib/custodian/protocoltest/http.rb | 4 ++-- lib/custodian/protocoltest/mx.rb | 4 ++-- lib/custodian/protocoltest/openproxy.rb | 6 +++--- lib/custodian/protocoltest/ping.rb | 4 ++-- lib/custodian/protocoltest/smtprelay.rb | 2 +- lib/custodian/protocoltest/tcp.rb | 10 +++++----- lib/custodian/queue.rb | 2 +- lib/custodian/settings.rb | 18 +++++++++--------- lib/custodian/util/dns.rb | 8 ++++---- lib/custodian/worker.rb | 18 +++++++++--------- t/test-custodian-parser.rb | 32 ++++++++++++++++---------------- t/test-custodian-settings.rb | 12 ++++++------ t/test-custodian-testfactory.rb | 24 ++++++++++++------------ t/test-custodian-util-timespan.rb | 4 ++-- 25 files changed, 102 insertions(+), 102 deletions(-) diff --git a/bin/custodian-dequeue b/bin/custodian-dequeue index c5c5309..a411746 100755 --- a/bin/custodian-dequeue +++ b/bin/custodian-dequeue @@ -65,7 +65,7 @@ if __FILE__ == $PROGRAM_NAME then # # The settings object contains a lot of configuration-data. # - settings = Custodian::Settings.instance() + settings = Custodian::Settings.instance begin opts = GetoptLong.new( @@ -137,7 +137,7 @@ if __FILE__ == $PROGRAM_NAME then # Single step? # if ( ENV['SINGLE'] ) - worker.process_single_job() + worker.process_single_job exit(0) end @@ -145,7 +145,7 @@ if __FILE__ == $PROGRAM_NAME then # Run until we see a failure? # if ( ENV['FAIL'] ) - worker.process_until_fail() + worker.process_until_fail exit(0) end diff --git a/bin/custodian-enqueue b/bin/custodian-enqueue index dec83cb..568c0d6 100755 --- a/bin/custodian-enqueue +++ b/bin/custodian-enqueue @@ -129,10 +129,10 @@ if __FILE__ == $PROGRAM_NAME then # # Connected to the queue - be it redis or beanstalkd # - settings = Custodian::Settings.instance() - queue = Custodian::QueueType.create( settings.queue_type() ) + settings = Custodian::Settings.instance + queue = Custodian::QueueType.create( settings.queue_type ) if ( ! queue ) - puts "Failed to connect to the #{settings.queue_type()} queue" + puts "Failed to connect to the #{settings.queue_type} queue" exit 1 end @@ -140,7 +140,7 @@ if __FILE__ == $PROGRAM_NAME then # # Create the parser object. # - mon = Custodian::Parser.new() + mon = Custodian::Parser.new # diff --git a/bin/custodian-queue b/bin/custodian-queue index 48c6edc..9dec58a 100755 --- a/bin/custodian-queue +++ b/bin/custodian-queue @@ -124,8 +124,8 @@ if __FILE__ == $PROGRAM_NAME then # # Create the queue object. # - settings = Custodian::Settings.instance() - queue = Custodian::QueueType.create( settings.queue_type() ) + settings = Custodian::Settings.instance + queue = Custodian::QueueType.create( settings.queue_type ) # # Alerting on a queue that is too-full? @@ -149,7 +149,7 @@ if __FILE__ == $PROGRAM_NAME then # Showing stats? # if ( $STATS ) - jobs = queue.size?() + jobs = queue.size? puts "There are #{jobs || 0} jobs pending." exit( 0 ) end diff --git a/bin/multi-ping b/bin/multi-ping index 00ae466..9833215 100755 --- a/bin/multi-ping +++ b/bin/multi-ping @@ -121,7 +121,7 @@ helper = Custodian::Util::Ping.new( hostname ) # # Ping the host, via the helper # -if ( helper.run_ping() ) +if ( helper.run_ping ) puts "#{hostname} - #{helper.address} - is alive." exit 0 else diff --git a/lib/custodian/alerts/file.rb b/lib/custodian/alerts/file.rb index cc2a672..5874136 100644 --- a/lib/custodian/alerts/file.rb +++ b/lib/custodian/alerts/file.rb @@ -31,7 +31,7 @@ module Custodian # Record a raise event for the given test. # def raise - write_message( "RAISE: #{test.target} failed #{test.get_type}-test - #{test.error()}" ) + write_message( "RAISE: #{test.target} failed #{test.get_type}-test - #{test.error}" ) end diff --git a/lib/custodian/alerts/graphite.rb b/lib/custodian/alerts/graphite.rb index 34ec73c..2e49125 100644 --- a/lib/custodian/alerts/graphite.rb +++ b/lib/custodian/alerts/graphite.rb @@ -63,9 +63,9 @@ module Custodian # # Send via UDP. # - socket = UDPSocket.new() + socket = UDPSocket.new socket.send( payload, 0, @target, 2003 ); - socket.close() + socket.close end diff --git a/lib/custodian/alerts/mauve.rb b/lib/custodian/alerts/mauve.rb index 8ce14c1..dfa4a04 100644 --- a/lib/custodian/alerts/mauve.rb +++ b/lib/custodian/alerts/mauve.rb @@ -69,7 +69,7 @@ module Custodian # update = Mauve::Proto::AlertUpdate.new update.alert = [] - update.source = @settings.alert_source() + update.source = @settings.alert_source update.replace = false # @@ -151,7 +151,7 @@ module Custodian # update = Mauve::Proto::AlertUpdate.new update.alert = [] - update.source = @settings.alert_source() + update.source = @settings.alert_source update.replace = false # @@ -241,7 +241,7 @@ module Custodian # # The text from the job-defition # - user_text = test.get_notification_text() + user_text = test.get_notification_text # # Add the user-detail if present @@ -251,7 +251,7 @@ module Custodian # # Add the test-failure message # - alert.detail = "#{alert.detail}

#{test.error()}

" + alert.detail = "#{alert.detail}

#{test.error}

" # # Determine if this is inside/outside the bytemark network diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb index 7d9daa7..f37cef2 100644 --- a/lib/custodian/alerts/redis-state.rb +++ b/lib/custodian/alerts/redis-state.rb @@ -59,7 +59,7 @@ module Custodian tmp["type"] = @test.get_type tmp["target"] = @test.target tmp["result"] = "RAISE" - tmp["reason"] = @test.error() + tmp["reason"] = @test.error tmp["test" ] = @test.to_s tmp["class" ] = @test.class diff --git a/lib/custodian/alerts/smtp.rb b/lib/custodian/alerts/smtp.rb index 4de6fbe..d37701b 100644 --- a/lib/custodian/alerts/smtp.rb +++ b/lib/custodian/alerts/smtp.rb @@ -30,8 +30,8 @@ module Custodian # Raise an alert by email. # def raise - subject = "#{test.target} alert #{test.get_type}-test - #{test.error()}" - body = "The alert has raised, with the following details:\n#{test.error()}\nRegards\n"; + subject = "#{test.target} alert #{test.get_type}-test - #{test.error}" + body = "The alert has raised, with the following details:\n#{test.error}\nRegards\n"; _send_mail( @target, subject, body ) end diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb index 0bafd47..bce507b 100644 --- a/lib/custodian/parser.rb +++ b/lib/custodian/parser.rb @@ -139,7 +139,7 @@ module Custodian text = getURL(uri) text.split( /[\r\n]/ ).each do |line| - val.push( line ) if ( line.length() > 0) + val.push( line ) if ( line.length > 0) end elsif ( line =~ /\s(is|are)\s+(.*)\.+$/ ) diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb index 05c8534..5787881 100644 --- a/lib/custodian/protocoltest/dns.rb +++ b/lib/custodian/protocoltest/dns.rb @@ -100,8 +100,8 @@ module Custodian # # Get the timeout period. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout # # Do the lookup @@ -147,16 +147,16 @@ module Custodian case ltype when /^A$/ then - dns.getresources(name, Resolv::DNS::Resource::IN::A).map{ |r| results.push( r.address.to_s() ) } + dns.getresources(name, Resolv::DNS::Resource::IN::A).map{ |r| results.push( r.address.to_s ) } when /^AAAA$/ then - dns.getresources(name, Resolv::DNS::Resource::IN::AAAA).map{ |r| results.push( r.address.to_s() ) } + dns.getresources(name, Resolv::DNS::Resource::IN::AAAA).map{ |r| results.push( r.address.to_s ) } when /^NS$/ then - dns.getresources(name, Resolv::DNS::Resource::IN::NS).map{ |r| results.push( Resolv.getaddresses( r.name.to_s() ) ) } + dns.getresources(name, Resolv::DNS::Resource::IN::NS).map{ |r| results.push( Resolv.getaddresses( r.name.to_s ) ) } when /^MX$/ then - dns.getresources(name, Resolv::DNS::Resource::IN::MX).map{ |r| results.push( Resolv.getaddresses( r.exchange.to_s() ) ) } + dns.getresources(name, Resolv::DNS::Resource::IN::MX).map{ |r| results.push( Resolv.getaddresses( r.exchange.to_s ) ) } else @error = "Unknown record type to resolve: '#{ltype}'" diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb index 0bbe290..a36b349 100644 --- a/lib/custodian/protocoltest/http.rb +++ b/lib/custodian/protocoltest/http.rb @@ -209,8 +209,8 @@ module Custodian # # Get the timeout period for this test. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout # # The URL we'll fetch/poll. diff --git a/lib/custodian/protocoltest/mx.rb b/lib/custodian/protocoltest/mx.rb index 29a9183..2372556 100644 --- a/lib/custodian/protocoltest/mx.rb +++ b/lib/custodian/protocoltest/mx.rb @@ -57,8 +57,8 @@ module Custodian # # Get the timeout period. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout # # The MX-hosts diff --git a/lib/custodian/protocoltest/openproxy.rb b/lib/custodian/protocoltest/openproxy.rb index 5313343..851982c 100644 --- a/lib/custodian/protocoltest/openproxy.rb +++ b/lib/custodian/protocoltest/openproxy.rb @@ -80,13 +80,13 @@ module Custodian # # Get the timeout period for this test. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout begin timeout( period ) do begin - c = Curl::Easy.new() + c = Curl::Easy.new c.follow_location = true c.max_redirects = 10 c.ssl_verify_host = false diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb index ff406d5..423b925 100644 --- a/lib/custodian/protocoltest/ping.rb +++ b/lib/custodian/protocoltest/ping.rb @@ -94,8 +94,8 @@ module Custodian # # Get the timeout period. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout diff --git a/lib/custodian/protocoltest/smtprelay.rb b/lib/custodian/protocoltest/smtprelay.rb index a1c0b33..45abf16 100644 --- a/lib/custodian/protocoltest/smtprelay.rb +++ b/lib/custodian/protocoltest/smtprelay.rb @@ -86,7 +86,7 @@ module Custodian begin - Net::SMTP.start(@host,@port, get_hostname() ) do |smtp| + Net::SMTP.start(@host,@port, get_hostname ) do |smtp| sent = smtp.send_message message, "noreply@bytemark.co.uk", "noreply@bytemark.co.uk" @status = sent.status.to_s diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb index 9ca2180..24a05be 100644 --- a/lib/custodian/protocoltest/tcp.rb +++ b/lib/custodian/protocoltest/tcp.rb @@ -153,8 +153,8 @@ module Custodian # # Get the timeout period. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout # # Perform the DNS lookups of the specified name. @@ -265,8 +265,8 @@ module Custodian # # Get the timeout period for this test. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout begin timeout(period) do @@ -283,7 +283,7 @@ module Custodian read.gsub!(/[\n\r]/, "") end - socket.close() + socket.close if ( banner.nil? ) @error = nil diff --git a/lib/custodian/queue.rb b/lib/custodian/queue.rb index 6e252e9..671e44e 100644 --- a/lib/custodian/queue.rb +++ b/lib/custodian/queue.rb @@ -182,7 +182,7 @@ end # Get the size of the queue # def size? - stats = @queue.stats() + stats = @queue.stats ( stats['current-jobs-ready'] || 0 ) end diff --git a/lib/custodian/settings.rb b/lib/custodian/settings.rb index 8bcf71c..e0d2d27 100644 --- a/lib/custodian/settings.rb +++ b/lib/custodian/settings.rb @@ -84,7 +84,7 @@ module Custodian # Retrieve an arbitrary key # def key( name ) - _load() unless( _loaded? ) + _load unless( _loaded? ) @settings[name] end @@ -93,7 +93,7 @@ module Custodian # The timeout period for each individual test. # def timeout - _load() unless( _loaded? ) + _load unless( _loaded? ) if ( @settings['timeout'] ) @settings['timeout'].to_i @@ -109,7 +109,7 @@ module Custodian # before raising an alert. # def retries - _load() unless( _loaded? ) + _load unless( _loaded? ) if ( @settings['retries'] ) @settings['retries'].to_i @@ -129,7 +129,7 @@ module Custodian # A delay of zero is permissable. # def retry_delay - _load() unless( _loaded? ) + _load unless( _loaded? ) if ( @settings['retry_delay'] ) @settings['retry_delay'].to_i @@ -146,7 +146,7 @@ module Custodian # environmental variable 'QUEUE_ADDRESS'. # def queue_type - _load() unless( _loaded? ) + _load unless( _loaded? ) @settings['queue_type'] || "redis" end @@ -157,7 +157,7 @@ module Custodian # The filename for the logfile. # def log_file - _load() unless( _loaded? ) + _load unless( _loaded? ) @settings['log_file'] || "custodian-dequeue.log" end @@ -167,7 +167,7 @@ module Custodian # The alerter to use # def alerter - _load() unless( _loaded? ) + _load unless( _loaded? ) @settings['alerter'] || "file" end @@ -177,7 +177,7 @@ module Custodian # The alert-source we send. Only used when the notifier is set to mauve. # def alert_source - _load() unless( _loaded? ) + _load unless( _loaded? ) @settings['alert_source'] || "Custodian" end @@ -195,7 +195,7 @@ module Custodian # When the alerter is "redis" the target is the redis-server address. # def alerter_target( alert ) - _load() unless( _loaded? ) + _load unless( _loaded? ) # diff --git a/lib/custodian/util/dns.rb b/lib/custodian/util/dns.rb index 82a7e68..9cbbf59 100644 --- a/lib/custodian/util/dns.rb +++ b/lib/custodian/util/dns.rb @@ -26,8 +26,8 @@ module Custodian # # Get the timeout period. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout begin timeout( period ) do @@ -54,8 +54,8 @@ module Custodian # # Get the timeout period. # - settings = Custodian::Settings.instance() - period = settings.timeout() + settings = Custodian::Settings.instance + period = settings.timeout begin timeout( period ) do diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb index b411c00..fd1abce 100644 --- a/lib/custodian/worker.rb +++ b/lib/custodian/worker.rb @@ -73,16 +73,16 @@ module Custodian @settings = settings # Connect to the queue - @queue = QueueType.create( @settings.queue_type() ) + @queue = QueueType.create( @settings.queue_type ) # Get the alerter-type(s) to instantiate @alerter = @settings.alerter # How many times to repeat a failing test - @retry_count=@settings.retries() + @retry_count=@settings.retries # Should we sleep between repeated tests? - @retry_delay = @settings.retry_delay() + @retry_delay = @settings.retry_delay end @@ -105,7 +105,7 @@ module Custodian def run! while( true ) log_message( "Waiting for job.." ) - process_single_job() + process_single_job end end @@ -170,7 +170,7 @@ module Custodian # Run the test - inverting the result if we should # result = test.run_test - result = ! result if ( test.inverted() ) + result = ! result if ( test.inverted ) if ( result ) log_message( "Test succeeed - clearing alert" ) @@ -223,7 +223,7 @@ module Custodian # # Raise the alert, passing the error message. # - log_message( "Test failed - alerting with #{test.error()}" ) + log_message( "Test failed - alerting with #{test.error}" ) do_raise( test ) end @@ -252,7 +252,7 @@ module Custodian # give the alerter a reference to the settings object. alert.set_settings( @settings ) - alert.raise() + alert.raise end end @@ -272,7 +272,7 @@ module Custodian # give the alerter a reference to the settings object. alert.set_settings( @settings ) - alert.clear() + alert.clear end end @@ -300,7 +300,7 @@ module Custodian # Process jobs until we see a failure, then stop. # def process_until_fail - while( process_single_job() ) + while( process_single_job ) # nop end end diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb index 5822ecd..43a0754 100755 --- a/t/test-custodian-parser.rb +++ b/t/test-custodian-parser.rb @@ -44,13 +44,13 @@ class TestCustodianParser < Test::Unit::TestCase # Constructor # assert_nothing_raised do - Custodian::Parser.new() + Custodian::Parser.new end end def test_period - parser = Custodian::Parser.new() + parser = Custodian::Parser.new result = parser.parse_line( "example.vm.bytemark.co.uk must run ping except between 00-23" ) assert( result.nil? ) end @@ -69,7 +69,7 @@ class TestCustodianParser < Test::Unit::TestCase # # 1. By string. # - parser = Custodian::Parser.new() + parser = Custodian::Parser.new # 1.a. Comment lines return nil. result = parser.parse_line( "# this is a comment" ) @@ -91,7 +91,7 @@ class TestCustodianParser < Test::Unit::TestCase # # 2. By array. # - parser = Custodian::Parser.new() + parser = Custodian::Parser.new # 2.a. Comment lines return nil. tmp = [] tmp.push( "# This is a comment.." ) @@ -107,7 +107,7 @@ class TestCustodianParser < Test::Unit::TestCase # # 3. By lines # - parser = Custodian::Parser.new() + parser = Custodian::Parser.new # 3.a. Comment lines return nil. str =< #{inv}" ) + assert( obj[0].inverted == inv, "#{str} -> #{inv}" ) end end @@ -247,7 +247,7 @@ class TestTestFactory < Test::Unit::TestCase # Get all the types we know about. # def test_types - registered = Custodian::TestFactory.known_tests() + registered = Custodian::TestFactory.known_tests # for each test-type registered.keys.each do |type| @@ -270,10 +270,10 @@ class TestTestFactory < Test::Unit::TestCase assert_nothing_raised do test_one_obj = Custodian::TestFactory.create( test_one ) - assert( !test_one_obj[0].inverted() ) + assert( !test_one_obj[0].inverted ) test_two_obj = Custodian::TestFactory.create( test_two ) - assert( test_two_obj[0].inverted(), "Found inverted test for #{tst}" ) + assert( test_two_obj[0].inverted, "Found inverted test for #{tst}" ) assert_equal( tst, test_one_obj[0].get_type ) assert_equal( tst, test_two_obj[0].get_type ) @@ -306,7 +306,7 @@ class TestTestFactory < Test::Unit::TestCase assert(obj) assert( obj.kind_of? Array ) assert( ! obj.empty? ) - assert_equal( "test.host.example.com", obj[0].target() ) + assert_equal( "test.host.example.com", obj[0].target ) end end end diff --git a/t/test-custodian-util-timespan.rb b/t/test-custodian-util-timespan.rb index ef05fe7..29e9b83 100755 --- a/t/test-custodian-util-timespan.rb +++ b/t/test-custodian-util-timespan.rb @@ -215,14 +215,14 @@ class TestTimeSpanUtil < Test::Unit::TestCase def test_wrap_around for h in 00..23 - assert_equal( 1, Custodian::Util::TimeSpan.to_hours( h,h ).size() ) + assert_equal( 1, Custodian::Util::TimeSpan.to_hours( h,h ).size ) end # # But the time-period 00-23 is a full day # assert_equal( 24, - Custodian::Util::TimeSpan.to_hours( 0,23 ).size() ) + Custodian::Util::TimeSpan.to_hours( 0,23 ).size ) end -- cgit v1.2.1