Skip to content

Commit 36a46c8

Browse files
(MODULES-11197) Rubocop fixes
1 parent e78ecf8 commit 36a46c8

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Performance/SortReverse:
121121
Performance/Squeeze:
122122
Enabled: true
123123
Performance/StringInclude:
124-
Enabled: true
124+
Enabled: false
125125
Performance/Sum:
126126
Enabled: true
127127
Style/CollectionMethods:

lib/puppet/type/host.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def inclusive?
4646

4747
validate do |value|
4848
# This regex already includes newline check.
49-
raise Puppet::Error, _('Host aliases cannot include whitespace') if value =~ %r{\s}
50-
raise Puppet::Error, _('Host aliases cannot be an empty string. Use an empty array to delete all host_aliases ') if value =~ %r{^\s*$}
49+
raise Puppet::Error, _('Host aliases cannot include whitespace') if %r{\s}.match?(value)
50+
raise Puppet::Error, _('Host aliases cannot be an empty string. Use an empty array to delete all host_aliases ') if %r{^\s*$}.match?(value)
5151
end
5252
end
5353

@@ -80,7 +80,7 @@ def inclusive?
8080

8181
validate do |value|
8282
value.split('.').each do |hostpart|
83-
if hostpart !~ %r{^([\w]+|[\w][\w\-]+[\w])$}
83+
unless %r{^([\w]+|[\w][\w\-]+[\w])$}.match?(hostpart)
8484
raise Puppet::Error, _('Invalid host name')
8585
end
8686
end

spec/acceptance/tests/create_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
on(agent, puppet_resource('host', 'test', 'ensure=present',
1414
'ip=127.0.0.1', "target=#{target}"))
1515
on(agent, "cat #{target}") do |result|
16-
fail_test 'record was not present' if result.stdout !~ %r{^127\.0\.0\.1[[:space:]]+test}
16+
fail_test 'record was not present' unless %r{^127\.0\.0\.1[[:space:]]+test}.match?(result.stdout)
1717
end
1818
end
1919

@@ -23,7 +23,7 @@
2323

2424
on(agent, "cat #{target}") do |result|
2525
fail_test 'alias was missing' unless
26-
result.stdout =~ %r{^127\.0\.0\.7[[:space:]]+test[[:space:]]alias}
26+
%r{^127\.0\.0\.7[[:space:]]+test[[:space:]]alias}.match?(result.stdout)
2727
end
2828
end
2929

spec/acceptance/tests/modify_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
on(agent, "cat #{target}") do |result|
1818
fail_test 'the address was not updated' unless
19-
result.stdout =~ %r{^127\.0\.0\.10[[:space:]]+test[[:space:]]+alias[[:space:]]*$}
19+
%r{^127\.0\.0\.10[[:space:]]+test[[:space:]]+alias[[:space:]]*$}.match?(result.stdout)
2020
end
2121
end
2222

@@ -27,7 +27,7 @@
2727

2828
on(agent, "cat #{target}") do |result|
2929
fail_test 'the alias was not updated' unless
30-
result.stdout =~ %r{^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$}
30+
%r{^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$}.match?(result.stdout)
3131
end
3232
end
3333
end

spec/shared_behaviours/all_parsedfile_providers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
end
55

66
files.flatten.each do |file|
7-
it "should rewrite #{file} reasonably unchanged" do
7+
it "rewrites #{file} reasonably unchanged" do
88
allow(provider).to receive(:default_target).and_return(file)
99
provider.prefetch
1010

spec/unit/type/host_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
describe 'when validating attributes' do
1414
[:name, :provider].each do |param|
15-
it "should have a #{param} parameter" do
15+
it "has a #{param} parameter" do
1616
expect(described_class.attrtype(param)).to eq(:param)
1717
end
1818
end
1919

2020
[:ip, :target, :host_aliases, :comment, :ensure].each do |property|
21-
it "should have a #{property} property" do
21+
it "has a #{property} property" do
2222
expect(described_class.attrtype(property)).to eq(:property)
2323
end
2424
end
@@ -256,7 +256,7 @@
256256
'0:a:b:c:d:e:f::',
257257
'::0:a:b:c:d:e:f', # syntactically correct, but bad form (::0:... could be combined)
258258
'a:b:c:d:e:f:0::'].each do |ip|
259-
it "should accept #{ip.inspect} as an IPv6 address" do
259+
it "accepts #{ip.inspect} as an IPv6 address" do
260260
expect { described_class.new(name: 'foo', ip: ip) }.not_to raise_error
261261
end
262262
end
@@ -587,7 +587,7 @@
587587
'1111::3333:4444:5555:6666:7777:8888:',
588588
'::3333:4444:5555:6666:7777:8888:',
589589
'::2222:3333:4444:5555:6666:7777:8888:'].each do |ip|
590-
it "should reject #{ip.inspect} as an IPv6 address" do
590+
it "rejects #{ip.inspect} as an IPv6 address" do
591591
expect { described_class.new(name: 'foo', ip: ip) }.to raise_error(Puppet::ResourceError, %r{Parameter ip failed})
592592
end
593593
end

0 commit comments

Comments
 (0)