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. --- lib/custodian/protocoltest/ssl.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/custodian/protocoltest/ssl.rb') diff --git a/lib/custodian/protocoltest/ssl.rb b/lib/custodian/protocoltest/ssl.rb index 82754c6..6bc1a04 100644 --- a/lib/custodian/protocoltest/ssl.rb +++ b/lib/custodian/protocoltest/ssl.rb @@ -162,25 +162,25 @@ class SSLCheck # is valid. # def certificate_fallback - cert = "" + cert = '' in_cert = false # Run the command. out = `echo "" | openssl s_client -servername #{uri.host} -connect #{uri.host}:#{uri.port} 2>/dev/null` # For each line of the output - out.split( /[\r\n]/ ).each do |line| + out.split(/[\r\n]/).each do |line| # Are we in a certificate? - in_cert = true if ( line =~ /BEGIN CERT/ ) + in_cert = true if (line =~ /BEGIN CERT/) # If so append the line. - if ( in_cert ) + if (in_cert) cert += line cert += "\n" end # Are we at the end? - in_cert = false if ( line =~ /END CERT/ ) + in_cert = false if (line =~ /END CERT/) end # Return the certificate @@ -248,10 +248,10 @@ class SSLCheck if self.certificate.nil? # Use our fallback method. - fallback = certificate_fallback() + fallback = certificate_fallback # If we failed to fetch it then we cannot do anything useful. - if ( fallback.nil? ) + if (fallback.nil?) self.errors << verbose("Failed to fetch certificate for #{self.domain}") return nil else @@ -373,9 +373,9 @@ class SSLCheck # signature is valid, because we're missing the bundle that # the remote server should have sent us. # - if ( @fallback ) + if (@fallback) verbose "Skipping certificate signature validation for #{self.domain} because fallback SSL-certificate had to be used and we think we'll fail" - return true; + return true end unless self.tests.include?(:signature) @@ -514,7 +514,7 @@ module Custodian return Custodian::TestResult::TEST_SKIPPED end - s = SSLCheck.new(@host,@expiry_days) + s = SSLCheck.new(@host, @expiry_days) result = s.verify if true == result @@ -522,7 +522,7 @@ module Custodian return Custodian::TestResult::TEST_PASSED elsif result.nil? puts("SSL Verification returned no result #{@host}") - @error = "SSL Verification for #{@host} failed - TLS negotiation failure?\n"; + @error = "SSL Verification for #{@host} failed - TLS negotiation failure?\n" @error += s.errors.join("\n") return Custodian::TestResult::TEST_FAILED else -- cgit v1.2.3