summaryrefslogtreecommitdiff
path: root/lib/chef/data_bag.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/data_bag.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/data_bag.rb')
-rw-r--r--lib/chef/data_bag.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb
index 5715f1970d..6be18dad58 100644
--- a/lib/chef/data_bag.rb
+++ b/lib/chef/data_bag.rb
@@ -36,10 +36,10 @@ class Chef
RESERVED_NAMES = /^(node|role|environment|client)$/.freeze
def self.validate_name!(name)
- unless name =~ VALID_NAME
+ unless VALID_NAME.match?(name)
raise Exceptions::InvalidDataBagName, "DataBags must have a name matching #{VALID_NAME.inspect}, you gave #{name.inspect}"
end
- if name =~ RESERVED_NAMES
+ if RESERVED_NAMES.match?(name)
raise Exceptions::InvalidDataBagName, "DataBags may not have a name matching #{RESERVED_NAMES.inspect}, you gave #{name.inspect}"
end
end