From 36a46c84de29e127dee95ebd5caa992ac39046b6 Mon Sep 17 00:00:00 2001 From: Bobosila Victor Date: Sat, 25 Sep 2021 13:15:58 +0300 Subject: (MODULES-11197) Rubocop fixes --- .rubocop.yml | 2 +- lib/puppet/type/host.rb | 6 +++--- spec/acceptance/tests/create_spec.rb | 4 ++-- spec/acceptance/tests/modify_spec.rb | 4 ++-- spec/shared_behaviours/all_parsedfile_providers.rb | 2 +- spec/unit/type/host_spec.rb | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4416e78..de02624 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -121,7 +121,7 @@ Performance/SortReverse: Performance/Squeeze: Enabled: true Performance/StringInclude: - Enabled: true + Enabled: false Performance/Sum: Enabled: true Style/CollectionMethods: diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 03059b9..0510180 100644 --- a/lib/puppet/type/host.rb +++ b/lib/puppet/type/host.rb @@ -46,8 +46,8 @@ Puppet::Type.newtype(:host) do validate do |value| # This regex already includes newline check. - raise Puppet::Error, _('Host aliases cannot include whitespace') if value =~ %r{\s} - raise Puppet::Error, _('Host aliases cannot be an empty string. Use an empty array to delete all host_aliases ') if value =~ %r{^\s*$} + raise Puppet::Error, _('Host aliases cannot include whitespace') if %r{\s}.match?(value) + raise Puppet::Error, _('Host aliases cannot be an empty string. Use an empty array to delete all host_aliases ') if %r{^\s*$}.match?(value) end end @@ -80,7 +80,7 @@ Puppet::Type.newtype(:host) do validate do |value| value.split('.').each do |hostpart| - if hostpart !~ %r{^([\w]+|[\w][\w\-]+[\w])$} + unless %r{^([\w]+|[\w][\w\-]+[\w])$}.match?(hostpart) raise Puppet::Error, _('Invalid host name') end end diff --git a/spec/acceptance/tests/create_spec.rb b/spec/acceptance/tests/create_spec.rb index 40267fd..f79452d 100644 --- a/spec/acceptance/tests/create_spec.rb +++ b/spec/acceptance/tests/create_spec.rb @@ -13,7 +13,7 @@ RSpec.context 'when creating host files' do on(agent, puppet_resource('host', 'test', 'ensure=present', 'ip=127.0.0.1', "target=#{target}")) on(agent, "cat #{target}") do |result| - fail_test 'record was not present' if result.stdout !~ %r{^127\.0\.0\.1[[:space:]]+test} + fail_test 'record was not present' unless %r{^127\.0\.0\.1[[:space:]]+test}.match?(result.stdout) end end @@ -23,7 +23,7 @@ RSpec.context 'when creating host files' do on(agent, "cat #{target}") do |result| fail_test 'alias was missing' unless - result.stdout =~ %r{^127\.0\.0\.7[[:space:]]+test[[:space:]]alias} + %r{^127\.0\.0\.7[[:space:]]+test[[:space:]]alias}.match?(result.stdout) end end diff --git a/spec/acceptance/tests/modify_spec.rb b/spec/acceptance/tests/modify_spec.rb index 6498ee0..d07bb23 100644 --- a/spec/acceptance/tests/modify_spec.rb +++ b/spec/acceptance/tests/modify_spec.rb @@ -16,7 +16,7 @@ RSpec.context 'when modifying host files' do on(agent, "cat #{target}") do |result| fail_test 'the address was not updated' unless - result.stdout =~ %r{^127\.0\.0\.10[[:space:]]+test[[:space:]]+alias[[:space:]]*$} + %r{^127\.0\.0\.10[[:space:]]+test[[:space:]]+alias[[:space:]]*$}.match?(result.stdout) end end @@ -27,7 +27,7 @@ RSpec.context 'when modifying host files' do on(agent, "cat #{target}") do |result| fail_test 'the alias was not updated' unless - result.stdout =~ %r{^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$} + %r{^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$}.match?(result.stdout) end end end diff --git a/spec/shared_behaviours/all_parsedfile_providers.rb b/spec/shared_behaviours/all_parsedfile_providers.rb index 1701fe3..321cd86 100644 --- a/spec/shared_behaviours/all_parsedfile_providers.rb +++ b/spec/shared_behaviours/all_parsedfile_providers.rb @@ -4,7 +4,7 @@ shared_examples_for 'all parsedfile providers' do |provider, *files| end files.flatten.each do |file| - it "should rewrite #{file} reasonably unchanged" do + it "rewrites #{file} reasonably unchanged" do allow(provider).to receive(:default_target).and_return(file) provider.prefetch diff --git a/spec/unit/type/host_spec.rb b/spec/unit/type/host_spec.rb index 54d9b75..3fa5985 100644 --- a/spec/unit/type/host_spec.rb +++ b/spec/unit/type/host_spec.rb @@ -12,13 +12,13 @@ describe Puppet::Type.type(:host) do describe 'when validating attributes' do [:name, :provider].each do |param| - it "should have a #{param} parameter" do + it "has a #{param} parameter" do expect(described_class.attrtype(param)).to eq(:param) end end [:ip, :target, :host_aliases, :comment, :ensure].each do |property| - it "should have a #{property} property" do + it "has a #{property} property" do expect(described_class.attrtype(property)).to eq(:property) end end @@ -256,7 +256,7 @@ describe Puppet::Type.type(:host) do '0:a:b:c:d:e:f::', '::0:a:b:c:d:e:f', # syntactically correct, but bad form (::0:... could be combined) 'a:b:c:d:e:f:0::'].each do |ip| - it "should accept #{ip.inspect} as an IPv6 address" do + it "accepts #{ip.inspect} as an IPv6 address" do expect { described_class.new(name: 'foo', ip: ip) }.not_to raise_error end end @@ -587,7 +587,7 @@ describe Puppet::Type.type(:host) do '1111::3333:4444:5555:6666:7777:8888:', '::3333:4444:5555:6666:7777:8888:', '::2222:3333:4444:5555:6666:7777:8888:'].each do |ip| - it "should reject #{ip.inspect} as an IPv6 address" do + it "rejects #{ip.inspect} as an IPv6 address" do expect { described_class.new(name: 'foo', ip: ip) }.to raise_error(Puppet::ResourceError, %r{Parameter ip failed}) end end -- cgit v1.2.3