Skip to content

Commit 992c5dc

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

File tree

177 files changed

+624
-628
lines changed

Some content is hidden

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

177 files changed

+624
-628
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,6 @@ Style/PreferredHashMethods:
657657
Style/RedundantReturn:
658658
Enabled: false
659659

660-
# This cop supports safe auto-correction (--auto-correct).
661-
Style/RedundantSelf:
662-
Enabled: false
663-
664660
# This cop supports safe auto-correction (--auto-correct).
665661
# Configuration parameters: EnforcedStyle.
666662
# SupportedStyles: implicit, explicit

lib/puppet/application.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def option(*options, &block)
187187
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)
@@ -261,7 +261,7 @@ def find(application_name)
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+
return const_defined?(class_name) ? const_get(class_name) : nil
265265
end
266266
private :try_load_class
267267

@@ -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/confine/variable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def initialize(values)
2929
end
3030

3131
def message(value)
32-
"facter value '#{test_value}' for '#{self.name}' not in required list '#{values.join(",")}'"
32+
"facter value '#{test_value}' for '#{name}' not in required list '#{values.join(",")}'"
3333
end
3434

3535
# Compare the passed-in value to the retrieved value.

lib/puppet/confine_collection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def confine(hash)
2222
confine.name = test
2323
@confines << confine
2424
end
25-
@confines[-1].label = self.label
25+
@confines[-1].label = label
2626
end
2727
end
2828

lib/puppet/confiner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def confine(hash)
3333
# @api private
3434
#
3535
def confine_collection
36-
@confine_collection ||= Puppet::ConfineCollection.new(self.to_s)
36+
@confine_collection ||= Puppet::ConfineCollection.new(to_s)
3737
end
3838

3939
# Checks whether this implementation is suitable for the current platform (or returns a summary

lib/puppet/error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def to_h
9898
def self.from_issue_and_stack(issue, args = {})
9999
filename, line = Puppet::Pops::PuppetStack.top_of_stack
100100

101-
self.new(
101+
new(
102102
issue.format(args),
103103
filename,
104104
line,

lib/puppet/facter_impl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def load_external?
5858
end
5959

6060
def load_external(value)
61-
::Facter.load_external(value) if self.load_external?
61+
::Facter.load_external(value) if load_external?
6262
end
6363

6464
private

lib/puppet/file_bucket/file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def name
7373
end
7474

7575
def self.from_binary(contents)
76-
self.new(contents)
76+
new(contents)
7777
end
7878

7979
class StringContents

lib/puppet/file_serving/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def relative_path=(path)
7676

7777
# Stat our file, using the appropriate link-sensitive method.
7878
def stat
79-
@stat_method ||= self.links == :manage ? :lstat : :stat
79+
@stat_method ||= links == :manage ? :lstat : :stat
8080
Puppet::FileSystem.send(@stat_method, full_path)
8181
end
8282

lib/puppet/file_serving/fileset.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ def valid?(path)
185185

186186
def continue_recursion_at?(depth)
187187
# recurse if told to, and infinite recursion or current depth not at the limit
188-
self.recurse && (self.recurselimit == :infinite || depth <= self.recurselimit)
188+
recurse && (recurselimit == :infinite || depth <= recurselimit)
189189
end
190190
end

0 commit comments

Comments
 (0)