(maint) RuboCop fixes.
This commit fixes a few RuboCop related failures.
This commit is contained in:
parent
cf77ef1379
commit
7897c70a52
|
@ -2,17 +2,16 @@ require 'json'
|
|||
|
||||
# The module for JSON related functionality.
|
||||
module PuppetStrings::Json
|
||||
|
||||
# Renders the current YARD registry as JSON to the given file (or STDOUT if nil).
|
||||
# @param [String] file The path to the output file to render the registry to. If nil, output will be to STDOUT.
|
||||
# @return [void]
|
||||
def self.render(file = nil)
|
||||
document = {
|
||||
puppet_classes: YARD::Registry.all(:puppet_class).sort_by! { |c| c.name }.map! { |c| c.to_hash },
|
||||
defined_types: YARD::Registry.all(:puppet_defined_type).sort_by! { |dt| dt.name }.map! { |dt| dt.to_hash },
|
||||
resource_types: YARD::Registry.all(:puppet_type).sort_by! { |t| t.name }.map! { |t| t.to_hash },
|
||||
providers: YARD::Registry.all(:puppet_provider).sort_by! { |p| p.name }.map! { |p| p.to_hash },
|
||||
puppet_functions: YARD::Registry.all(:puppet_function).sort_by! { |f| f.name }.map! { |f| f.to_hash },
|
||||
puppet_classes: YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash),
|
||||
defined_types: YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash),
|
||||
resource_types: YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash),
|
||||
providers: YARD::Registry.all(:puppet_provider).sort_by!(&:name).map!(&:to_hash),
|
||||
puppet_functions: YARD::Registry.all(:puppet_function).sort_by!(&:name).map!(&:to_hash),
|
||||
# TODO: Need Ruby documentation?
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class YARD::CLI::Yardoc
|
|||
:puppet_defined_type,
|
||||
:puppet_type,
|
||||
:puppet_provider,
|
||||
:puppet_function,
|
||||
:puppet_function
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -76,11 +76,12 @@ class YARD::CLI::Stats
|
|||
# Monkey patch output to accommodate our larger header widths
|
||||
@total += data if data.is_a?(Integer) && undoc
|
||||
@undocumented += undoc if undoc.is_a?(Integer)
|
||||
if undoc
|
||||
data = ('%5s (% 5d undocumented)' % [data, undoc])
|
||||
else
|
||||
data = '%5s' % data
|
||||
end
|
||||
data =
|
||||
if undoc
|
||||
('%5s (% 5d undocumented)' % [data, undoc])
|
||||
else
|
||||
'%5s' % data
|
||||
end
|
||||
log.puts('%-21s %s' % [name + ':', data])
|
||||
end
|
||||
|
||||
|
|
|
@ -138,9 +138,9 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects:
|
|||
hash[:file] = file
|
||||
hash[:line] = line
|
||||
hash[:docstring] = PuppetStrings::Json.docstring_to_hash(docstring)
|
||||
hash[:properties] = properties.map { |p| p.to_hash } if properties && !properties.empty?
|
||||
hash[:parameters] = parameters.map { |p| p.to_hash } if parameters && !parameters.empty?
|
||||
hash[:features] = features.map { |f| f.to_hash } if features && !features.empty?
|
||||
hash[:properties] = properties.map(&:to_hash) if properties && !properties.empty?
|
||||
hash[:parameters] = parameters.map(&:to_hash) if parameters && !parameters.empty?
|
||||
hash[:features] = features.map(&:to_hash) if features && !features.empty?
|
||||
hash
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,9 +57,10 @@ class PuppetStrings::Yard::Handlers::Ruby::ProviderHandler < PuppetStrings::Yard
|
|||
return nil
|
||||
elsif child.is_a?(YARD::Parser::Ruby::MethodCallNode)
|
||||
# Look for a call to a dispatch method with a block
|
||||
next unless child.method_name &&
|
||||
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
|
||||
child.parameters(false).count == 1
|
||||
next unless
|
||||
child.method_name &&
|
||||
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
|
||||
child.parameters(false).count == 1
|
||||
|
||||
docstring = node_as_string(child.parameters[0])
|
||||
log.error "Failed to parse docstring for Puppet provider '#{object.name}' (resource type '#{object.type_name}') near #{child.file}:#{child.line}." and return nil unless docstring
|
||||
|
|
|
@ -80,7 +80,7 @@ Puppet::Face.define(:strings, '0.0.1') do
|
|||
def check_required_features
|
||||
raise RuntimeError, "The 'yard' gem must be installed in order to use this face." unless Puppet.features.yard?
|
||||
raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." unless Puppet.features.rgen?
|
||||
raise RuntimeError, 'This face requires Ruby 1.9 or greater.' if RUBY_VERSION.match(/^1\.8/)
|
||||
raise RuntimeError, 'This face requires Ruby 1.9 or greater.' if RUBY_VERSION =~ /^1\.8/
|
||||
end
|
||||
|
||||
# Builds the options to PuppetStrings.generate.
|
||||
|
|
|
@ -6,7 +6,6 @@ unless ENV['RS_PROVISION'] == 'no'
|
|||
end
|
||||
|
||||
RSpec.configure do |c|
|
||||
|
||||
# Readable test descriptions
|
||||
c.formatter = :documentation
|
||||
|
||||
|
|
Loading…
Reference in New Issue