Skip to content

Commit 62b1cd6

Browse files
authored
Merge pull request #9283 from AriaXLi/PUP-11993/more_style_cops
(PUP-11993) The rest of the Style/Redundant* cops!
2 parents 5eaa95b + be334aa commit 62b1cd6

File tree

289 files changed

+1159
-1192
lines changed

Some content is hidden

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

289 files changed

+1159
-1192
lines changed

.rubocop_todo.yml

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

655-
# This cop supports unsafe auto-correction (--auto-correct-all).
656-
Style/RedundantInterpolation:
657-
Enabled: false
658-
659-
# This cop supports safe auto-correction (--auto-correct).
660-
# Configuration parameters: AllowMultipleReturnValues.
661-
Style/RedundantReturn:
662-
Enabled: false
663-
664-
# This cop supports safe auto-correction (--auto-correct).
665-
Style/RedundantSelf:
666-
Enabled: false
667-
668655
# This cop supports safe auto-correction (--auto-correct).
669656
# Configuration parameters: EnforcedStyle.
670657
# 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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ def option(*options, &block)
184184
define_method(fname, &block)
185185
else
186186
define_method(fname) do |value|
187-
self.options["#{long}".to_sym] = value
187+
self.options[long.to_s.to_sym] = value
188188
end
189189
end
190-
self.option_parser_commands << [options, fname]
190+
option_parser_commands << [options, fname]
191191
end
192192

193193
def banner(banner = nil)
@@ -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 self.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

@@ -330,7 +330,7 @@ def clear_everything_for_tests
330330
# See also `lib/puppet/util/command_line.rb` for some special case early
331331
# handling of this.
332332
option("--version", "-V") do |_arg|
333-
puts "#{Puppet.version}"
333+
puts Puppet.version
334334
exit(0)
335335
end
336336

@@ -553,14 +553,14 @@ def parse_options
553553
self.class.option_parser_commands.each do |options, fname|
554554
option_parser.on(*options) do |value|
555555
# Call the method that "option()" created.
556-
self.send(fname, value)
556+
send(fname, value)
557557
end
558558
end
559559

560560
# Scan command line. We just hand any exceptions to our upper levels,
561561
# rather than printing help and exiting, so that we can meaningfully
562562
# respond with context-sensitive help if we want to. --daniel 2011-04-12
563-
option_parser.parse!(self.command_line.args)
563+
option_parser.parse!(command_line.args)
564564
end
565565

566566
def handlearg(opt, val)

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)