(maint) RuboCop fixes.

This commit fixes a few RuboCop related failures.
This commit is contained in:
Peter Huene 2016-09-14 13:14:53 -07:00
parent cf77ef1379
commit 7897c70a52
No known key found for this signature in database
GPG Key ID: 6B585C1742BE3C3C
6 changed files with 20 additions and 20 deletions

View File

@ -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?
}

View File

@ -43,7 +43,7 @@ class YARD::CLI::Yardoc
:puppet_defined_type,
:puppet_type,
:puppet_provider,
:puppet_function,
:puppet_function
)
end
end
@ -76,10 +76,11 @@ 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)
data =
if undoc
data = ('%5s (% 5d undocumented)' % [data, undoc])
('%5s (% 5d undocumented)' % [data, undoc])
else
data = '%5s' % data
'%5s' % data
end
log.puts('%-21s %s' % [name + ':', data])
end

View File

@ -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

View File

@ -57,7 +57,8 @@ 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 &&
next unless
child.method_name &&
(child.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
child.parameters(false).count == 1

View File

@ -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.

View File

@ -6,7 +6,6 @@ unless ENV['RS_PROVISION'] == 'no'
end
RSpec.configure do |c|
# Readable test descriptions
c.formatter = :documentation