summaryrefslogtreecommitdiff
path: root/lib/chef/provider/group/dscl.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-06-11 15:02:42 -0700
committerTim Smith <tsmith84@gmail.com>2020-06-11 15:32:53 -0700
commit5825eea4b139b9af089c3075d042d5d3160583ec (patch)
treefd79641ded1857ee4166b6e9ba774a35ab47b06b /lib/chef/provider/group/dscl.rb
parent3889eddfc9944b23caea412d05c08b9b156cb50f (diff)
downloadchef-5825eea4b139b9af089c3075d042d5d3160583ec.tar.gz
Use .match? not =~ when match values aren't necessary
Autocorrected from RuboCop Performance which is now smart enough to detect when you use the match and when you don't. Using match? does not create any objects so it's slightly faster and uses less memory. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/provider/group/dscl.rb')
-rw-r--r--lib/chef/provider/group/dscl.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb
index b506197dca..824ebe0477 100644
--- a/lib/chef/provider/group/dscl.rb
+++ b/lib/chef/provider/group/dscl.rb
@@ -39,7 +39,7 @@ class Chef
result = dscl(*args)
return "" if ( args.first =~ /^delete/ ) && ( result[1].exitstatus != 0 )
raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") unless result[1].exitstatus == 0
- raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") if result[2] =~ /No such key: /
+ raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") if /No such key: /.match?(result[2])
result[2]
end
@@ -77,7 +77,7 @@ class Chef
gid = nil; next_gid_guess = 200
groups_gids = safe_dscl("list", "/Groups", "gid")
while next_gid_guess < search_limit + 200
- if groups_gids =~ Regexp.new("#{Regexp.escape(next_gid_guess.to_s)}\n")
+ if groups_gids&.match?(Regexp.new("#{Regexp.escape(next_gid_guess.to_s)}\n"))
next_gid_guess += 1
else
gid = next_gid_guess