(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. # The module for JSON related functionality.
module PuppetStrings::Json module PuppetStrings::Json
# Renders the current YARD registry as JSON to the given file (or STDOUT if nil). # 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. # @param [String] file The path to the output file to render the registry to. If nil, output will be to STDOUT.
# @return [void] # @return [void]
def self.render(file = nil) def self.render(file = nil)
document = { document = {
puppet_classes: YARD::Registry.all(:puppet_class).sort_by! { |c| c.name }.map! { |c| c.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! { |dt| dt.name }.map! { |dt| dt.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! { |t| t.name }.map! { |t| t.to_hash }, resource_types: YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash),
providers: YARD::Registry.all(:puppet_provider).sort_by! { |p| p.name }.map! { |p| p.to_hash }, providers: YARD::Registry.all(:puppet_provider).sort_by!(&:name).map!(&:to_hash),
puppet_functions: YARD::Registry.all(:puppet_function).sort_by! { |f| f.name }.map! { |f| f.to_hash }, puppet_functions: YARD::Registry.all(:puppet_function).sort_by!(&:name).map!(&:to_hash),
# TODO: Need Ruby documentation? # TODO: Need Ruby documentation?
} }

View File

@ -43,7 +43,7 @@ class YARD::CLI::Yardoc
:puppet_defined_type, :puppet_defined_type,
:puppet_type, :puppet_type,
:puppet_provider, :puppet_provider,
:puppet_function, :puppet_function
) )
end end
end end
@ -76,10 +76,11 @@ class YARD::CLI::Stats
# Monkey patch output to accommodate our larger header widths # Monkey patch output to accommodate our larger header widths
@total += data if data.is_a?(Integer) && undoc @total += data if data.is_a?(Integer) && undoc
@undocumented += undoc if undoc.is_a?(Integer) @undocumented += undoc if undoc.is_a?(Integer)
data =
if undoc if undoc
data = ('%5s (% 5d undocumented)' % [data, undoc]) ('%5s (% 5d undocumented)' % [data, undoc])
else else
data = '%5s' % data '%5s' % data
end end
log.puts('%-21s %s' % [name + ':', data]) log.puts('%-21s %s' % [name + ':', data])
end end

View File

@ -138,9 +138,9 @@ class PuppetStrings::Yard::CodeObjects::Type < PuppetStrings::Yard::CodeObjects:
hash[:file] = file hash[:file] = file
hash[:line] = line hash[:line] = line
hash[:docstring] = PuppetStrings::Json.docstring_to_hash(docstring) hash[:docstring] = PuppetStrings::Json.docstring_to_hash(docstring)
hash[:properties] = properties.map { |p| p.to_hash } if properties && !properties.empty? hash[:properties] = properties.map(&:to_hash) if properties && !properties.empty?
hash[:parameters] = parameters.map { |p| p.to_hash } if parameters && !parameters.empty? hash[:parameters] = parameters.map(&:to_hash) if parameters && !parameters.empty?
hash[:features] = features.map { |f| f.to_hash } if features && !features.empty? hash[:features] = features.map(&:to_hash) if features && !features.empty?
hash hash
end end
end end

View File

@ -57,7 +57,8 @@ class PuppetStrings::Yard::Handlers::Ruby::ProviderHandler < PuppetStrings::Yard
return nil return nil
elsif child.is_a?(YARD::Parser::Ruby::MethodCallNode) elsif child.is_a?(YARD::Parser::Ruby::MethodCallNode)
# Look for a call to a dispatch method with a block # 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.method_name.source == 'desc' || child.method_name.source == 'doc=') &&
child.parameters(false).count == 1 child.parameters(false).count == 1

View File

@ -80,7 +80,7 @@ Puppet::Face.define(:strings, '0.0.1') do
def check_required_features 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 '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, "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 end
# Builds the options to PuppetStrings.generate. # Builds the options to PuppetStrings.generate.

View File

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