Skip to content

Commit 845621a

Browse files
committed
(CONT-776) - Correct Style/SoleNestedConditional
1 parent e3a160e commit 845621a

File tree

5 files changed

+16
-34
lines changed

5 files changed

+16
-34
lines changed

.rubocop_todo.yml

-10
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,6 @@ RSpec/StubbedMock:
156156
Exclude:
157157
- 'spec/unit/lib/facter/docker_spec.rb'
158158

159-
# Offense count: 4
160-
# This cop supports safe autocorrection (--autocorrect).
161-
# Configuration parameters: AllowModifier.
162-
Style/SoleNestedConditional:
163-
Exclude:
164-
- 'lib/puppet/provider/docker_network/ruby.rb'
165-
- 'spec/classes/compose_spec.rb'
166-
- 'spec/classes/machine_spec.rb'
167-
- 'spec/defines/services_spec.rb'
168-
169159
# Offense count: 4
170160
# This cop supports safe autocorrection (--autocorrect).
171161
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.

lib/puppet/provider/docker_network/ruby.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def self.instances
5454
inspect = docker(['network', 'inspect', name])
5555
obj = JSON.parse(inspect).first
5656
ipam_driver = (obj['IPAM']['Driver'] unless obj['IPAM']['Driver'].nil?)
57-
subnet = unless obj['IPAM']['Config'].nil? || obj['IPAM']['Config'].empty?
58-
obj['IPAM']['Config'].first['Subnet'] if obj['IPAM']['Config'].first.key? 'Subnet'
59-
end
57+
subnet = (obj['IPAM']['Config'].first['Subnet'] if !(obj['IPAM']['Config'].nil? || obj['IPAM']['Config'].empty?) && (obj['IPAM']['Config'].first.key? 'Subnet'))
6058
new(
6159
name: name,
6260
id: obj['Id'],

spec/classes/compose_spec.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,12 @@
7373
params
7474
end
7575

76-
if params['proxy'] != :undef
77-
unless %r{^((https?)?://)?([^:^@]+:[^:^@]+@|)([\da-z.-]+)\.([\da-z.]{2,6})(:\d)?([/\w .-]*)*/?$}.match?(params['proxy'])
78-
it {
79-
expect(subject).to compile.and_raise_error(%r{does not match})
80-
}
76+
if params['proxy'] != :undef && !%r{^((https?)?://)?([^:^@]+:[^:^@]+@|)([\da-z.-]+)\.([\da-z.]{2,6})(:\d)?([/\w .-]*)*/?$}.match?(params['proxy'])
77+
it {
78+
expect(subject).to compile.and_raise_error(%r{does not match})
79+
}
8180

82-
next
83-
end
81+
next
8482
end
8583

8684
include_examples 'compose', params, facts

spec/classes/machine_spec.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@
4242
params
4343
end
4444

45-
if params['proxy'] != :undef
46-
unless '^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$'.match?(params['proxy'])
47-
it {
48-
expect(subject).to compile.and_raise_error(%r{})
49-
}
45+
if params['proxy'] != :undef && !'^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$'.match?(params['proxy'])
46+
it {
47+
expect(subject).to compile.and_raise_error(%r{})
48+
}
5049

51-
next
52-
end
50+
next
5351
end
5452

5553
include_examples 'machine', params, facts, defaults

spec/defines/services_spec.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,12 @@
102102
'rspec_services'
103103
end
104104

105-
if params['ensure'] == 'absent'
106-
if params['update'] || params['scale']
107-
it {
108-
expect(subject).to compile.and_raise_error('When removing a service you can not update it.')
109-
}
105+
if params['ensure'] == 'absent' && (params['update'] || params['scale'])
106+
it {
107+
expect(subject).to compile.and_raise_error('When removing a service you can not update it.')
108+
}
110109

111-
next
112-
end
110+
next
113111
end
114112

115113
include_examples 'services', 'rspec_services', params, facts, defaults

0 commit comments

Comments
 (0)