summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook
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/cookbook
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/cookbook')
-rw-r--r--lib/chef/cookbook/chefignore.rb2
-rw-r--r--lib/chef/cookbook/metadata.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/cookbook/chefignore.rb b/lib/chef/cookbook/chefignore.rb
index 8f5b4516c4..41a0e44c54 100644
--- a/lib/chef/cookbook/chefignore.rb
+++ b/lib/chef/cookbook/chefignore.rb
@@ -50,7 +50,7 @@ class Chef
ignore_globs = []
if @ignore_file && readable_file_or_symlink?(@ignore_file)
File.foreach(@ignore_file) do |line|
- ignore_globs << line.strip unless line =~ COMMENTS_AND_WHITESPACE
+ ignore_globs << line.strip unless COMMENTS_AND_WHITESPACE.match?(line)
end
else
Chef::Log.debug("No chefignore file found. No files will be ignored!")
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index c1393abcab..7f6d972771 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -391,7 +391,7 @@ class Chef
def recipes_from_cookbook_version(cookbook)
cookbook.fully_qualified_recipe_names.map do |recipe_name|
unqualified_name =
- if recipe_name =~ /::default$/
+ if /::default$/.match?(recipe_name)
name.to_s
else
recipe_name