Skip to content

Commit a12d0d8

Browse files
committed
Lint/ReturnInVoidContext
Ruby does not allow the initialize method or setters to return a value, so stop pretending that we can.
1 parent f83c6cd commit a12d0d8

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,6 @@ Lint/RescueException:
661661
- 'lib/puppet/util/command_line/trollop.rb'
662662
- 'util/rspec_grouper'
663663

664-
Lint/ReturnInVoidContext:
665-
Exclude:
666-
- 'lib/puppet/type/component.rb'
667-
- 'lib/puppet/util/suidmanager.rb'
668-
669664
Lint/SelfAssignment:
670665
Exclude:
671666
- 'lib/puppet/pops/evaluator/evaluator_impl.rb'

lib/puppet/type/component.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@
1515
# Override how parameters are handled so that we support the extra
1616
# parameters that are used with defined resource types.
1717
def [](param)
18-
return super if self.class.valid_parameter?(param)
19-
@extra_parameters[param.to_sym]
18+
if self.class.valid_parameter?(param)
19+
super
20+
else
21+
@extra_parameters[param.to_sym]
22+
end
2023
end
2124

2225
# Override how parameters are handled so that we support the extra
2326
# parameters that are used with defined resource types.
2427
def []=(param, value)
25-
return super if self.class.valid_parameter?(param)
26-
@extra_parameters[param.to_sym] = value
28+
if self.class.valid_parameter?(param)
29+
super
30+
else
31+
@extra_parameters[param.to_sym] = value
32+
end
2733
end
2834

2935
# Initialize a new component

lib/puppet/util/suidmanager.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def osx_maj_ver
2424

2525
def groups=(grouplist)
2626
begin
27-
return Process.groups = grouplist
27+
Process.groups = grouplist
2828
rescue Errno::EINVAL => e
2929
#We catch Errno::EINVAL as some operating systems (OS X in particular) can
3030
# cause troubles when using Process#groups= to change *this* user / process
@@ -37,9 +37,7 @@ def groups=(grouplist)
3737
# operating system side. Therefore we catch the exception and look whether
3838
# we run under OS X or not -- if so, then we acknowledge the problem and
3939
# re-throw the exception otherwise.
40-
if osx_maj_ver and not osx_maj_ver.empty?
41-
return true
42-
else
40+
if !osx_maj_ver || osx_maj_ver.empty?
4341
raise e
4442
end
4543
end

0 commit comments

Comments
 (0)