Skip to content

Commit 049dc6a

Browse files
authored
Merge pull request #9029 from tvpartytonight/PUP-11770-handle_lint_cops_DuplicateMethods
(PUP-11770) Eliminate duplicate methods reported by rubocop
2 parents a4ed291 + b02c038 commit 049dc6a

File tree

18 files changed

+31
-37
lines changed

18 files changed

+31
-37
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,6 @@ Lint/DeprecatedOpenSSLConstant:
596596
- 'lib/puppet/util/checksums.rb'
597597
- 'lib/puppet/x509/cert_provider.rb'
598598

599-
Lint/DuplicateMethods:
600-
Enabled: false
601-
602599
# This cop supports safe auto-correction (--auto-correct).
603600
Lint/ElseLayout:
604601
Exclude:

lib/puppet/application/face_base.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class Puppet::Application::FaceBase < Puppet::Application
2727
exit(0)
2828
end
2929

30-
attr_accessor :face, :action, :type, :arguments, :render_as
30+
attr_reader :render_as
31+
attr_accessor :face, :action, :type, :arguments
3132

3233
def render_as=(format)
3334
@render_as = Puppet::Network::FormatHandler.format(format)

lib/puppet/interface/action.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def __render_method_name_for(type)
141141

142142
# @api private
143143
# @return [Symbol]
144-
attr_accessor :render_as
144+
attr_reader :render_as
145145
def render_as=(value)
146146
@render_as = value.to_sym
147147
end
@@ -216,11 +216,11 @@ def deprecated?
216216

217217
# The arity of the action
218218
# @return [Integer]
219-
attr_reader :positional_arg_count
219+
attr_reader :positional_arg_count
220220

221221
# The block that is executed when the action is invoked
222222
# @return [block]
223-
attr_accessor :when_invoked
223+
attr_reader :when_invoked
224224
def when_invoked=(block)
225225

226226
internal_name = "#{@name} implementation, required on Ruby 1.8".to_sym

lib/puppet/interface/documentation.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def copyright(owner = nil, years = nil)
266266
# owners.
267267
# @return [String] Comma-separated list of copyright owners
268268
# @api private
269-
attr_accessor :copyright_owner
269+
attr_reader :copyright_owner
270270
def copyright_owner=(value)
271271
case value
272272
when String then @copyright_owner = value
@@ -283,7 +283,7 @@ def copyright_owner=(value)
283283
# copyright year or years.
284284
# @return [String]
285285
# @api private
286-
attr_accessor :copyright_years
286+
attr_reader :copyright_years
287287
def copyright_years=(value)
288288
years = munge_copyright_year value
289289
years = (years.is_a?(Array) ? years : [years]).

lib/puppet/interface/option.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,15 @@ def default
132132
@default and @default.call
133133
end
134134

135-
attr_reader :parent, :name, :aliases, :optparse
136-
attr_accessor :required
135+
attr_reader :parent, :name, :aliases, :optparse, :required
137136
def required=(value)
138137
if has_default?
139138
raise ArgumentError, _("%{name} can't be optional and have a default value") % { name: self }
140139
end
141140
@required = value
142141
end
143142

144-
attr_accessor :before_action
143+
attr_reader :before_action
145144
def before_action=(proc)
146145
unless proc.is_a? Proc
147146
#TRANSLATORS 'proc' is a Ruby block of code
@@ -152,7 +151,7 @@ def before_action=(proc)
152151
@parent.__send__(:__add_method, __decoration_name(:before), proc)
153152
end
154153

155-
attr_accessor :after_action
154+
attr_reader :after_action
156155
def after_action=(proc)
157156
unless proc.is_a? Proc
158157
#TRANSLATORS 'proc' is a Ruby block of code

lib/puppet/module.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def self.parse_range(range)
6262
SemanticPuppet::VersionRange.parse(range)
6363
end
6464

65-
attr_reader :name, :environment, :path, :metadata, :tasks, :plans
65+
attr_reader :name, :environment, :path, :metadata
6666
attr_writer :environment
6767

6868
attr_accessor :dependencies, :forge_name

lib/puppet/module/plan.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def self.plans_in_module(pup_module)
104104
end
105105
end
106106

107-
attr_reader :name, :module, :metadata_file, :metadata
107+
attr_reader :name, :module, :metadata_file
108108

109109
# file paths must be relative to the modules plan directory
110110
def initialize(pup_module, plan_name, plan_files)

lib/puppet/module/task.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def self.tasks_in_module(pup_module)
215215
end
216216
end
217217

218-
attr_reader :name, :module, :metadata_file, :metadata
218+
attr_reader :name, :module, :metadata_file
219219

220220
# file paths must be relative to the modules task directory
221221
def initialize(pup_module, task_name, module_executables, metadata_file = nil)

lib/puppet/node.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class Puppet::Node
1616
indirects :node, :terminus_setting => :node_terminus, :doc => "Where to find node information.
1717
A node is composed of its name, its facts, and its environment."
1818

19-
attr_accessor :name, :classes, :source, :ipaddress, :parameters, :trusted_data, :environment_name
20-
attr_reader :time, :facts
19+
attr_accessor :name, :classes, :source, :ipaddress, :parameters, :environment_name
20+
attr_reader :time, :facts, :trusted_data
2121

2222
attr_reader :server_facts
2323

lib/puppet/pops/functions/function.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#
1212
# @api public
1313
class Puppet::Pops::Functions::Function
14-
# The scope where the function was defined
15-
attr_reader :closure_scope
16-
1714
# The loader that loaded this function.
1815
# Should be used if function wants to load other things.
1916
#
@@ -74,6 +71,7 @@ def call_function(function_name, *args, &block)
7471
internal_call_function(closure_scope, function_name, args, &block)
7572
end
7673

74+
# The scope where the function was defined
7775
def closure_scope
7876
# If closure scope is explicitly set to not nil, if there is a global scope, otherwise an empty hash
7977
@closure_scope || Puppet.lookup(:global_scope) { {} }

0 commit comments

Comments
 (0)