Class: RuboCop::Cop::Yardoc::ValidTypes
- Extended by:
- AutoCorrector
- Includes:
- ParamHelp, RuboCop::Cop::YardHelp
- Defined in:
- lib/rubocop/cop/yardoc/valid_types.rb
Overview
Ensures all types are separated by a space
Types are parsed with YARD.
Constant Summary collapse
- MSG =
'Types should be parseable by YARD'
Instance Method Summary collapse
-
#on_def(node) ⇒ Object
(also: #on_defs)
Executed for every method definition.
Methods included from ParamHelp
#param_tags_and_positions, #start_tag_position, #start_type_position
Instance Method Details
#on_def(node) ⇒ Object Also known as: on_defs
Executed for every method definition
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/cop/yardoc/valid_types.rb', line 29 def on_def(node) return unless documented?(node) (node, tags: [:param, :return]).each do |param| param.types.each do |type| YARD::Tags::TypesExplainer::Parser.parse type rescue SyntaxError add_offense(param.type_range || param.tag_range, message: MSG) break end end end |