Skip to content

Commit faac29f

Browse files
committed
fix lint 2.0
1 parent 1a397b7 commit faac29f

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

resources/libraries/update_hosts_file.rb

+5-10
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,15 @@ def update_hosts_file
5656
hosts_entries
5757
end
5858

59-
def managerToIp(str)
59+
def manager_to_ip(str)
6060
ipv4_regex = /\A(\d{1,3}\.){3}\d{1,3}\z/
6161
ipv6_regex = /\A(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}\z/
62-
dns_regex = /\A[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+\z/
62+
dns_regex = /\A[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+\z/
6363

64-
return str if str =~ ipv4_regex || str =~ ipv6_regex
64+
return str if str.match?(ipv4_regex) || str.match?(ipv6_regex)
65+
return Resolv.getaddress(str).to_s if str.match?(dns_regex)
6566

66-
if str =~ dns_regex
67-
begin
68-
Resolv.getaddress(str).to_s
69-
rescue Resolv::ResolvError
70-
return
71-
end
72-
end
67+
nil
7368
end
7469
end
7570
end

0 commit comments

Comments
 (0)