diff options
author | Steve Kemp <steve@steve.org.uk> | 2017-08-10 10:17:51 +0300 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2017-08-10 10:17:51 +0300 |
commit | 63e2d2f2ec87d833408b7e8b6fb33e3f0fa0c804 (patch) | |
tree | 18cd4b93e09a5c56f3e47d0fd2693372e51634a7 /lib/custodian/util | |
parent | 005013d98d742989d3c000b04054e15bb0482a69 (diff) |
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.
Diffstat (limited to 'lib/custodian/util')
-rw-r--r-- | lib/custodian/util/ping.rb | 4 | ||||
-rw-r--r-- | lib/custodian/util/prefix.rb | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/custodian/util/ping.rb b/lib/custodian/util/ping.rb index 21836ac..f0aa15b 100644 --- a/lib/custodian/util/ping.rb +++ b/lib/custodian/util/ping.rb @@ -45,7 +45,7 @@ module Custodian # Does the hostname resolve to an IPv4 address? # def is_ipv4? - if (! @resolved.nil?) && (@resolved =~ /^([0-9]+).([0-9]+).([0-9]+).([0-9]+)$/) + if (!@resolved.nil?) && (@resolved =~ /^([0-9]+).([0-9]+).([0-9]+).([0-9]+)$/) true else false @@ -57,7 +57,7 @@ module Custodian # Does the hostname resolve to an IPv6 address? # def is_ipv6? - if (! @resolved.nil?) && (@resolved =~ /^([a-f0-9:]+)$/i) + if (!@resolved.nil?) && (@resolved =~ /^([a-f0-9:]+)$/i) true else false diff --git a/lib/custodian/util/prefix.rb b/lib/custodian/util/prefix.rb index 743a422..9ac027c 100644 --- a/lib/custodian/util/prefix.rb +++ b/lib/custodian/util/prefix.rb @@ -14,25 +14,25 @@ module Custodian # # Return the custom-prefix to use, if any. # - def Prefix.text() + def Prefix.text # Default to no prefix. - default = "" + default = '' # Look for matches - last one wins. - Dir.glob( "/store/clients/*/custodian-prefix.cfg" ).each do |file| + Dir.glob('/store/clients/*/custodian-prefix.cfg').each do |file| begin - default = File.read( file ) + default = File.read(file) rescue Errno::EACCES # Permission-denied. end end # Remove any newline characters - default.gsub!( /[\r\n]/, '' ) + default.gsub!(/[\r\n]/, '') # Truncate, if required. max = 32 - default = default[0...max] if ( default.length > max ) + default = default[0...max] if (default.length > max) default end |