Skip to content

Commit 1b30b4d

Browse files
committed
(MAINT) Rubocop: Fix Layout/EmptyLineAfterGuardClause
1 parent a76d361 commit 1b30b4d

File tree

22 files changed

+73
-0
lines changed

22 files changed

+73
-0
lines changed

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ namespace :litmus do
9595
`gem build puppet-strings.gemspec --quiet`
9696
result = $CHILD_STATUS
9797
raise "Unable to build the puppet-strings gem. Returned exit code #{result.exitstatus}" unless result.exitstatus.zero?
98+
9899
puts 'Built'
99100
# Find the gem build artifact
100101
gem_tar = Dir.glob('puppet-strings-*.gem').max_by { |f| File.mtime(f) }
101102
raise "Unable to find package in 'puppet-strings-*.gem'" if gem_tar.nil?
103+
102104
gem_tar = File.expand_path(gem_tar)
103105

104106
target_string = if args[:target_node_name].nil?

lib/puppet-strings/tasks/gh_pages.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
task :checkout do
88
if Dir.exist?('doc')
99
fail "The 'doc' directory (#{File.expand_path('doc')}) is not a Git repository! Remove it and run the Rake task again." unless Dir.exist?('doc/.git')
10+
1011
Dir.chdir('doc') do
1112
system 'git checkout gh-pages'
1213
system 'git pull --rebase origin gh-pages'

lib/puppet-strings/yard.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def stats_for_puppet_tasks
104104

105105
def stats_for_puppet_plans
106106
return unless PuppetStrings.puppet_5?
107+
107108
output 'Puppet Plans', *type_statistics_all(:puppet_plan)
108109
end
109110

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def function_type
6363
# @return [String] Returns the Puppet signature of the function.
6464
def signature
6565
return '' if self.has_tag? :overload
66+
6667
tags = self.tags(:param)
6768
args = @parameters.map do |parameter|
6869
name, default = parameter

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class PuppetStrings::Yard::CodeObjects::Group < PuppetStrings::Yard::CodeObjects
1212
def self.instance(key)
1313
instance = P(:root, key)
1414
return instance unless instance.is_a?(YARD::CodeObjects::Proxy)
15+
1516
instance = self.new(:root, key)
1617
instance.visibility = :hidden
1718
P(:root).children << instance

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def type
4444
# @return [void]
4545
def add_confine(key, value)
4646
return unless key && value
47+
4748
@confines ||= {}
4849
@confines[key] = value
4950
end
@@ -53,6 +54,7 @@ def add_confine(key, value)
5354
# @return [void]
5455
def add_feature(feature)
5556
return unless feature
57+
5658
@features ||= []
5759
@features << feature
5860
end
@@ -62,6 +64,7 @@ def add_feature(feature)
6264
# @return [void]
6365
def add_default(constraints)
6466
return unless constraints
67+
6568
@defaults ||= []
6669
@defaults << constraints
6770
end
@@ -72,6 +75,7 @@ def add_default(constraints)
7275
# @return [void]
7376
def add_command(key, value)
7477
return unless key && value
78+
7579
@commands ||= {}
7680
@commands[key] = value
7781
end

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def parameters
169169
def providers
170170
providers = YARD::Registry.all("puppet_providers_#{name}".intern)
171171
return providers if providers.empty?
172+
172173
providers.first.children
173174
end
174175

lib/puppet-strings/yard/handlers/puppet/base.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def set_parameter_types(object)
1919
tags = object.tags(:param)
2020
tags.each do |tag|
2121
next if statement.parameters.find { |p| tag.name == p.name }
22+
2223
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}." unless tag.name == 'name' || tag.name == 'title'
2324
end
2425

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class PuppetStrings::Yard::Handlers::Ruby::Base < YARD::Handlers::Ruby::Base
1414
# @return [String] Returns a string representation of the node or nil if a string representation was not possible.
1515
def node_as_string(node)
1616
return nil unless node
17+
1718
case node.type
1819
when :symbol, :symbol_literal
1920
node.source[1..-1]
@@ -44,8 +45,10 @@ def node_as_string(node)
4445
def get_name(statementobject, statementtype)
4546
parameters = statementobject.parameters(false)
4647
raise YARD::Parser::UndocumentableError, "Expected at least one parameter to #{statementtype} at #{statementobject.file}:#{statementobject.line}." if parameters.empty?
48+
4749
name = node_as_string(parameters.first)
4850
raise YARD::Parser::UndocumentableError, "Expected a symbol or string literal for first parameter but found '#{parameters.first.type}' at #{statement.file}:#{statement.line}." unless name
51+
4952
name
5053
end
5154
end

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
1212

1313
process do
1414
return unless statement.count > 1
15+
1516
ruby_module_name = statement[0].source
1617
return unless ruby_module_name == 'Puppet::DataTypes' || ruby_module_name == 'DataTypes' # rubocop:disable Style/MultipleComparison This reads better
18+
1719
object = get_datatype_yard_object(get_name(statement, 'Puppet::DataTypes.create_type'))
1820
# Extract the interface definition
1921
type_interface = extract_data_type_interface
@@ -67,8 +69,10 @@ def extract_data_type_interface
6769
next false unless node.is_a?(YARD::Parser::Ruby::MethodCallNode) &&
6870
node.method_name &&
6971
node.method_name.source == 'interface'
72+
7073
parameters = node.parameters(false)
7174
next false unless parameters.count >= 1
75+
7276
interface_string = node_as_string(parameters[0])
7377
next false unless interface_string
7478

@@ -99,8 +103,10 @@ def extract_data_type_interface
99103
# @return [YARD::Parser::Ruby::AstNode, nil]
100104
def find_ruby_ast_node(ast_node, recurse = false, &block)
101105
raise ArgumentError, 'find_ruby_ast_node requires a block' unless block_given?
106+
102107
is_found = yield ast_node
103108
return ast_node if is_found
109+
104110
if ast_node.respond_to?(:children)
105111
ast_node.children.each do |child_node|
106112
child_found = find_ruby_ast_node(child_node, recurse, &block)
@@ -277,8 +283,10 @@ def validate_param_tags!(object, actual_params_hash)
277283
# Find param tags with a type that is different from the actual definition
278284
object.tags(:param).reject { |tag| tag.types.nil? }.each do |tag|
279285
next if actual_params_hash[tag.name].nil?
286+
280287
actual_data_type = actual_params_hash[tag.name][:types]
281288
next if actual_data_type.nil?
289+
282290
log.warn "The @param tag for '#{tag.name}' has a different type definition than the actual attribute near #{object.file}:#{object.line}." if tag.types != actual_data_type
283291
end
284292

@@ -292,6 +300,7 @@ def validate_param_tags!(object, actual_params_hash)
292300
# Set the type in the param tag
293301
object.tags(:param).each do |tag|
294302
next if actual_params_hash[tag.name].nil?
303+
295304
tag.types = actual_params_hash[tag.name][:types]
296305
end
297306
end
@@ -313,10 +322,13 @@ def validate_methods!(object, actual_functions_hash)
313322
# Functions with the wrong return type
314323
object.meths.each do |meth|
315324
next unless actual_func_names.include?(meth.name.to_s)
325+
316326
return_tag = meth.docstring.tag(:return)
317327
next if return_tag.nil?
328+
318329
actual_return_types = [actual_functions_hash[meth.name.to_s][:return_type]]
319330
next if return_tag.types == actual_return_types
331+
320332
log.warn "The @return tag for '#{meth.name}' has a different type definition than the actual function near #{object.file}:#{object.line}. Expected #{actual_return_types}"
321333
return_tag.types = actual_return_types
322334
end
@@ -331,13 +343,15 @@ def validate_methods!(object, actual_functions_hash)
331343
# Add the return type for the methods if missing
332344
object.meths.each do |meth|
333345
next unless meth.docstring.tag(:return).nil?
346+
334347
meth.docstring.add_tag(YARD::Tags::Tag.new(:return, '', actual_functions_hash[meth.name.to_s][:return_type]))
335348
end
336349

337350
# Sync the method properties and add the return type for the methods if missing
338351
object.meths.each do |meth|
339352
validate_function_method!(object, meth, actual_functions_hash[meth.name.to_s])
340353
next unless meth.docstring.tag(:return).nil?
354+
341355
meth.docstring.add_tag(YARD::Tags::Tag.new(:return, '', actual_functions_hash[meth.name.to_s][:return_type]))
342356
end
343357

0 commit comments

Comments
 (0)