Class: RuboCop::Cop::YARD::CollectionType

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
ConfigurableEnforcedStyle, RangeHelp, Helper
Defined in:
lib/rubocop/cop/yard/collection_type.rb

Overview

Examples:

common

# bad
# @param [Hash<Symbol, String>]

# bad
# @param [Hash(String)]

# bad
# @param [Array{Symbol => String}]

# good
# @param [Hash{Symbol => String}]

# good
# @param [Array(String)]

# good
# @param [Hash{Symbol => String}]

Instance Method Summary collapse

Methods included from Helper

#build_docstring, #each_types_explainer, #extract_tag_types, #inline_comment?, #parse_type, #styled_string

Instance Method Details

#on_new_investigationObject



30
31
32
33
34
35
36
37
38
# File 'lib/rubocop/cop/yard/collection_type.rb', line 30

def on_new_investigation
  processed_source.comments.each do |comment|
    next if inline_comment?(comment)
    next unless include_yard_tag?(comment)

    docstring = ::YARD::DocstringParser.new.parse(comment.text.gsub(/\A#\s*/, ''))
    check_mismatch_collection_type(comment, docstring)
  end
end