From ca1498e26a225d85fbb9b9e5d8157825aec8e9ce Mon Sep 17 00:00:00 2001 From: Gavin Didrichsen Date: Thu, 20 Jun 2024 12:22:00 +0100 Subject: [PATCH] Fix rubocop warnings Signed-off-by: Gavin Didrichsen --- lib/puppet-strings/yard/code_objects/task.rb | 12 +++++------- .../yard/handlers/ruby/provider_handler.rb | 5 ++--- lib/puppet-strings/yard/parsers/puppet/statement.rb | 12 ++++++------ lib/puppet-strings/yard/tags/overload_tag.rb | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/puppet-strings/yard/code_objects/task.rb b/lib/puppet-strings/yard/code_objects/task.rb index a94ff8d6b..e1f8cb320 100644 --- a/lib/puppet-strings/yard/code_objects/task.rb +++ b/lib/puppet-strings/yard/code_objects/task.rb @@ -44,14 +44,12 @@ def source end def parameters - parameters = [] - statement.parameters.each do |name, props| - parameters.push({ name: name.to_s, - tag_name: 'param', - text: props['description'] || '', - types: [props['type']] || '' }) + statement.parameters.map do |name, props| + { name: name.to_s, + tag_name: 'param', + text: props['description'] || '', + types: [props['type']] || '' } end - parameters end # Converts the code object to a hash representation. diff --git a/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb b/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb index 8f16f9919..9ce6213a7 100644 --- a/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb @@ -107,9 +107,8 @@ def populate_provider_data(object) parameters.each do |kvps| next unless kvps.count >= 1 - defaultfor = [] - kvps.each do |kvp| - defaultfor << [node_as_string(kvp[0]) || kvp[0].source, node_as_string(kvp[1]) || kvp[1].source] + defaultfor = kvps.map do |kvp| + [node_as_string(kvp[0]) || kvp[0].source, node_as_string(kvp[1]) || kvp[1].source] end object.add_default(defaultfor) end diff --git a/lib/puppet-strings/yard/parsers/puppet/statement.rb b/lib/puppet-strings/yard/parsers/puppet/statement.rb index 07102494d..f61568e85 100644 --- a/lib/puppet-strings/yard/parsers/puppet/statement.rb +++ b/lib/puppet-strings/yard/parsers/puppet/statement.rb @@ -92,7 +92,7 @@ def initialize(parameter) # @param object The Puppet parser model object that has parameters. # @param [String] file The file containing the statement. def initialize(object, file) - super(object, file) + super @parameters = object.parameters.map { |parameter| Parameter.new(parameter) } end end @@ -105,7 +105,7 @@ class ClassStatement < ParameterizedStatement # @param [Puppet::Pops::Model::HostClassDefinition] object The model object for the class statement. # @param [String] file The file containing the statement. def initialize(object, file) - super(object, file) + super @name = object.name @parent_class = object.parent_class end @@ -119,7 +119,7 @@ class DefinedTypeStatement < ParameterizedStatement # @param [Puppet::Pops::Model::ResourceTypeDefinition] object The model object for the defined type statement. # @param [String] file The file containing the statement. def initialize(object, file) - super(object, file) + super @name = object.name end end @@ -132,7 +132,7 @@ class FunctionStatement < ParameterizedStatement # @param [Puppet::Pops::Model::FunctionDefinition] object The model object for the function statement. # @param [String] file The file containing the statement. def initialize(object, file) - super(object, file) + super @name = object.name return unless object.respond_to? :return_type @@ -151,7 +151,7 @@ class PlanStatement < ParameterizedStatement # @param [Puppet::Pops::Model::PlanDefinition] object The model object for the plan statement. # @param [String] file The file containing the statement. def initialize(object, file) - super(object, file) + super @name = object.name end end @@ -164,7 +164,7 @@ class DataTypeAliasStatement < Statement # @param [Puppet::Pops::Model::TypeAlias] object The model object for the type statement. # @param [String] file The file containing the statement. def initialize(object, file) - super(object, file) + super type_expr = object.type_expr case type_expr diff --git a/lib/puppet-strings/yard/tags/overload_tag.rb b/lib/puppet-strings/yard/tags/overload_tag.rb index 8ae294250..04d0431fb 100644 --- a/lib/puppet-strings/yard/tags/overload_tag.rb +++ b/lib/puppet-strings/yard/tags/overload_tag.rb @@ -65,7 +65,7 @@ def has_tag?(name) # rubocop:disable Naming/PredicateName # @param [Object] value The object to associate with this tag. # @return [void] def object=(value) - super(value) + super @docstring.object = value @docstring.tags.each { |tag| tag.object = value } end