diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-05 11:44:16 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-05 12:41:14 -0700 |
commit | 7bf98ad06b30b7feb4ea3fbbe45a5b733467a5d3 (patch) | |
tree | b0995ded1a63654d3f54140bd880c69f86afd52f /lib/chef/cookbook | |
parent | 9802d7c075c8b7dae42dbcecd92d492f7fa128ac (diff) | |
download | chef-7bf98ad06b30b7feb4ea3fbbe45a5b733467a5d3.tar.gz |
Style/RegexpLiteral
given how many regexps we have with /'s in the match this seems like
a very good one.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/cookbook')
-rw-r--r-- | lib/chef/cookbook/cookbook_version_loader.rb | 2 | ||||
-rw-r--r-- | lib/chef/cookbook/remote_file_vendor.rb | 2 | ||||
-rw-r--r-- | lib/chef/cookbook/synchronizer.rb | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index 6d1b3e1f61..0b62718ab9 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -52,7 +52,7 @@ class Chef @inferred_cookbook_name = File.basename( path ) @chefignore = chefignore @metadata = nil - @relative_path = /#{Regexp.escape(cookbook_path)}\/(.+)$/ + @relative_path = %r{#{Regexp.escape(cookbook_path)}/(.+)$} @metadata_loaded = false @cookbook_settings = { all_files: {}, diff --git a/lib/chef/cookbook/remote_file_vendor.rb b/lib/chef/cookbook/remote_file_vendor.rb index ebdb94ee54..e5270018fb 100644 --- a/lib/chef/cookbook/remote_file_vendor.rb +++ b/lib/chef/cookbook/remote_file_vendor.rb @@ -37,7 +37,7 @@ class Chef # Chef::Config.cookbook_path file hierarchy for the requested # file. def get_filename(filename) - if filename =~ /([^\/]+)\/(.+)$/ + if filename =~ %r{([^/]+)/(.+)$} segment = $1 else raise "get_filename: Cannot determine segment/filename for incoming filename #{filename}" diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb index b69e6b8212..342fc89f16 100644 --- a/lib/chef/cookbook/synchronizer.rb +++ b/lib/chef/cookbook/synchronizer.rb @@ -209,7 +209,7 @@ class Chef # (if we have an override run_list we may not want to do this) def remove_old_cookbooks cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_file| - cache_file =~ /^cookbooks\/([^\/]+)\// + cache_file =~ %r{^cookbooks/([^/]+)/} unless have_cookbook?($1) Chef::Log.info("Removing #{cache_file} from the cache; its cookbook is no longer needed on this client.") cache.delete(cache_file) @@ -221,7 +221,7 @@ class Chef # remove deleted files in cookbooks that are being used on the node def remove_deleted_files cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_file| - md = cache_file.match(/^cookbooks\/([^\/]+)\/([^\/]+)\/(.*)/) + md = cache_file.match(%r{^cookbooks/([^/]+)/([^/]+)/(.*)}) next unless md ( cookbook_name, segment, file ) = md[1..3] |