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 /knife | |
parent | 50a0001bae754c66feb69c84b64cb305a03a34d2 (diff) | |
download | chef-f84a238a1d8d0060d5064eee0b74ed942088d4fd.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 'knife')
-rw-r--r-- | knife/lib/chef/knife/core/gem_glob_loader.rb | 2 | ||||
-rw-r--r-- | knife/lib/chef/knife/core/subcommand_loader.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/knife/lib/chef/knife/core/gem_glob_loader.rb b/knife/lib/chef/knife/core/gem_glob_loader.rb index d365602cb4..afc1575f5e 100644 --- a/knife/lib/chef/knife/core/gem_glob_loader.rb +++ b/knife/lib/chef/knife/core/gem_glob_loader.rb @@ -62,7 +62,7 @@ class Chef # Exclude knife/chef/version. It's not a knife command, and force-loading # when we load all of these files will emit constant-already-defined warnings - next if rel_path =~ version_file_match + next if rel_path&.match?(version_file_match) subcommand_files[rel_path] = file end diff --git a/knife/lib/chef/knife/core/subcommand_loader.rb b/knife/lib/chef/knife/core/subcommand_loader.rb index ca7bfcd008..0f84dbb176 100644 --- a/knife/lib/chef/knife/core/subcommand_loader.rb +++ b/knife/lib/chef/knife/core/subcommand_loader.rb @@ -151,7 +151,7 @@ class Chef rel_path = knife_file[/#{KNIFE_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1] # Exclude version.rb file for the gem. It's not a knife command, and force-loading it later # because loaded via in subcommand files generates CLI warnings about its consts already having been defined - next if knife_file =~ version_file_match + next if knife_file&.match?(version_file_match) subcommand_files[rel_path] = knife_file end |