diff options
author | Tim Smith <tsmith84@gmail.com> | 2021-12-26 18:50:43 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2021-12-26 18:50:43 -0800 |
commit | f84a238a1d8d0060d5064eee0b74ed942088d4fd (patch) | |
tree | d26039e8502c84a0c2e2c947227bab5f02139c81 /lib/chef/cookbook_version.rb | |
parent | 50a0001bae754c66feb69c84b64cb305a03a34d2 (diff) | |
download | chef-Performance_RegexpMatch.tar.gz |
Resolve Performance/RegexpMatch warningsPerformance_RegexpMatch
Do regex checks without creating objects for the results.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/cookbook_version.rb')
-rw-r--r-- | lib/chef/cookbook_version.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index 6e4f13c291..8a616e5e07 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -598,7 +598,7 @@ class Chef filename = record[:name] base_dup_name = File.join(File.dirname(filename), File.basename(filename, File.extname(filename))) yml_files.each do |other| - if other[:name] =~ /#{(File.extname(filename) == ".yml") ? "#{base_dup_name}.yaml" : "#{base_dup_name}.yml"}$/ + if /#{(File.extname(filename) == ".yml") ? "#{base_dup_name}.yaml" : "#{base_dup_name}.yml"}$/.match?(other[:name]) raise Chef::Exceptions::AmbiguousYAMLFile.new("Cookbook #{name}@#{version} contains ambiguous files: #{filename} and #{other[:name]}. Please update the cookbook to remove the incorrect file.") end end |