summaryrefslogtreecommitdiff
path: root/knife
diff options
context:
space:
mode:
authorLamont Granquist <454857+lamont-granquist@users.noreply.github.com>2022-01-04 12:44:48 -0800
committerGitHub <noreply@github.com>2022-01-04 12:44:48 -0800
commitf9fb231d9080192b31728d31c56de9d009941637 (patch)
treeed82f4b520ab81ad89bd5023f8d8c8d35a4f3205 /knife
parent8c5dbeb7609284f79d705e6ff0ac703bce0752ba (diff)
parentf84a238a1d8d0060d5064eee0b74ed942088d4fd (diff)
downloadchef-f9fb231d9080192b31728d31c56de9d009941637.tar.gz
Merge pull request #12411 from chef/Performance_RegexpMatch
Diffstat (limited to 'knife')
-rw-r--r--knife/lib/chef/knife/core/gem_glob_loader.rb2
-rw-r--r--knife/lib/chef/knife/core/subcommand_loader.rb2
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 d70ba11a59..ddcaeffd0c 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