diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-06-11 15:02:42 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-06-11 15:32:53 -0700 |
commit | 5825eea4b139b9af089c3075d042d5d3160583ec (patch) | |
tree | fd79641ded1857ee4166b6e9ba774a35ab47b06b /lib/chef/util | |
parent | 3889eddfc9944b23caea412d05c08b9b156cb50f (diff) | |
download | chef-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/util')
-rw-r--r-- | lib/chef/util/diff.rb | 2 | ||||
-rw-r--r-- | lib/chef/util/windows/net_user.rb | 2 | ||||
-rw-r--r-- | lib/chef/util/windows/volume.rb | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/util/diff.rb b/lib/chef/util/diff.rb index 30ea838e96..6f10cbde35 100644 --- a/lib/chef/util/diff.rb +++ b/lib/chef/util/diff.rb @@ -171,7 +171,7 @@ class Chef begin return buff !~ /\A[\s[:print:]]*\z/m rescue ArgumentError => e - return true if e.message =~ /invalid byte sequence/ + return true if /invalid byte sequence/.match?(e.message) raise end diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb index 5545ff4ca5..b6767c41c5 100644 --- a/lib/chef/util/windows/net_user.rb +++ b/lib/chef/util/windows/net_user.rb @@ -100,7 +100,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows rescue Chef::Exceptions::Win32APIError => e Chef::Log.trace(e) # we're only interested in the incorrect password failures - if e.to_s =~ /System Error Code: 1326/ + if /System Error Code: 1326/.match?(e.to_s) return false end diff --git a/lib/chef/util/windows/volume.rb b/lib/chef/util/windows/volume.rb index 1b75fe8cb9..e197604c34 100644 --- a/lib/chef/util/windows/volume.rb +++ b/lib/chef/util/windows/volume.rb @@ -25,7 +25,7 @@ class Chef::Util::Windows::Volume < Chef::Util::Windows attr_reader :mount_point def initialize(name) - name += "\\" unless name =~ /\\$/ # trailing slash required + name += "\\" unless /\\$/.match?(name) # trailing slash required @mount_point = name end |