Skip to content

Commit be334aa

Browse files
committed
(PUP-11993) Style/RedundantReturn
This commit enables the Style/RedundantReturn cop and fixes 538 autocorrectable offenses.
1 parent 992c5dc commit be334aa

File tree

200 files changed

+524
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+524
-549
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -652,11 +652,6 @@ Style/OptionalBooleanParameter:
652652
Style/PreferredHashMethods:
653653
Enabled: false
654654

655-
# This cop supports safe auto-correction (--auto-correct).
656-
# Configuration parameters: AllowMultipleReturnValues.
657-
Style/RedundantReturn:
658-
Enabled: false
659-
660655
# This cop supports safe auto-correction (--auto-correct).
661656
# Configuration parameters: EnforcedStyle.
662657
# SupportedStyles: implicit, explicit

lib/hiera/scope.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ def compiler
7777

7878
def find_hostclass(scope)
7979
if scope.source and scope.source.type == :hostclass
80-
return scope.source.name.downcase
80+
scope.source.name.downcase
8181
elsif scope.parent
82-
return find_hostclass(scope.parent)
82+
find_hostclass(scope.parent)
8383
else
84-
return nil
84+
nil
8585
end
8686
end
8787
private :find_hostclass

lib/hiera_puppet.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def parse_args(args)
4747
default = args[1]
4848
override = args[2]
4949

50-
return [key, default, override]
50+
[key, default, override]
5151
end
5252

5353
def hiera

lib/puppet.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def self.replace_settings_object(new_settings)
7575
# @api public
7676
def self.[](param)
7777
if param == :debug
78-
return Puppet::Util::Log.level == :debug
78+
Puppet::Util::Log.level == :debug
7979
else
80-
return @@settings[param]
80+
@@settings[param]
8181
end
8282
end
8383

lib/puppet/application.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ def find(application_name)
254254
raise Puppet::Error, _("Unable to load application class '%{class_name}' from file 'puppet/application/%{application_name}.rb'") % { class_name: class_name, application_name: application_name }
255255
end
256256

257-
return clazz
257+
clazz
258258
end
259259

260260
# Given the fully qualified name of a class, attempt to get the class instance.
261261
# @param [String] class_name the fully qualified name of the class to try to load
262262
# @return [Class] the Class instance, or nil? if it could not be loaded.
263263
def try_load_class(class_name)
264-
return const_defined?(class_name) ? const_get(class_name) : nil
264+
const_defined?(class_name) ? const_get(class_name) : nil
265265
end
266266
private :try_load_class
267267

lib/puppet/application/describe.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def scrub(text)
4444
# indent from every line.
4545
if text =~ /^(\s+)/
4646
indent = ::Regexp.last_match(1)
47-
return text.gsub(/^#{indent}/, '')
47+
text.gsub(/^#{indent}/, '')
4848
else
49-
return text
49+
text
5050
end
5151
end
5252
end

lib/puppet/application/doc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def handle_unknown(opt, arg)
122122
end
123123

124124
def run_command
125-
return [:rdoc].include?(options[:mode]) ? send(options[:mode]) : other
125+
[:rdoc].include?(options[:mode]) ? send(options[:mode]) : other
126126
end
127127

128128
def rdoc

lib/puppet/application/face_base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def find_global_settings_argument(item)
164164
pattern.match item and return object
165165
end
166166
end
167-
return nil # nothing found.
167+
nil # nothing found.
168168
end
169169

170170
def find_application_argument(item)
@@ -181,7 +181,7 @@ def find_application_argument(item)
181181
}
182182
end
183183
end
184-
return nil # not found
184+
nil # not found
185185
end
186186

187187
def setup

lib/puppet/application/ssl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def download_cert(ssl_context)
234234
cert
235235
rescue Puppet::HTTP::ResponseError => e
236236
if e.response.code == 404
237-
return nil
237+
nil
238238
else
239239
raise Puppet::Error.new(_("Failed to download certificate: %{message}") % { message: e.message }, e)
240240
end

lib/puppet/configurer.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def run_internal(options)
505505
true
506506
rescue => detail
507507
Puppet.log_exception(detail, _("Failed to apply catalog: %{detail}") % { detail: detail })
508-
return nil
508+
nil
509509
ensure
510510
execute_postrun_command or return nil # rubocop:disable Lint/EnsureReturn
511511
end
@@ -675,12 +675,12 @@ def resubmit_facts
675675

676676
puppet.put_facts(facts.name, facts: facts, environment: Puppet.lookup(:current_environment).name.to_s)
677677

678-
return true
678+
true
679679
rescue => detail
680680
Puppet.log_exception(detail, _("Failed to submit facts: %{detail}") %
681681
{ detail: detail })
682682

683-
return false
683+
false
684684
end
685685

686686
private
@@ -722,7 +722,7 @@ def retrieve_catalog_from_cache(query_options)
722722
result
723723
rescue => detail
724724
Puppet.log_exception(detail, _("Could not retrieve catalog from cache: %{detail}") % { detail: detail })
725-
return nil
725+
nil
726726
end
727727

728728
def retrieve_new_catalog(facts, query_options)
@@ -744,7 +744,7 @@ def retrieve_new_catalog(facts, query_options)
744744
result
745745
rescue StandardError => detail
746746
Puppet.log_exception(detail, _("Could not retrieve catalog from remote server: %{detail}") % { detail: detail })
747-
return nil
747+
nil
748748
end
749749

750750
def download_plugins(remote_environment_for_plugins)

0 commit comments

Comments
 (0)