Skip to content

Commit 5f1cc46

Browse files
committed
(PUP-11993) Style/RedundantAssignment
This commit enables the Style/RedundantAssignment cop and fixes 64 autocorrectable offenses.
1 parent 1160aa8 commit 5f1cc46

File tree

16 files changed

+18
-60
lines changed

16 files changed

+18
-60
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -646,25 +646,6 @@ Style/OptionalBooleanParameter:
646646
Style/PreferredHashMethods:
647647
Enabled: false
648648

649-
# This cop supports safe auto-correction (--auto-correct).
650-
Style/RedundantAssignment:
651-
Exclude:
652-
- 'lib/puppet/file_serving/mount/locales.rb'
653-
- 'lib/puppet/file_serving/mount/pluginfacts.rb'
654-
- 'lib/puppet/file_serving/mount/plugins.rb'
655-
- 'lib/puppet/parameter.rb'
656-
- 'lib/puppet/parser/ast/pops_bridge.rb'
657-
- 'lib/puppet/pops/model/factory.rb'
658-
- 'lib/puppet/pops/parser/parser_support.rb'
659-
- 'lib/puppet/provider/nameservice/directoryservice.rb'
660-
- 'lib/puppet/provider/nameservice/objectadd.rb'
661-
- 'lib/puppet/provider/nameservice/pw.rb'
662-
- 'lib/puppet/settings.rb'
663-
- 'lib/puppet/type.rb'
664-
- 'lib/puppet/type/file/ensure.rb'
665-
- 'lib/puppet/util.rb'
666-
- 'lib/puppet/util/execution.rb'
667-
668649
# This cop supports safe auto-correction (--auto-correct).
669650
Style/RedundantBegin:
670651
Enabled: false

lib/puppet/file_serving/mount/locales.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ def find(relative_path, request)
1111
mod = request.environment.modules.find { |m| m.locale(relative_path) }
1212
return nil unless mod
1313

14-
path = mod.locale(relative_path)
15-
16-
path
14+
mod.locale(relative_path)
1715
end
1816

1917
def search(relative_path, request)

lib/puppet/file_serving/mount/pluginfacts.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ def find(relative_path, request)
1111
mod = request.environment.modules.find { |m| m.pluginfact(relative_path) }
1212
return nil unless mod
1313

14-
path = mod.pluginfact(relative_path)
15-
16-
path
14+
mod.pluginfact(relative_path)
1715
end
1816

1917
def search(relative_path, request)

lib/puppet/file_serving/mount/plugins.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ def find(relative_path, request)
1111
mod = request.environment.modules.find { |m| m.plugin(relative_path) }
1212
return nil unless mod
1313

14-
path = mod.plugin(relative_path)
15-
16-
path
14+
mod.plugin(relative_path)
1715
end
1816

1917
def search(relative_path, request)

lib/puppet/parameter.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ def name
385385
#
386386
def noop
387387
@noop ||= false
388-
tmp = @noop || self.resource.noop || Puppet[:noop] || false
389-
tmp
388+
@noop || self.resource.noop || Puppet[:noop] || false
390389
end
391390

392391
# Returns an array of strings representing the containment hierarchy

lib/puppet/parser/ast/pops_bridge.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,14 @@ def create_type_map(definition)
173173

174174
# Obtains the scope or issues a warning if :global_scope is not bound
175175
def obtain_scope
176-
scope = Puppet.lookup(:global_scope) do
176+
Puppet.lookup(:global_scope) do
177177
# This occurs when testing and when applying a catalog (there is no scope available then), and
178178
# when running tests that run a partial setup.
179179
# This is bad if the logic is trying to compile, but a warning can not be issues since it is a normal
180180
# use case that there is no scope when requesting the type in order to just get the parameters.
181181
Puppet.debug { _("Instantiating Resource with type checked parameters - scope is missing, skipping type checking.") }
182182
nil
183183
end
184-
scope
185184
end
186185

187186
# Produces a hash with data for Definition and HostClass

lib/puppet/pops/model/factory.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,8 +1052,7 @@ def self.transform_resource_wo_title(left, attribute_ops, lbrace_token, rbrace_t
10521052
end
10531053
a_hash = HASH(keyed_entries)
10541054
a_hash.record_position(left[KEY_LOCATOR], lbrace_token, rbrace_token)
1055-
result = block_or_expression(transform_calls([left, a_hash]))
1056-
result
1055+
block_or_expression(transform_calls([left, a_hash]))
10571056
end
10581057

10591058
def interpolate_Factory(c)

lib/puppet/pops/parser/parser_support.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ def create_empty_program
229229
_, token = @lexer.emit_completed([:NOOP, '', 0], locator.string.bytesize)
230230
loc(no_op, token)
231231
# Program with a Noop
232-
program = Factory.PROGRAM(no_op, [], locator)
233-
program
232+
Factory.PROGRAM(no_op, [], locator)
234233
end
235234

236235
# Performs the parsing and returns the resulting model.

lib/puppet/provider/nameservice/directoryservice.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ def self.get_password(guid, username)
264264
# string. The password_hash provided as a resource attribute is a
265265
# hex value. We need to convert the Base64 encoded string to a
266266
# hex value and provide it back to Puppet.
267-
password_hash = converted_hash_plist['SALTED-SHA512'].unpack("H*")[0]
268-
password_hash
267+
converted_hash_plist['SALTED-SHA512'].unpack("H*")[0]
268+
269269
end
270270
end
271271
end

lib/puppet/provider/nameservice/objectadd.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ def flag(name)
1515
end
1616

1717
def posixmethod(name)
18-
name = name.intern if name.is_a? String
19-
method = self.class.option(name, :method) || name
20-
21-
method
18+
name = name.intern if name.is_a? String
19+
self.class.option(name, :method) || name
2220
end
2321
end
2422
end

0 commit comments

Comments
 (0)