summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2016-04-22 21:48:59 +0300
committerSteve Kemp <steve@steve.org.uk>2016-04-22 21:48:59 +0300
commit67fbf68705e1808107e8cea1d3ab6ad0e206f645 (patch)
treee9488cc105876485822be15c29c97ee66bd964ca
parent12de7cf1aefcd5d567a9e6e2eaa061f2074c8dbb (diff)
Fixed up more rubocop warnings.
Again these were whitespace-related.
-rw-r--r--.rubocop.yml12
-rw-r--r--lib/custodian/util/bytemark.rb2
-rw-r--r--lib/custodian/util/dns.rb2
-rw-r--r--lib/custodian/util/ping.rb10
-rw-r--r--lib/custodian/util/tftp.rb10
-rw-r--r--lib/custodian/util/timespan.rb12
6 files changed, 23 insertions, 25 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 8fcb264..46850c9 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -66,7 +66,7 @@ Metrics/AbcSize:
# Offense count: 8
# Configuration parameters: CountComments.
Metrics/ClassLength:
- Max: 202
+ Max: 300
# Offense count: 22
Metrics/CyclomaticComplexity:
@@ -75,7 +75,7 @@ Metrics/CyclomaticComplexity:
# Offense count: 118
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
- Max: 216
+ Max: 300
# Offense count: 78
# Configuration parameters: CountComments.
@@ -302,14 +302,12 @@ Style/PredicateName:
Style/RedundantBegin:
Enabled: false
+Style/RedundantReturn:
+ Enabled: false
+
Style/RegexpLiteral:
Enabled: false
-# Offense count: 20
-# Cop supports --auto-correct.
-# Configuration parameters: AllowMultipleReturnValues.
-Style/RedundantReturn:
- Enabled: true
# Offense count: 50
# Cop supports --auto-correct.
diff --git a/lib/custodian/util/bytemark.rb b/lib/custodian/util/bytemark.rb
index 6e944de..c72b457 100644
--- a/lib/custodian/util/bytemark.rb
+++ b/lib/custodian/util/bytemark.rb
@@ -29,7 +29,7 @@ module Custodian
def self.inside?(target)
inside = false
- if BYTEMARK_RANGES.any? { |range| range.include?(IPAddr.new(target)) }
+ if BYTEMARK_RANGES.any? { |range| range.include?(IPAddr.new(target)) }
inside = true
end
diff --git a/lib/custodian/util/dns.rb b/lib/custodian/util/dns.rb
index 724b3c2..dbb7158 100644
--- a/lib/custodian/util/dns.rb
+++ b/lib/custodian/util/dns.rb
@@ -61,7 +61,7 @@ module Custodian
timeout(period) do
begin
Socket.getaddrinfo(hostname, 'echo').each do |a|
- resolved = a[3] if a
+ resolved = a[3] if a
end
rescue SocketError
resolved = nil
diff --git a/lib/custodian/util/ping.rb b/lib/custodian/util/ping.rb
index d563722..21836ac 100644
--- a/lib/custodian/util/ping.rb
+++ b/lib/custodian/util/ping.rb
@@ -26,8 +26,8 @@ module Custodian
#
def initialize(hostname)
- raise ArgumentError, 'Hostname must not be nil' if hostname.nil?
- raise ArgumentError, 'Hostname must be a String' unless hostname.kind_of?(String)
+ raise ArgumentError, 'Hostname must not be nil' if hostname.nil?
+ raise ArgumentError, 'Hostname must be a String' unless hostname.kind_of?(String)
@hostname = hostname
@resolved = Custodian::Util::DNS.hostname_to_ip(hostname)
@@ -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
@@ -72,7 +72,7 @@ module Custodian
# Return false on error.
#
def run_ping
- if is_ipv6?
+ if is_ipv6?
if (system("ping6 -c 1 #{@resolved} 2>/dev/null >/dev/null") == true)
return true
end
diff --git a/lib/custodian/util/tftp.rb b/lib/custodian/util/tftp.rb
index c012a82..0c9d119 100644
--- a/lib/custodian/util/tftp.rb
+++ b/lib/custodian/util/tftp.rb
@@ -12,14 +12,14 @@ module Custodian
#
# Store hostname and port
#
- def initialize(hostname, port=69)
+ def initialize(hostname, port = 69)
- raise ArgumentError, 'Hostname must not be nil' if hostname.nil?
- raise ArgumentError, 'Hostname must be a String' unless hostname.kind_of?(String)
+ raise ArgumentError, 'Hostname must not be nil' if hostname.nil?
+ raise ArgumentError, 'Hostname must be a String' unless hostname.kind_of?(String)
raise ArgumentError, 'Port must be a number' unless port.to_i > 0
@hostname = hostname
- @port = port.to_i
+ @port = port.to_i
end
#
@@ -35,7 +35,7 @@ module Custodian
FileUtils.rm_f(target)
end
- def fetch(file, target=nil)
+ def fetch(file, target = nil)
# HPA's tftp client appears to have a 25s timeout that it is
# not possible to change on the command line.
return tftp("-m binary #{@hostname} #{@port} -c get #{file} #{target}")
diff --git a/lib/custodian/util/timespan.rb b/lib/custodian/util/timespan.rb
index 7de76b3..8364d02 100644
--- a/lib/custodian/util/timespan.rb
+++ b/lib/custodian/util/timespan.rb
@@ -17,7 +17,7 @@ module Custodian
#
# Handle PM times.
#
- if (desc.kind_of? String) &&
+ if (desc.kind_of? String) &&
(desc =~ /([0-9]+)pm$/i)
desc = $1.dup.to_i + 12
end
@@ -25,7 +25,7 @@ module Custodian
#
# Handle AM times.
#
- if desc.kind_of? String
+ if desc.kind_of? String
desc = desc.sub(/am$/, '')
desc = desc.to_i
end
@@ -33,8 +33,8 @@ module Custodian
#
# Ensure within a valid range
#
- raise ArgumentError, 'Integer required for time' unless desc.kind_of? Integer
- raise ArgumentError, "Invalid time: #{desc}" unless (desc >= 0) && (desc <= 23)
+ raise ArgumentError, 'Integer required for time' unless desc.kind_of? Integer
+ raise ArgumentError, "Invalid time: #{desc}" unless (desc >= 0) && (desc <= 23)
#
@@ -70,7 +70,7 @@ module Custodian
while (hour != p_end)
valid[hour] = 1
hour += 1
- hour = 0 if hour > 23
+ hour = 0 if hour > 23
end
valid[p_end] = 1
@@ -92,7 +92,7 @@ module Custodian
#
# Default to the current hour, if not specified.
#
- if cur_hour.nil?
+ if cur_hour.nil?
cur_hour = Time.now.hour
end