From fea454753efc4a673751131960c394254555d34a Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 9 Mar 2015 13:10:32 +0000 Subject: Don't use parenthesis aroudn conditions in an if. --- lib/custodian/protocoltest/ping.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/custodian/protocoltest/ping.rb') diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb index 423b925..90e4241 100644 --- a/lib/custodian/protocoltest/ping.rb +++ b/lib/custodian/protocoltest/ping.rb @@ -41,7 +41,7 @@ module Custodian # # Is this test inverted? # - if ( line =~ /must\s+not\s+run\s+/ ) + if line =~ /must\s+not\s+run\s+/ @inverted = true else @inverted = false @@ -71,9 +71,9 @@ module Custodian # binary = nil binary = "./bin/multi-ping" - binary = "/usr/bin/multi-ping" if ( File.exist?( "/usr/bin/multi-ping" ) ) + binary = "/usr/bin/multi-ping" if File.exist?( "/usr/bin/multi-ping" ) - if ( binary.nil? ) + if binary.nil? @error = "Failed to find '/usr/bin/multi-ping'" return false end @@ -85,7 +85,7 @@ module Custodian # # $(/tmp/exploit.sh) must run ping .. # - if ( @host !~ /^([a-zA-Z0-9:\-\.]+)$/ ) + if @host !~ /^([a-zA-Z0-9:\-\.]+)$/ @error = "Invalid hostname for ping-test: #{@host}" return false end @@ -109,7 +109,7 @@ module Custodian # begin x = IPAddr.new( @host ) - if ( x.ipv4? or x.ipv6? ) + if x.ipv4? or x.ipv6? ips.push( @host ) end rescue ArgumentError @@ -125,10 +125,10 @@ module Custodian # # Allow the test to disable one/both # - if ( @line =~ /ipv4_only/ ) + if @line =~ /ipv4_only/ do_ipv6 = false end - if ( @line =~ /ipv6_only/ ) + if @line =~ /ipv6_only/ do_ipv4 = false end @@ -140,11 +140,11 @@ module Custodian timeout( period ) do Resolv::DNS.open do |dns| - if ( do_ipv4 ) + if do_ipv4 ress = dns.getresources(@host, Resolv::DNS::Resource::IN::A) ress.map { |r| ips.push( r.address.to_s ) } end - if ( do_ipv6 ) + if do_ipv6 ress = dns.getresources(@host, Resolv::DNS::Resource::IN::AAAA) ress.map { |r| ips.push( r.address.to_s ) } end @@ -159,7 +159,7 @@ module Custodian # # Did we fail to perform a DNS lookup? # - if ( ips.empty? ) + if ips.empty? @error = "#{@host} failed to resolve to either IPv4 or IPv6" return false end -- cgit v1.2.1