From 63e2d2f2ec87d833408b7e8b6fb33e3f0fa0c804 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 10 Aug 2017 10:17:51 +0300 Subject: Significant rubocop fixups. This merge-request contains almost entirely mechanical changes, with a few exceptions: * I changed `do_ipv4` and `do_ipv6` to `ipv4` and `ipv6` respectively. * This fixed a warning about normal-casing. * I changed a test-case to compare against both `Integer` and `Fixnum` * Suspect this is a ruby-versionism. The tests continue to pass, so I believe this is safe to merge, but of course it is still not 100%: lib/custodian/queue.rb:135:21: W: Assignment in condition - you probably meant to use ==. added = true ^ lib/custodian/protocoltest/ssl.rb:218:5: W: Do not shadow rescued Exceptions rescue OpenSSL::SSL::SSLError => err ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/custodian/protocoltest/ssl.rb:286:5: W: Do not shadow rescued Exceptions rescue OpenSSL::SSL::SSLError => err ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/custodian/protocoltest/http.rb:307:7: C: Assignment Branch Condition size for run_test is too high. [84.53/72] def run_test ^^^ lib/custodian/protocoltest/http.rb:307:7: C: Cyclomatic complexity for run_test is too high. [22/19] def run_test ^^^ lib/custodian/protocoltest/http.rb:307:7: C: Method has too many lines. [97/87] def run_test ... ^^^^^^^^^^^^ lib/custodian/protocoltest/http.rb:307:7: C: Perceived complexity for run_test is too high. [23/21] def run_test In short this takes care of _most_ of the warnings, but updates requiring significant code-change have not been applied. --- t/test-custodian-parser.rb | 22 +++++++++++----------- t/test-custodian-settings.rb | 13 +++++++------ t/test-custodian-util-ping.rb | 2 +- t/test-custodian-util-timespan.rb | 2 +- t/test-rubocop.rb | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) (limited to 't') diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb index 2239503..62a39dc 100755 --- a/t/test-custodian-parser.rb +++ b/t/test-custodian-parser.rb @@ -438,15 +438,15 @@ EOF # test data # data = { - 'http://bob:steve@example must run http.' => - { username: 'bob', password: 'steve'}, + 'http://bob:steve@example must run http.' => + { :username => 'bob', :password => 'steve' }, 'http://stee\':steve@example must run http.' => - { username: 'stee\'', password: 'steve'}, + { :username => 'stee\'', :password => 'steve' }, 'http://e\'e:pa$$w0rd@example must run http.' => - { username: 'e\'e', password: 'pa$$w0rd'}, + { :username => 'e\'e', :password => 'pa$$w0rd' } } - data.each do |str, hash | + data.each do |str, hash| assert_nothing_raised do # @@ -461,8 +461,8 @@ EOF # There should be auth-enabled assert(obj[0].basic_auth?) - assert(obj[0].basic_auth_username == hash[:username] ) - assert(obj[0].basic_auth_password == hash[:password] ) + assert(obj[0].basic_auth_username == hash[:username]) + assert(obj[0].basic_auth_password == hash[:password]) end end @@ -488,7 +488,7 @@ EOF # # Test the parser with this text # - expiries.each do |str,days| + expiries.each do |str, days| assert_nothing_raised do # @@ -505,13 +505,13 @@ EOF # Test both of them to make sure we got our expiry period. obj.each do |x| - if ( x.class.name =~ /SSL/ ) - found_days = x.expiry_days + if (x.class.name =~ /SSL/) + found_days = x.expiry_days end end # Ensure we did find a match. - assert(found_days != -1 ) + assert(found_days != -1) assert(found_days == days) end diff --git a/t/test-custodian-settings.rb b/t/test-custodian-settings.rb index 74f881b..1630859 100755 --- a/t/test-custodian-settings.rb +++ b/t/test-custodian-settings.rb @@ -47,36 +47,37 @@ class TestConfigurationSingleton < Test::Unit::TestCase # retry delay - probably unset. a = settings.retry_delay - assert(a.class == Fixnum) + assert(a.class == Integer || + a.class == Fixnum) # store a number settings._store('retry_delay', 5) a = settings.retry_delay - assert(a.class == Fixnum) + assert(a.class == Integer || a.class == Fixnum ) assert(a == 5) # store a string settings._store('retry_delay', '35') a = settings.retry_delay - assert(a.class == Fixnum) + assert(a.class == Integer || a.class == Fixnum ) assert(a == 35) # timeout - probably unset. a = settings.timeout - assert(a.class == Fixnum) + assert(a.class == Integer || a.class == Fixnum ) # store a number settings._store('timeout', 5) a = settings.timeout - assert(a.class == Fixnum) + assert(a.class == Integer || a.class == Fixnum ) assert(a == 5) # store a string settings._store('timeout', '35') a = settings.timeout - assert(a.class == Fixnum) + assert(a.class == Integer || a.class == Fixnum ) assert(a == 35) diff --git a/t/test-custodian-util-ping.rb b/t/test-custodian-util-ping.rb index 99b61c1..d7d16b8 100755 --- a/t/test-custodian-util-ping.rb +++ b/t/test-custodian-util-ping.rb @@ -63,7 +63,7 @@ class TestPingUtil < Test::Unit::TestCase # Test lookup of hosts that don't work # def test_lookup_fail - %w( tessf.dfsdf.sdf.sdfsdf fdsfkljflj3.fdsfds.f3.dfs ).each do |name| + %w(tessf.dfsdf.sdf.sdfsdf fdsfkljflj3.fdsfds.f3.dfs).each do |name| assert_nothing_raised do helper = Custodian::Util::Ping.new(name) diff --git a/t/test-custodian-util-timespan.rb b/t/test-custodian-util-timespan.rb index fec079f..5098589 100755 --- a/t/test-custodian-util-timespan.rb +++ b/t/test-custodian-util-timespan.rb @@ -214,7 +214,7 @@ class TestTimeSpanUtil < Test::Unit::TestCase # def test_wrap_around - for h in 00..23 + for h in 0o0..23 assert_equal(1, Custodian::Util::TimeSpan.to_hours(h, h).size) end diff --git a/t/test-rubocop.rb b/t/test-rubocop.rb index 57457b7..cb597e8 100755 --- a/t/test-rubocop.rb +++ b/t/test-rubocop.rb @@ -20,7 +20,7 @@ class TestRubocop < Test::Unit::TestCase cli = RuboCop::CLI.new result = cli.run - assert(result == 0, 'No errors found') + assert(result.zero?, 'No errors found') rescue LoadError => ex if methods.include?(:skip) -- cgit v1.2.1