summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_version.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/cookbook_version.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/cookbook_version.rb')
-rw-r--r--lib/chef/cookbook_version.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 2e9bb77151..62407aa314 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -392,7 +392,7 @@ class Chef
platform, version = Chef::Platform.find_platform_and_version(node)
rescue ArgumentError => e
# Skip platform/version if they were not found by find_platform_and_version
- if e.message =~ /Cannot find a (?:platform|version)/
+ if /Cannot find a (?:platform|version)/.match?(e.message)
platform = "/unknown_platform/"
version = "/unknown_platform_version/"
else
@@ -527,7 +527,7 @@ class Chef
cb["version"]
end
rescue Net::HTTPClientException => e
- if e.to_s =~ /^404/
+ if /^404/.match?(e.to_s)
Chef::Log.error("Cannot find a cookbook named #{cookbook_name}")
nil
else