From 390d6258696aa24f5beb6996ebef8f3eccffaff1 Mon Sep 17 00:00:00 2001 From: Michael Hashizume Date: Wed, 10 Jan 2024 09:56:39 -0800 Subject: [PATCH] Fix Rubocop Performance/StringInclude offenses --- lib/puppet/type/sshkey.rb | 2 +- .../tests/resource/ssh_authorized_key/create_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/type/sshkey.rb b/lib/puppet/type/sshkey.rb index 11d6cef..7971d62 100644 --- a/lib/puppet/type/sshkey.rb +++ b/lib/puppet/type/sshkey.rb @@ -85,7 +85,7 @@ def should if %r{\s}.match?(value) raise Puppet::Error, _('Aliases cannot include whitespace') end - if %r{,}.match?(value) + if value.include?(',') raise Puppet::Error, _('Aliases must be provided as an array, not a comma-separated list') end end diff --git a/spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb b/spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb index d19d328..5a9f53d 100644 --- a/spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb +++ b/spec/acceptance/tests/resource/ssh_authorized_key/create_spec.rb @@ -65,7 +65,7 @@ 'drop_privileges=false', "target=/home/testuser/tmp/ssh_authorized_keys_#{name}/authorized_keys_#{name}"] on(agent, puppet_resource('ssh_authorized_key', name.to_s, args)) do |_res| - fail_test unless %r{the target path is not trusted}.match?(stderr) + fail_test unless stderr.include?('the target path is not trusted') end on(agent, "rm -rf #{custom_key_directory}") @@ -81,7 +81,7 @@ 'drop_privileges=false', "target='#{custom_key}'"] on(agent, puppet_resource('ssh_authorized_key', name.to_s, args), acceptable_exit_codes: [0, 1]) do |_res| - fail_test unless %r{the target path is not trusted}.match?(stderr) + fail_test unless stderr.include?('the target path is not trusted') end end end