Skip to content

Commit e142382

Browse files
committed
(MAINT) Rubocop: Fix remaining rubocop warnings
1 parent 8c7587e commit e142382

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

lib/puppet-strings/yard/code_objects/class.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def to_hash
5454
hash[:inherits] = statement.parent_class if statement.parent_class
5555
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
5656
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
57-
hash[:defaults] = defaults unless defaults.empty?
58-
hash[:source] = source unless source&.empty?
57+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
58+
hash[:source] = source unless source.nil? || source.empty?
5959
hash
6060
end
6161
end

lib/puppet-strings/yard/code_objects/data_type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def to_hash
8888
hash[:file] = file
8989
hash[:line] = line
9090
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example])
91-
hash[:defaults] = defaults unless defaults.empty?
92-
hash[:source] = source unless source&.empty?
91+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
92+
hash[:source] = source unless source.nil? || source.empty?
9393
hash[:functions] = functions.map do |func|
9494
{
9595
name: func.name,

lib/puppet-strings/yard/code_objects/defined_type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def to_hash
5353
hash[:line] = line
5454
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
5555
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
56-
hash[:defaults] = defaults unless defaults.empty?
57-
hash[:source] = source unless source&.empty?
56+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
57+
hash[:source] = source unless source.nil? || source.empty?
5858
hash
5959
end
6060
end

lib/puppet-strings/yard/code_objects/function.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def to_hash
9999

100100
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
101101
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
102-
hash[:defaults] = defaults unless defaults.empty?
103-
hash[:source] = source unless source&.empty?
102+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
103+
hash[:source] = source unless source.nil? || source.empty?
104104
hash
105105
end
106106
end

lib/puppet-strings/yard/code_objects/plan.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def to_hash
5151
hash[:line] = line
5252
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
5353
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
54-
hash[:defaults] = defaults unless defaults.empty?
55-
hash[:source] = source unless source&.empty?
54+
hash[:defaults] = defaults unless defaults.nil? || defaults.empty?
55+
hash[:source] = source unless source.nil? || source.empty?
5656
hash
5757
end
5858
end

lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def find_ruby_ast_node(ast_node, recurse = false, &block)
136136
# Anything else is ignored
137137
class LazyLiteralEvaluator
138138
def initialize
139-
@literal_visitor ||= ::Puppet::Pops::Visitor.new(self, "literal", 0, 0)
139+
@literal_visitor = ::Puppet::Pops::Visitor.new(self, "literal", 0, 0)
140140
end
141141

142142
def literal(ast)

lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PuppetStrings::Yard::Handlers::Ruby::TypeExtrasHandler < PuppetStrings::Ya
3636

3737
module_name = statement[0].children[0].source
3838
method1_name = statement[0].children.drop(1).find{ |c| c.type == :ident }.source
39-
return unless (module_name == 'Puppet::Type' || module_name == 'Type') && method1_name == 'type'
39+
return unless ['Type', 'Puppet::Type'].include?(module_name) && method1_name == 'type'
4040

4141
typename = get_name(statement[0], 'Puppet::Type.type')
4242
method2_name = caller_method

0 commit comments

Comments
 (0)