From e29c713298f4690f25aa2b6a920ba930e53c31b8 Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Wed, 19 Jun 2019 15:33:46 +0800 Subject: [PATCH 1/5] (maint) Update rubocop rules with correct names Many of the rubocop rules have changed names or are now redundant. This commit updates the rubocop.yml to be correct for rubocop v0.57.2 --- .rubocop.yml | 127 ++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 67 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 52d151a24..89706d973 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ Bundler/OrderedGems: Bundler/DuplicatedGem: Enabled: false -Lint/ConditionPosition: +Layout/ConditionPosition: Enabled: true Lint/ElseLayout: @@ -32,10 +32,6 @@ Lint/EnsureReturn: Lint/HandleExceptions: Enabled: false -# MAYBE useful - catches while 1 -Lint/LiteralInCondition: - Enabled: false - # MAYBE useful - but too many instances Lint/ShadowingOuterLocalVariable: Enabled: false @@ -56,7 +52,7 @@ Lint/AssignmentInCondition: Enabled: true # DISABLED - not useful -Style/SpaceBeforeComment: +Layout/SpaceBeforeComment: Enabled: false # DISABLED - not useful @@ -92,15 +88,15 @@ Lint/AmbiguousRegexpLiteral: Enabled: false # DISABLED -Lint/BlockAlignment: +Layout/BlockAlignment: Enabled: false # DISABLED -Lint/DefEndAlignment: +Layout/DefEndAlignment: Enabled: false # DISABLED -Lint/EndAlignment: +Layout/EndAlignment: Enabled: false # DISABLED @@ -130,28 +126,25 @@ Lint/UnusedMethodArgument: Lint/UselessAccessModifier: Enabled: true -Lint/UselessAssignment: - Enabled: true - Lint/Void: Enabled: true -Style/AccessModifierIndentation: +Layout/AccessModifierIndentation: Enabled: false -Style/AccessorMethodName: +Naming/AccessorMethodName: Enabled: false Style/Alias: Enabled: false -Style/AlignArray: +Layout/AlignArray: Enabled: false -Style/AlignHash: +Layout/AlignHash: Enabled: false -Style/AlignParameters: +Layout/AlignParameters: Enabled: false Metrics/BlockNesting: @@ -169,13 +162,13 @@ Style/BracesAroundHashParameters: Style/CaseEquality: Enabled: false -Style/CaseIndentation: +Layout/CaseIndentation: Enabled: false Style/CharacterLiteral: Enabled: false -Style/ClassAndModuleCamelCase: +Naming/ClassAndModuleCamelCase: Enabled: false Style/ClassAndModuleChildren: @@ -203,67 +196,64 @@ Style/WordArray: Style/UnneededPercentQ: Enabled: false -Style/Tab: +Layout/Tab: Enabled: false -Style/SpaceBeforeSemicolon: +Layout/SpaceBeforeSemicolon: Enabled: false -Style/TrailingBlankLines: +Layout/TrailingBlankLines: Enabled: false -Style/SpaceInsideBlockBraces: +Layout/SpaceInsideBlockBraces: Enabled: false -Style/SpaceInsideBrackets: +Layout/SpaceInsideHashLiteralBraces: Enabled: false -Style/SpaceInsideHashLiteralBraces: +Layout/SpaceInsideParens: Enabled: false -Style/SpaceInsideParens: +Layout/LeadingCommentSpace: Enabled: false -Style/LeadingCommentSpace: +Layout/SpaceBeforeFirstArg: Enabled: false -Style/SpaceBeforeFirstArg: +Layout/SpaceAfterColon: Enabled: false -Style/SpaceAfterColon: +Layout/SpaceAfterComma: Enabled: false -Style/SpaceAfterComma: +Layout/SpaceAroundKeyword: Enabled: false -Style/SpaceAroundKeyword: +Layout/SpaceAfterMethodName: Enabled: false -Style/SpaceAfterMethodName: +Layout/SpaceAfterNot: Enabled: false -Style/SpaceAfterNot: +Layout/SpaceAfterSemicolon: Enabled: false -Style/SpaceAfterSemicolon: +Layout/SpaceAroundEqualsInParameterDefault: Enabled: false -Style/SpaceAroundEqualsInParameterDefault: +Layout/SpaceAroundOperators: Enabled: false -Style/SpaceAroundOperators: +Layout/SpaceBeforeBlockBraces: Enabled: false -Style/SpaceBeforeBlockBraces: - Enabled: false - -Style/SpaceBeforeComma: +Layout/SpaceBeforeComma: Enabled: false Style/CollectionMethods: Enabled: false -Style/CommentIndentation: +Layout/CommentIndentation: Enabled: false Style/ColonMethodCall: @@ -275,7 +265,7 @@ Style/CommentAnnotation: Metrics/CyclomaticComplexity: Enabled: false -Style/ConstantName: +Naming/ConstantName: Enabled: false Style/Documentation: @@ -284,7 +274,7 @@ Style/Documentation: Style/DefWithParentheses: Enabled: false -Style/DotPosition: +Layout/DotPosition: Enabled: false # DISABLED - used for converting to bool @@ -294,25 +284,25 @@ Style/DoubleNegation: Style/EachWithObject: Enabled: false -Style/EmptyLineBetweenDefs: +Layout/EmptyLineBetweenDefs: Enabled: false -Style/IndentArray: +Layout/IndentArray: Enabled: false -Style/IndentHash: +Layout/IndentHash: Enabled: false -Style/IndentationConsistency: +Layout/IndentationConsistency: Enabled: true -Style/IndentationWidth: +Layout/IndentationWidth: Enabled: true -Style/EmptyLines: +Layout/EmptyLines: Enabled: false -Style/EmptyLinesAroundAccessModifier: +Layout/EmptyLinesAroundAccessModifier: Enabled: false Style/EmptyLiteral: @@ -330,13 +320,16 @@ Style/MethodDefParentheses: Style/LineEndConcatenation: Enabled: false -Style/TrailingWhitespace: +Layout/TrailingWhitespace: Enabled: false Style/StringLiterals: Enabled: false -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: + Enabled: false + +Style/TrailingCommaInHashLiteral: Enabled: false Style/TrailingCommaInArguments: @@ -381,7 +374,7 @@ Style/UnlessElse: Style/VariableInterpolation: Enabled: false -Style/VariableName: +Naming/VariableName: Enabled: false Style/WhileUntilDo: @@ -390,7 +383,7 @@ Style/WhileUntilDo: Style/EvenOdd: Enabled: false -Style/FileName: +Naming/FileName: Enabled: false Style/For: @@ -399,7 +392,7 @@ Style/For: Style/Lambda: Enabled: false -Style/MethodName: +Naming/MethodName: Enabled: false Style/MultilineTernaryOperator: @@ -435,7 +428,7 @@ Style/NumericLiterals: Style/OneLineConditional: Enabled: false -Style/OpMethod: +Naming/BinaryOperatorParameterName: Enabled: false Style/ParenthesesAroundCondition: @@ -447,7 +440,7 @@ Style/PercentLiteralDelimiters: Style/PerlBackrefs: Enabled: false -Style/PredicateName: +Naming/PredicateName: Enabled: false Style/RedundantException: @@ -492,22 +485,22 @@ Style/IfWithSemicolon: Style/Encoding: Enabled: false -Style/MultilineOperationIndentation: +Layout/MultilineOperationIndentation: Enabled: false Style/BlockDelimiters: Enabled: false -Style/ExtraSpacing: +Layout/ExtraSpacing: Enabled: false -Style/MultilineHashBraceLayout: +Layout/MultilineHashBraceLayout: Enabled: false -Style/MultilineMethodCallBraceLayout: +Layout/MultilineMethodCallBraceLayout: Enabled: false -Style/MultilineBlockLayout: +Layout/MultilineBlockLayout: Enabled: false Lint/UselessAssignment: @@ -516,16 +509,16 @@ Lint/UselessAssignment: Lint/DuplicateMethods: Enabled: false -Style/EmptyLinesAroundMethodBody: +Layout/EmptyLinesAroundMethodBody: Enabled: false -Style/EmptyLinesAroundModuleBody: +Layout/EmptyLinesAroundModuleBody: Enabled: false -Style/EmptyLinesAroundBlockBody: +Layout/EmptyLinesAroundBlockBody: Enabled: false -Style/EmptyLinesAroundClassBody: +Layout/EmptyLinesAroundClassBody: Enabled: false Style/UnneededInterpolation: @@ -570,5 +563,5 @@ Metrics/PerceivedComplexity: Metrics/BlockLength: Enabled: false -Style/VariableNumber: +Naming/VariableNumber: Enabled: false From 4226e295f53e1294fc37d2012df2c4277e2672d9 Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Wed, 19 Jun 2019 16:07:17 +0800 Subject: [PATCH 2/5] (maint) Allow rubocop to be used on Windows Rubocop only expects CRLF line endings on Windows, however this project is LF. This commit enforces LF as the line-ending no matter what OS. --- .rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 89706d973..2384c1171 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -565,3 +565,7 @@ Metrics/BlockLength: Naming/VariableNumber: Enabled: false + +# Enforce LF line endings, even when on Windows +Layout/EndOfLine: + EnforcedStyle: lf From 3bdf503090d2490f9ce5f6ca2aa61377cfe8d5ef Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Wed, 19 Jun 2019 15:55:28 +0800 Subject: [PATCH 3/5] (maint) Fix basic Rubocop violations This commit fixes most of the simple rubocop violations (indentation, whitespace arrays of symbols) and adds a Rubocop TODO file for the remainder. Later commits will fix the TODO items and the file can be removed. --- .rubocop.yml | 5 ++ .rubocop_todo.yml | 71 +++++++++++++++++++ lib/puppet-strings/markdown/function.rb | 4 +- lib/puppet-strings/tasks/generate.rb | 5 +- lib/puppet-strings/yard/code_objects/class.rb | 2 +- .../yard/code_objects/defined_type.rb | 2 +- .../yard/code_objects/function.rb | 6 +- lib/puppet-strings/yard/code_objects/plan.rb | 2 +- .../yard/handlers/ruby/function_handler.rb | 4 +- .../yard/handlers/ruby/rsapi_handler.rb | 4 +- .../yard/handlers/ruby/type_base.rb | 11 ++- .../yard/parsers/json/parser.rb | 2 +- .../yard/parsers/puppet/parser.rb | 15 ++-- lib/puppet-strings/yard/tags/overload_tag.rb | 2 +- lib/puppet/face/strings.rb | 6 +- spec/acceptance/generate_markdown_spec.rb | 2 +- spec/unit/puppet-strings/describe_spec.rb | 14 ++-- spec/unit/puppet-strings/json_spec.rb | 10 +-- .../unit/puppet-strings/markdown/base_spec.rb | 6 +- spec/unit/puppet-strings/markdown_spec.rb | 10 +-- .../yard/code_objects/task_spec.rb | 2 +- .../yard/handlers/json/task_handler_spec.rb | 8 +-- .../handlers/puppet/class_handler_spec.rb | 16 ++--- .../puppet/defined_type_handler_spec.rb | 16 ++--- .../handlers/puppet/function_handler_spec.rb | 26 +++---- .../handlers/ruby/function_handler_spec.rb | 38 +++++----- .../handlers/ruby/provider_handler_spec.rb | 14 ++-- .../yard/handlers/ruby/rsapi_handler_spec.rb | 14 ++-- .../yard/handlers/ruby/type_handler_spec.rb | 20 +++--- .../yard/parsers/json/task_statement_spec.rb | 4 +- spec/unit/puppet-strings/yard/util_spec.rb | 2 +- 31 files changed, 209 insertions(+), 134 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 2384c1171..5ce9b6d30 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +inherit_from: .rubocop_todo.yml + AllCops: Exclude: # Ignore HTML related things @@ -569,3 +571,6 @@ Naming/VariableNumber: # Enforce LF line endings, even when on Windows Layout/EndOfLine: EnforcedStyle: lf + +Layout/IndentHeredoc: # Not appicable on Ruby 2.1 + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..7b906851e --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,71 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2019-06-19 16:03:20 +0800 using RuboCop version 0.57.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'puppet-strings.gemspec' + +# Offense count: 108 +# Cop supports --auto-correct. +Layout/ClosingHeredocIndentation: + Enabled: false + +# Offense count: 5 +# Configuration parameters: Blacklist. +# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +Naming/HeredocDelimiterNaming: + Exclude: + - 'spec/acceptance/generate_markdown_spec.rb' + - 'spec/acceptance/lib/util.rb' + +# Offense count: 2 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: inline, group +Style/AccessModifierDeclarations: + Exclude: + - 'spec/acceptance/lib/util.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'puppet-strings.gemspec' + +# Offense count: 6 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: annotated, template, unannotated +Style/FormatStringToken: + Exclude: + - 'lib/puppet-strings/describe.rb' + - 'lib/puppet-strings/yard.rb' + +# Offense count: 3 +Style/MixinUsage: + Exclude: + - 'spec/acceptance/emit_json_options.rb' + - 'spec/acceptance/generate_markdown_spec.rb' + - 'spec/acceptance/running_strings_generate.rb' + +# Offense count: 3 +Style/MultipleComparison: + Exclude: + - 'lib/puppet-strings/yard/handlers/ruby/function_handler.rb' + - 'lib/puppet-strings/yard/handlers/ruby/provider_handler.rb' + - 'lib/puppet-strings/yard/handlers/ruby/type_handler.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: . +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: percent + MinSize: 5 diff --git a/lib/puppet-strings/markdown/function.rb b/lib/puppet-strings/markdown/function.rb index 5680d9ef7..9da691627 100644 --- a/lib/puppet-strings/markdown/function.rb +++ b/lib/puppet-strings/markdown/function.rb @@ -30,11 +30,11 @@ def type end end - def error_type(r) + def error_type(r) # rubocop:disable Naming/UncommunicativeMethodParamName "`#{r.split(' ')[0]}`" end - def error_text(r) + def error_text(r) # rubocop:disable Naming/UncommunicativeMethodParamName "#{r.split(' ').drop(1).join(' ')}" end end diff --git a/lib/puppet-strings/tasks/generate.rb b/lib/puppet-strings/tasks/generate.rb index c8ecb1a84..228fd82e5 100644 --- a/lib/puppet-strings/tasks/generate.rb +++ b/lib/puppet-strings/tasks/generate.rb @@ -33,11 +33,12 @@ def parse_format_option(args, options, format) end end end + # rubocop:enable Style/PreferredHashMethods - [:json,:markdown].each { |format| parse_format_option(args, options, format) } + %i[json markdown].each { |format| parse_format_option(args, options, format) } warn('yard_args behavior is a little dodgy, use at your own risk') if args[:yard_args] - options[:yard_args] = args[:yard_args].split if args.has_key? :yard_args + options[:yard_args] = args[:yard_args].split if args.key? :yard_args PuppetStrings.generate(patterns, options) end diff --git a/lib/puppet-strings/yard/code_objects/class.rb b/lib/puppet-strings/yard/code_objects/class.rb index a7315e854..4a65c4b30 100644 --- a/lib/puppet-strings/yard/code_objects/class.rb +++ b/lib/puppet-strings/yard/code_objects/class.rb @@ -51,7 +51,7 @@ def to_hash hash[:line] = line hash[:inherits] = statement.parent_class if statement.parent_class hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) - defaults = Hash[*parameters.select{ |p| !p[1].nil? }.flatten] + defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten] hash[:defaults] = defaults unless defaults.empty? hash[:source] = source unless source && source.empty? hash diff --git a/lib/puppet-strings/yard/code_objects/defined_type.rb b/lib/puppet-strings/yard/code_objects/defined_type.rb index f5c1b8c25..7a0c3df50 100644 --- a/lib/puppet-strings/yard/code_objects/defined_type.rb +++ b/lib/puppet-strings/yard/code_objects/defined_type.rb @@ -50,7 +50,7 @@ def to_hash hash[:file] = file hash[:line] = line hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) - defaults = Hash[*parameters.select{ |p| !p[1].nil? }.flatten] + defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten] hash[:defaults] = defaults unless defaults.empty? hash[:source] = source unless source && source.empty? hash diff --git a/lib/puppet-strings/yard/code_objects/function.rb b/lib/puppet-strings/yard/code_objects/function.rb index cd0885b1c..a0dd51f5c 100644 --- a/lib/puppet-strings/yard/code_objects/function.rb +++ b/lib/puppet-strings/yard/code_objects/function.rb @@ -88,14 +88,14 @@ def to_hash if self.has_tag? :overload # loop over overloads and append onto the signatures array self.tags(:overload).each do |o| - hash[:signatures] << { :signature => o.signature, :docstring => PuppetStrings::Yard::Util.docstring_to_hash(o.docstring, [:param, :option, :return, :example]) } + hash[:signatures] << { :signature => o.signature, :docstring => PuppetStrings::Yard::Util.docstring_to_hash(o.docstring, %i[param option return example]) } end else - hash[:signatures] << { :signature => self.signature, :docstring => PuppetStrings::Yard::Util.docstring_to_hash(docstring, [:param, :option, :return, :example]) } + hash[:signatures] << { :signature => self.signature, :docstring => PuppetStrings::Yard::Util.docstring_to_hash(docstring, %i[param option return example]) } end hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) - defaults = Hash[*parameters.select{ |p| !p[1].nil? }.flatten] + defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten] hash[:defaults] = defaults unless defaults.empty? hash[:source] = source unless source && source.empty? hash diff --git a/lib/puppet-strings/yard/code_objects/plan.rb b/lib/puppet-strings/yard/code_objects/plan.rb index eb8dcc5e7..670f641ed 100644 --- a/lib/puppet-strings/yard/code_objects/plan.rb +++ b/lib/puppet-strings/yard/code_objects/plan.rb @@ -48,7 +48,7 @@ def to_hash hash[:file] = file hash[:line] = line hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) - defaults = Hash[*parameters.select{ |p| !p[1].nil? }.flatten] + defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten] hash[:defaults] = defaults unless defaults.empty? hash[:source] = source unless source && source.empty? hash diff --git a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb index 1590fd065..fffe831ee 100644 --- a/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/function_handler.rb @@ -301,9 +301,7 @@ def add_param_tag(object, tags, name, file, line, type = nil, default = nil, opt name = '&' + name end - unless type - type = tag && tag.types ? tag.type : 'Any' - end + type ||= tag && tag.types ? tag.type : 'Any' type = optional ? "Optional[#{type}]" : type object.parameters << [name, to_puppet_literal(default)] diff --git a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb index 075894d28..735e28f45 100644 --- a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb @@ -15,7 +15,7 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H # Only accept calls to Puppet::ResourceApi return unless statement.count > 1 module_name = statement[0].source - return unless [ 'Puppet::ResourceApi' ].include? module_name + return unless ['Puppet::ResourceApi'].include? module_name schema = extract_schema @@ -92,7 +92,7 @@ def hash_from_node(node) # puts "hash from #{node.inspect}" kv_pairs = node.children.collect do |assoc| - [ value_from_node(assoc.children[0]), value_from_node(assoc.children[1]) ] + [value_from_node(assoc.children[0]), value_from_node(assoc.children[1])] end Hash[kv_pairs] end diff --git a/lib/puppet-strings/yard/handlers/ruby/type_base.rb b/lib/puppet-strings/yard/handlers/ruby/type_base.rb index dbefbf476..2c310ed92 100644 --- a/lib/puppet-strings/yard/handlers/ruby/type_base.rb +++ b/lib/puppet-strings/yard/handlers/ruby/type_base.rb @@ -15,7 +15,7 @@ def get_type_yard_object(name) register object object end - + def find_docstring(node, kind) # Walk the tree searching for assignments or calls to desc/doc= node.traverse do |child| @@ -98,10 +98,10 @@ def set_values(node, object) next unless kvp.count == 2 next unless node_as_string(kvp[0]) == 'parent' if kvp[1].source == 'Puppet::Parameter::Boolean' - object.add('true') unless object.values.include? 'true' - object.add('false') unless object.values.include? 'false' - object.add('yes') unless object.values.include? 'yes' - object.add('no') unless object.values.include? 'no' + object.add('true') unless object.values.include? 'true' # rubocop:disable Performance/InefficientHashSearch Not supported on Ruby 2.1 + object.add('false') unless object.values.include? 'false' # rubocop:disable Performance/InefficientHashSearch Not supported on Ruby 2.1 + object.add('yes') unless object.values.include? 'yes' # rubocop:disable Performance/InefficientHashSearch Not supported on Ruby 2.1 + object.add('no') unless object.values.include? 'no' # rubocop:disable Performance/InefficientHashSearch Not supported on Ruby 2.1 end break end @@ -127,4 +127,3 @@ def set_default_namevar(object) default.isnamevar = true if default end end - \ No newline at end of file diff --git a/lib/puppet-strings/yard/parsers/json/parser.rb b/lib/puppet-strings/yard/parsers/json/parser.rb index 6e0104998..9a0c99385 100644 --- a/lib/puppet-strings/yard/parsers/json/parser.rb +++ b/lib/puppet-strings/yard/parsers/json/parser.rb @@ -25,7 +25,7 @@ def parse # TODO: this should compare json to a Task metadata json-schema or perform some other hueristics # to determine what type of statement it represents @statements.push(PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, @source, @file)) unless json.empty? - rescue + rescue # rubocop:disable Style/RescueStandardError Just catch everything log.error "Failed to parse #{@file}: " @statements = [] end diff --git a/lib/puppet-strings/yard/parsers/puppet/parser.rb b/lib/puppet-strings/yard/parsers/puppet/parser.rb index 6c91826f0..819057d2f 100644 --- a/lib/puppet-strings/yard/parsers/puppet/parser.rb +++ b/lib/puppet-strings/yard/parsers/puppet/parser.rb @@ -41,41 +41,42 @@ def enumerator end private - def transform_Program(o) + + def transform_Program(o) # rubocop:disable Naming/UncommunicativeMethodParamName # Cache the lines of the source text; we'll use this to locate comments @lines = o.source_text.lines.to_a o.definitions.map { |d| @visitor.visit(d) } end - def transform_Factory(o) + def transform_Factory(o) # rubocop:disable Naming/UncommunicativeMethodParamName @visitor.visit(o.current) end - def transform_HostClassDefinition(o) + def transform_HostClassDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName statement = PuppetStrings::Yard::Parsers::Puppet::ClassStatement.new(o, @file) statement.extract_docstring(@lines) statement end - def transform_ResourceTypeDefinition(o) + def transform_ResourceTypeDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName statement = PuppetStrings::Yard::Parsers::Puppet::DefinedTypeStatement.new(o, @file) statement.extract_docstring(@lines) statement end - def transform_FunctionDefinition(o) + def transform_FunctionDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName statement = PuppetStrings::Yard::Parsers::Puppet::FunctionStatement.new(o, @file) statement.extract_docstring(@lines) statement end - def transform_PlanDefinition(o) + def transform_PlanDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName statement = PuppetStrings::Yard::Parsers::Puppet::PlanStatement.new(o, @file) statement.extract_docstring(@lines) statement end - def transform_Object(o) + def transform_Object(o) # rubocop:disable Naming/UncommunicativeMethodParamName # Ignore anything else (will be compacted out of the resulting array) end end diff --git a/lib/puppet-strings/yard/tags/overload_tag.rb b/lib/puppet-strings/yard/tags/overload_tag.rb index 7cf115311..3c5f7e6f3 100644 --- a/lib/puppet-strings/yard/tags/overload_tag.rb +++ b/lib/puppet-strings/yard/tags/overload_tag.rb @@ -100,7 +100,7 @@ def to_hash hash[:text] = text if text hash[:signature] = signature hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) if !docstring.blank? - defaults = Hash[*parameters.select{ |p| !p[1].nil? }.flatten] + defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten] hash[:defaults] = defaults unless defaults.empty? hash[:types] = types if types hash[:name] = name if name diff --git a/lib/puppet/face/strings.rb b/lib/puppet/face/strings.rb index b0c1a0d14..d612795bb 100644 --- a/lib/puppet/face/strings.rb +++ b/lib/puppet/face/strings.rb @@ -117,7 +117,7 @@ if args.length > 1 if options[:list] - $stderr.puts "WARNING: ignoring types when listing all types." + warn "WARNING: ignoring types when listing all types." else options[:describe_types] = args[0..-2] end @@ -159,10 +159,10 @@ def build_generate_options(options = nil, *yard_args) generate_options[:yard_args] = yard_args unless yard_args.empty? if options if options[:emit_json] - $stderr.puts "WARNING: '--emit-json PATH' is deprecated. Use '--format json --out PATH' instead." + warn "WARNING: '--emit-json PATH' is deprecated. Use '--format json --out PATH' instead." end if options[:emit_json_stdout] - $stderr.puts "WARNING: '--emit-json-stdout' is deprecated. Use '--format json' instead." + warn "WARNING: '--emit-json-stdout' is deprecated. Use '--format json' instead." end markup = options[:markup] generate_options[:markup] = markup if markup diff --git a/spec/acceptance/generate_markdown_spec.rb b/spec/acceptance/generate_markdown_spec.rb index 5562483bf..a30244537 100644 --- a/spec/acceptance/generate_markdown_spec.rb +++ b/spec/acceptance/generate_markdown_spec.rb @@ -29,7 +29,7 @@ class { "test": } The name of the service -EOF + EOF it 'should render Markdown to stdout when using --format markdown and --stdout' do test_module_path = get_test_module_path(master, /Module test/) diff --git a/spec/unit/puppet-strings/describe_spec.rb b/spec/unit/puppet-strings/describe_spec.rb index 2f54183dc..ccc88a366 100644 --- a/spec/unit/puppet-strings/describe_spec.rb +++ b/spec/unit/puppet-strings/describe_spec.rb @@ -19,7 +19,7 @@ Puppet::Type.newtype(:database) do desc 'An example database server resource type.' end -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) Puppet::ResourceApi.register_type( @@ -40,9 +40,9 @@ path this type will autorequire that file. EOS ) -SOURCE + SOURCE - YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) + YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) Puppet::Type.type(:file).newproperty(:content) do include Puppet::Util::Checksums include Puppet::DataSync @@ -54,7 +54,7 @@ exclusive with `source` and `target`. EOT end -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) Puppet::Type.newtype(:file) do @@ -78,7 +78,7 @@ end end -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) Puppet::Type.type(:file).newproperty(:source) do @@ -92,7 +92,7 @@ exclusive with `source` and `target`. EOT end -SOURCE + SOURCE end describe 'rendering DESCRIBE to stdout' do @@ -134,7 +134,7 @@ Providers --------- -DATA + DATA expect{ PuppetStrings::Describe.render(['file']) }.to output(output).to_stdout end end diff --git a/spec/unit/puppet-strings/json_spec.rb b/spec/unit/puppet-strings/json_spec.rb index 12157a2e4..e1faf3e13 100644 --- a/spec/unit/puppet-strings/json_spec.rb +++ b/spec/unit/puppet-strings/json_spec.rb @@ -21,7 +21,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { # @param param3 Third param. define dt(Integer $param1, $param2, String $param3 = hi) { } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) if TEST_PUPPET_PLANS # A simple plan. @@ -30,7 +30,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { # @param param3 Third param. plan plann(String $param1, $param2, Integer $param3 = 1) { } -SOURCE + SOURCE # Only include Puppet functions for 4.1+ YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) if TEST_PUPPET_FUNCTIONS @@ -41,7 +41,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { # @return [Undef] Returns nothing. function func(Integer $param1, $param2, String $param3 = hi) { } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :json) { @@ -66,7 +66,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { } } } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) Puppet::Parser::Functions.newfunction(:func3x, doc: <<-DOC @@ -199,7 +199,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { package: 'apt', }, ) -SOURCE + SOURCE end RSpec.shared_examples "correct JSON" do diff --git a/spec/unit/puppet-strings/markdown/base_spec.rb b/spec/unit/puppet-strings/markdown/base_spec.rb index c1e271654..ad818e59b 100644 --- a/spec/unit/puppet-strings/markdown/base_spec.rb +++ b/spec/unit/puppet-strings/markdown/base_spec.rb @@ -12,7 +12,7 @@ # @param param3 Third param. class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { } -SOURCE + SOURCE end let(:reg) { YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash)[0] } @@ -24,7 +24,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { end end - [ 'examples', + ['examples', 'see', 'since', 'return_val', @@ -85,7 +85,7 @@ class klass::yeah( ) inherits foo::bar { } -SOURCE + SOURCE end let(:reg) { YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash)[0] } diff --git a/spec/unit/puppet-strings/markdown_spec.rb b/spec/unit/puppet-strings/markdown_spec.rb index 9b9e72bd4..4f4599315 100644 --- a/spec/unit/puppet-strings/markdown_spec.rb +++ b/spec/unit/puppet-strings/markdown_spec.rb @@ -65,7 +65,7 @@ class noparams () {} Boolean $param4 = true ) { } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) if TEST_PUPPET_PLANS # A simple plan. # @param param1 First param. @@ -73,7 +73,7 @@ class noparams () {} # @param param3 Third param. plan plann(String $param1, $param2, Integer $param3 = 1) { } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :json) { @@ -98,7 +98,7 @@ class noparams () {} } } } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) # A simple Puppet function. @@ -112,7 +112,7 @@ class noparams () {} # $result = func(1, 2) function func(Integer $param1, $param2, String $param3 = hi) { } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) # An example 4.x function. @@ -272,7 +272,7 @@ class noparams () {} package: 'apt', }, ) -SOURCE + SOURCE end let(:filename) do diff --git a/spec/unit/puppet-strings/yard/code_objects/task_spec.rb b/spec/unit/puppet-strings/yard/code_objects/task_spec.rb index ea72cf157..478700215 100644 --- a/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +++ b/spec/unit/puppet-strings/yard/code_objects/task_spec.rb @@ -26,7 +26,7 @@ } } } -SOURCE + SOURCE } let(:json) { JSON.parse(source) } let(:statement) { PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, source, "test.json") } diff --git a/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb index 55bc13b70..fc2734175 100644 --- a/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb @@ -18,7 +18,7 @@ } } } -SOURCE + SOURCE } it 'should log an error' do @@ -50,7 +50,7 @@ } } } -SOURCE + SOURCE } it 'should log a warning' do @@ -83,7 +83,7 @@ } } -SOURCE + SOURCE } it 'should register a task object' do @@ -105,7 +105,7 @@ } } } -SOURCE + SOURCE } it 'should output a warning' do diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb index 6dac537cb..ab5d58a9e 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb @@ -43,7 +43,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { ensure => present } } -SOURCE + SOURCE } it 'should register a class object' do @@ -85,7 +85,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { ensure => present } } -SOURCE + SOURCE } it 'should output a warning' do @@ -103,7 +103,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { ensure => present } } -SOURCE + SOURCE } it 'should output a warning' do @@ -122,7 +122,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { ensure => present } } -SOURCE + SOURCE } it 'should respect the type that was documented' do @@ -145,7 +145,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { ensure => present } } -SOURCE + SOURCE } it 'should output a warning' do @@ -164,7 +164,7 @@ class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { ensure => present } } -SOURCE + SOURCE } it 'should respect the type that was documented' do @@ -186,7 +186,7 @@ class foo() { ensure => present } } - SOURCE + SOURCE } it 'should parse the summary' do @@ -206,7 +206,7 @@ class foo() { ensure => present } } - SOURCE + SOURCE } it 'should log a warning' do diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb index 8d8718729..804dc5518 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb @@ -44,7 +44,7 @@ ensure => present } } -SOURCE + SOURCE } it 'does not output a warning for title/name' do expect{ subject }.not_to output(/\[warn\].*(name|title).*/).to_stdout_from_any_process @@ -92,7 +92,7 @@ ensure => present } } -SOURCE + SOURCE } it 'should output a warning' do @@ -110,7 +110,7 @@ ensure => present } } -SOURCE + SOURCE } it 'should output a warning' do @@ -129,7 +129,7 @@ ensure => present } } -SOURCE + SOURCE } it 'should respect the type that was documented' do @@ -152,7 +152,7 @@ ensure => present } } -SOURCE + SOURCE } it 'should output a warning' do @@ -171,7 +171,7 @@ ensure => present } } -SOURCE + SOURCE } it 'should respect the type that was documented' do @@ -197,7 +197,7 @@ ensure => present } } -SOURCE + SOURCE } it 'should parse the summary' do @@ -220,7 +220,7 @@ ensure => present } } -SOURCE + SOURCE } it 'should log a warning' do diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb index 0651e3974..db2d62404 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb @@ -44,7 +44,7 @@ notice 'hello world' undef } -SOURCE + SOURCE } it 'should register a function object' do @@ -90,7 +90,7 @@ function foo(Integer $param1, $param2, String $param3 = hi) { notice 'hello world' } -SOURCE + SOURCE } it 'should output a warning' do @@ -107,7 +107,7 @@ function foo(Integer $param1, $param2, String $param3 = hi) { notice 'hello world' } -SOURCE + SOURCE } it 'should output a warning' do @@ -125,7 +125,7 @@ function foo(Integer $param1, $param2, String $param3 = hi) { notice 'hello world' } -SOURCE + SOURCE } it 'should respect the type that was documented' do @@ -147,7 +147,7 @@ function foo(Integer $param1, $param2, String $param3 = hi) { notice 'hello world' } -SOURCE + SOURCE } it 'should output a warning' do @@ -165,7 +165,7 @@ function foo(Integer $param1, $param2, String $param3 = hi) { notice 'hello world' } -SOURCE + SOURCE } it 'should respect the type that was documented' do @@ -186,7 +186,7 @@ function foo(Integer $param1, $param2, String $param3 = hi) { notice 'hello world' } -SOURCE + SOURCE } it 'should output a warning' do @@ -200,7 +200,7 @@ function foo() >> String { notice 'hello world' } -SOURCE + SOURCE } it 'should register a function object with the correct return type' do @@ -223,7 +223,7 @@ function foo() >> String { notice 'hi there' } -SOURCE + SOURCE } it 'should not output a warning if return types match' do @@ -238,7 +238,7 @@ function foo() >> Struct[{'a' => Integer[1, 10]}] { notice 'hello world' } -SOURCE + SOURCE } it 'should prefer the return type from the function definition' do @@ -260,7 +260,7 @@ function foo() { notice 'hello world' } -SOURCE + SOURCE } it 'should add a return tag with a default type value of Any' do @@ -285,7 +285,7 @@ function foo() { notice 'hello world' } -SOURCE + SOURCE } it 'should parse the summary' do @@ -304,7 +304,7 @@ notice 'hello world' } -SOURCE + SOURCE } it 'should log a warning' do diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb index 84ffe4a4d..101244f1f 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb @@ -20,7 +20,7 @@ let(:source) { <<-SOURCE Puppet::Parser::Functions.newfunction(:foo) do |*args| end -SOURCE + SOURCE } it 'should log a warning' do @@ -38,7 +38,7 @@ DOC ) do |*args| end -SOURCE + SOURCE } it 'should register a function object' do @@ -82,7 +82,7 @@ module Puppet::Parser::Functions ) do |*args| end end -SOURCE + SOURCE } it 'should register a function object' do @@ -122,7 +122,7 @@ module Puppet::Parser::Functions @param second The second parameter. DOC end -SOURCE + SOURCE } it 'should log a warning' do @@ -136,7 +136,7 @@ module Puppet::Parser::Functions let(:source) { <<-SOURCE Puppet::Functions.create_function(:foo) do end -SOURCE + SOURCE } it 'should log a warning' do @@ -149,7 +149,7 @@ module Puppet::Parser::Functions # An example 4.x function. Puppet::Functions.create_function(:foo) do end -SOURCE + SOURCE } it 'should register a function object' do @@ -179,7 +179,7 @@ module Puppet::Parser::Functions def foo(param1, param2, param3 = nil) end end -SOURCE + SOURCE } it 'should register a function object' do @@ -231,7 +231,7 @@ def foo(param1, param2, param3 = nil) def foo(param1, param2, param3 = nil) end end -SOURCE + SOURCE } it 'should register a function object without any overload tags' do @@ -285,7 +285,7 @@ def foo(param1, param2, param3 = nil) "Bar" end end -SOURCE + SOURCE } it 'does not throw an error with no @return' do @@ -316,7 +316,7 @@ def foo(param1, param2, param3 = nil) repeated_param 'String', :param4 end end -SOURCE + SOURCE } it 'should register a function object with the expected parameters' do @@ -365,7 +365,7 @@ def foo(param1, param2, param3 = nil) optional_repeated_param 'String', :param end end -SOURCE + SOURCE } it 'should register a function object with the expected parameters' do @@ -507,7 +507,7 @@ def other(b) 'lol' end end -SOURCE + SOURCE } it 'should register a function object with overload tags' do @@ -576,7 +576,7 @@ def other(b) dispatch :foo do end end -SOURCE + SOURCE } it 'should output a warning' do @@ -593,7 +593,7 @@ def other(b) param 'String', :param1 end end -SOURCE + SOURCE } it 'should output a warning' do @@ -611,7 +611,7 @@ def other(b) param 'String', :param1 end end -SOURCE + SOURCE } it 'should output a warning' do @@ -628,7 +628,7 @@ def other(b) param 'String', :param1 end end -SOURCE + SOURCE } it 'should output a warning' do @@ -645,7 +645,7 @@ def other(b) dispatch :foo do end end -SOURCE + SOURCE } it 'should output a warning' do @@ -698,7 +698,7 @@ def other(b) dispatch :foo do end end -SOURCE + SOURCE } it 'should parse the summary' do @@ -718,7 +718,7 @@ def other(b) dispatch :foo do end end -SOURCE + SOURCE } it 'should log a warning' do diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb index de31c5dde..da875fa79 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb @@ -19,7 +19,7 @@ let(:source) { <<-SOURCE Puppet::Type.type(:custom).provide :linux do end -SOURCE + SOURCE } it 'should log a warning' do @@ -32,7 +32,7 @@ Puppet::Type.type(:custom).provide :linux do @doc = 123 end -SOURCE + SOURCE } it 'should log an error' do @@ -45,7 +45,7 @@ Puppet::Type.type(:custom).provide :linux do @doc = 'An example provider on Linux.' end -SOURCE + SOURCE } it 'should correctly detect the docstring' do @@ -62,7 +62,7 @@ desc %Q{This is a multi-line doc in %Q with #{test}} end -SOURCE + SOURCE } it 'should strip the `%Q{}` and render the interpolation expression literally' do @@ -84,7 +84,7 @@ has_feature :some_other_feature commands foo: '/usr/bin/foo' end -SOURCE + SOURCE } it 'should register a provider object' do @@ -112,7 +112,7 @@ Puppet::Type.type(:custom).provide :linux do @doc = '@summary A short summary.' end -SOURCE + SOURCE } it 'should parse the summary' do @@ -128,7 +128,7 @@ Puppet::Type.type(:custom).provide :linux do @doc = '@summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!!' end -SOURCE + SOURCE } it 'should log a warning' do diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb index 386869f70..a3ff08b30 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb @@ -20,7 +20,7 @@ Puppet::ResourceApi.register_type( name: 'database' ) -SOURCE + SOURCE } it 'should log a warning' do @@ -34,7 +34,7 @@ name: 'database', docs: 'An example database server resource type.', ) -SOURCE + SOURCE } it 'should correctly detect the docstring' do @@ -53,7 +53,7 @@ docs: %Q{This is a multi-line doc in %Q with #{test}}, ) -SOURCE + SOURCE } it 'should strip the `%Q{}` and render the interpolation expression literally' do @@ -110,7 +110,7 @@ }, }, ) -SOURCE + SOURCE } it 'should register a type object' do @@ -186,7 +186,7 @@ name: 'database', docs: '@summary A short summary.', ) -SOURCE + SOURCE } it 'should parse the summary' do @@ -203,7 +203,7 @@ name: 'database', docs: '@summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!!', ) -SOURCE + SOURCE } it 'should log a warning' do @@ -224,7 +224,7 @@ } ] ) -SOURCE + SOURCE } it 'should not emit a warning' do diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb index 87283c83c..cd16099cf 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb @@ -19,7 +19,7 @@ let(:source) { <<-SOURCE Puppet::Type.newtype(:database) do end -SOURCE + SOURCE } it 'should log a warning' do @@ -32,7 +32,7 @@ Puppet::Type.newtype(:database) do @doc = 123 end -SOURCE + SOURCE } it 'should log an error' do @@ -45,7 +45,7 @@ Puppet::Type.newtype(:database) do @doc = 'An example database server resource type.' end -SOURCE + SOURCE } it 'should correctly detect the docstring' do @@ -62,7 +62,7 @@ desc %Q{This is a multi-line doc in %Q with #{test}} end -SOURCE + SOURCE } it 'should strip the `%Q{}` and render the interpolation expression literally' do @@ -82,7 +82,7 @@ defaultto false end end -SOURCE + SOURCE } it 'should correctly detect the required_feature' do @@ -150,7 +150,7 @@ defaultto 'warn' end end -SOURCE + SOURCE } it 'should register a type object' do @@ -229,7 +229,7 @@ desc 'An example database server resource type.' ensurable end -SOURCE + SOURCE } it 'should register a type object with default ensure values' do @@ -250,7 +250,7 @@ desc 'The database server name.' end end -SOURCE + SOURCE } it 'should register a type object with the "name" parameter as the namevar' do @@ -268,7 +268,7 @@ Puppet::Type.newtype(:database) do @doc = '@summary A short summary.' end -SOURCE + SOURCE } it 'should parse the summary' do @@ -284,7 +284,7 @@ Puppet::Type.newtype(:database) do @doc = '@summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!!' end -SOURCE + SOURCE } it 'should log a warning' do diff --git a/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb b/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb index e20a01ad4..4fee3dbd4 100644 --- a/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb @@ -24,7 +24,7 @@ } } } -SOURCE + SOURCE } let(:json) { JSON.parse(source) } subject { PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, source, "test.json") } @@ -45,7 +45,7 @@ "description": "Allows you to backup your database to local file.", "input_method": "stdin" } -SOURCE + SOURCE } it 'returns an empty hash' do expect(subject.parameters).to eq({}) diff --git a/spec/unit/puppet-strings/yard/util_spec.rb b/spec/unit/puppet-strings/yard/util_spec.rb index 6611284e6..80a0c5496 100644 --- a/spec/unit/puppet-strings/yard/util_spec.rb +++ b/spec/unit/puppet-strings/yard/util_spec.rb @@ -19,7 +19,7 @@ str = <<-STR %Q{this is a test string} -STR + STR expect(subject.scrub_string(str)).to eq("this is\na test string") end From 73c64d9edebb8f6d48de35110261b77af2bbcc74 Mon Sep 17 00:00:00 2001 From: Jesse Scott Date: Wed, 19 Jun 2019 10:53:30 -0700 Subject: [PATCH 4/5] (MAINT) Pin rubocop and beaker more specifically --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 397997f26..fd9de43f7 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ group :test do end group :acceptance do - gem 'beaker', '< 3.0' + gem 'beaker', '~> 3.0' gem 'beaker-rspec' gem 'beaker-hostgenerator' gem 'beaker-abs' @@ -35,7 +35,7 @@ group :development do gem 'pry-byebug' end -gem 'rubocop', '~> 0.49' +gem 'rubocop', '~> 0.57.2' # Evaluate Gemfile.local if it exists if File.exists? "#{__FILE__}.local" From dca3f6d245087bb2107843a6f41665bab4c01ca1 Mon Sep 17 00:00:00 2001 From: Jesse Scott Date: Wed, 19 Jun 2019 10:53:52 -0700 Subject: [PATCH 5/5] (MAINT) Make rubocop rake task actually exit non-zero on failure --- Rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 8bc06e532..6b1f10f42 100644 --- a/Rakefile +++ b/Rakefile @@ -61,7 +61,8 @@ end task(:rubocop) do require 'rubocop' cli = RuboCop::CLI.new - cli.run(%w(-D -f s)) + result = cli.run(%w(-D -f s)) + abort unless result == RuboCop::CLI::STATUS_SUCCESS end #### CHANGELOG ####