Skip to content

Commit 09502ce

Browse files
committed
(PUP-11993) Style/ParallelAssignment
This commit enables the Style/ParallelAssignment cop and fixes 19 autocorrectable offenses.
1 parent 0d10dfc commit 09502ce

File tree

14 files changed

+50
-36
lines changed

14 files changed

+50
-36
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -640,23 +640,6 @@ Style/NumericPredicate:
640640
Style/OptionalBooleanParameter:
641641
Enabled: false
642642

643-
# This cop supports safe auto-correction (--auto-correct).
644-
Style/ParallelAssignment:
645-
Exclude:
646-
- 'lib/puppet/configurer/downloader.rb'
647-
- 'lib/puppet/graph/rb_tree_map.rb'
648-
- 'lib/puppet/module_tool/shared_behaviors.rb'
649-
- 'lib/puppet/network/client_request.rb'
650-
- 'lib/puppet/parser/relationship.rb'
651-
- 'lib/puppet/provider/package/ports.rb'
652-
- 'lib/puppet/provider/service/smf.rb'
653-
- 'lib/puppet/provider/user/aix.rb'
654-
- 'lib/puppet/relationship.rb'
655-
- 'lib/puppet/settings/config_file.rb'
656-
- 'lib/puppet/type/file/ensure.rb'
657-
- 'lib/puppet/util/suidmanager.rb'
658-
- 'lib/puppet/util/windows/registry.rb'
659-
660643
# This cop supports safe auto-correction (--auto-correct).
661644
# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions.
662645
Style/ParenthesesAroundCondition:

lib/puppet/configurer/downloader.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ def evaluate
4040
end
4141

4242
def initialize(name, path, source, ignore = nil, environment = nil, source_permissions = :ignore)
43-
@name, @path, @source, @ignore, @environment, @source_permissions = name, path, source, ignore, environment, source_permissions
43+
@name = name
44+
@path = path
45+
@source = source
46+
@ignore = ignore
47+
@environment = environment
48+
@source_permissions = source_permissions
4449
end
4550

4651
def file

lib/puppet/graph/rb_tree_map.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,27 +236,35 @@ def colorflip
236236

237237
def rotate_left
238238
r = @right
239-
r_key, r_value = r.key, r.value
239+
r_key = r.key
240+
r_value = r.value
240241
b = r.left
241242
r.left = @left
242243
@left = r
243244
@right = r.right
244245
r.right = b
245-
r.color, r.key, r.value = :red, @key, @value
246-
@key, @value = r_key, r_value
246+
r.color = :red
247+
r.key = @key
248+
r.value = @value
249+
@key = r_key
250+
@value = r_value
247251
self
248252
end
249253

250254
def rotate_right
251255
l = @left
252-
l_key, l_value = l.key, l.value
256+
l_key = l.key
257+
l_value = l.value
253258
b = l.right
254259
l.right = @right
255260
@right = l
256261
@left = l.left
257262
l.left = b
258-
l.color, l.key, l.value = :red, @key, @value
259-
@key, @value = l_key, l_value
263+
l.color = :red
264+
l.key = @key
265+
l.value = @value
266+
@key = l_key
267+
@value = l_value
260268
self
261269
end
262270

lib/puppet/module_tool/shared_behaviors.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def get_local_constraints
1313
@installed[mod_name] << mod
1414
d = @local["#{mod_name}@#{mod.version}"]
1515
(mod.dependencies || []).each do |hash|
16-
name, conditions = hash['name'], hash['version_requirement']
16+
name = hash['name']
17+
conditions = hash['version_requirement']
1718
name = name.tr('/', '-')
1819
d[name] = conditions
1920
@conditions[name] << {

lib/puppet/network/client_request.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def call
2020
end
2121

2222
def initialize(name, ip, authenticated)
23-
@name, @ip, @authenticated = name, ip, authenticated
23+
@name = name
24+
@ip = ip
25+
@authenticated = authenticated
2426
end
2527

2628
def to_s

lib/puppet/parser/relationship.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def evaluate(catalog)
2626
end
2727

2828
def initialize(source, target, type)
29-
@source, @target, @type = source, target, type
29+
@source = source
30+
@target = target
31+
@type = type
3032
end
3133

3234
def param_name

lib/puppet/provider/package/ports.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def latest
6262
_("Could not match version info '%{info}'") % { info: info }
6363
end
6464

65-
source, newversion = $1, $2
65+
source = $1
66+
newversion = $2
6667

6768
debug "Newer version in #{source}"
6869
newversion

lib/puppet/provider/service/smf.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ def maybe_clear_service_then_svcadm(cur_state, subcmd, flags)
248248
def flush
249249
# We append the "_" because ensure is a Ruby keyword, and it is good to keep property
250250
# variable names consistent with each other.
251-
enable_, ensure_ = @properties_to_sync[:enable], @properties_to_sync[:ensure]
251+
enable_ = @properties_to_sync[:enable]
252+
ensure_ = @properties_to_sync[:ensure]
252253

253254
# All of the relevant properties are in sync., so we do not need to do
254255
# anything here.

lib/puppet/provider/user/aix.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def expires_to_expiry(provider, expires)
7272
return :absent
7373
end
7474

75-
month, day, year = match_obj[1], match_obj[2], match_obj[-1]
75+
month = match_obj[1]
76+
day = match_obj[2]
77+
year = match_obj[-1]
7678
return "20#{year}-#{month}-#{day}"
7779
end
7880

lib/puppet/relationship.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def event=(event)
3434
end
3535

3636
def initialize(source, target, options = {})
37-
@source, @target = source, target
37+
@source = source
38+
@target = target
3839

3940
options = (options || {}).each_with_object({}) { |a, h| h[a[0].to_sym] = a[1]; }
4041
[:callback, :event].each do |option|

0 commit comments

Comments
 (0)