Skip to content

Commit

Permalink
Linter for regex match?
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Powell <thomas.powell@progress.com>
  • Loading branch information
tpowell-progress committed Oct 4, 2023
1 parent 8ec28c0 commit ffa04af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ohai/mixin/network_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def hex_to_dec_netmask(netmask)
# Addrinfo#ip*? methods return true on AI_CANONNAME Addrinfo records that match
# the ipv* scheme and #ip? always returns true unless a non tcp Addrinfo
def ip?(hostname)
!!(canonname =~ Resolv::IPv4::Regex) || !!(canonname =~ Resolv::IPv6::Regex)
Resolv::IPv4::Regex.match?(hostname) || Resolv::IPv6::Regex.match?(hostname)
end

# This does a forward and reverse lookup on the hostname to return what should be
Expand All @@ -65,7 +65,7 @@ def canonicalize_hostname(hostname)
# However, we have found that Windows hosts that are not joined to a domain
# can return a non-qualified hostname).
# Use a '.' in the canonname as indicator of FQDN
return canonname if canonname =~ /\./
return canonname if /\./.match?(canonname)

Check failure on line 68 in lib/ohai/mixin/network_helper.rb

View workflow job for this annotation

GitHub Actions / chefstyle

[Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern.

# If we got a non-qualified name, then we do a standard reverse resolve
# which, assuming DNS is working, will work around that windows bug
Expand Down

0 comments on commit ffa04af

Please sign in to comment.