From 24cb7c539e852ca13c535cdf0d9624b5d5f770da Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 27 Oct 2020 12:10:24 -0700 Subject: Simplify a weird conditional in chef-config if with ! is a brain twister. Signed-off-by: Tim Smith --- chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb b/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb index ab51966077..05188d44aa 100644 --- a/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb +++ b/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb @@ -21,7 +21,7 @@ module ChefConfig module FuzzyHostnameMatcher def fuzzy_hostname_match_any?(hostname, matches) - if (!hostname.nil?) && (!matches.nil?) + unless hostname.nil? || matches.nil? return matches.to_s.split(/\s*,\s*/).compact.any? do |m| fuzzy_hostname_match?(hostname, m) end -- cgit v1.2.1 From 5b54538e22189fea3ba05539fde67a60638194d0 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 28 Oct 2020 09:47:30 -0700 Subject: Remove .nil? and add some yard explaining what this method is Signed-off-by: Tim Smith --- chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb b/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb index 05188d44aa..533db85860 100644 --- a/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb +++ b/chef-config/lib/chef-config/mixin/fuzzy_hostname_matcher.rb @@ -20,8 +20,16 @@ module ChefConfig module Mixin module FuzzyHostnameMatcher + # + # Check to see if a hostname matches a match string. Used to see if hosts fall under our no_proxy config + # + # @param [String] hostname the hostname to check + # @param [String] matches the pattern to match + # + # @return [Boolean] + # def fuzzy_hostname_match_any?(hostname, matches) - unless hostname.nil? || matches.nil? + if hostname && matches return matches.to_s.split(/\s*,\s*/).compact.any? do |m| fuzzy_hostname_match?(hostname, m) end -- cgit v1.2.1