Class: RuboCop::Cop::YARD::MeaninglessTag
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::YARD::MeaninglessTag
show all
- Extended by:
- AutoCorrector
- Includes:
- DocumentationComment, RangeHelp, Helper
- Defined in:
- lib/rubocop/cop/yard/meaningless_tag.rb
Overview
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
#check(node) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/rubocop/cop/yard/meaningless_tag.rb', line 34
def check(node)
preceding_lines = preceding_lines(node)
return false unless (node, preceding_lines.last)
docstring = build_docstring(preceding_lines)
return false unless docstring
docstring.tags.each do |tag|
next unless tag.tag_name == 'param' || tag.tag_name == 'option'
= preceding_lines.find { |line| line.text.include?("@#{tag.tag_name}") }
next unless
add_offense(, message: "`@#{tag.tag_name}` is meaningless tag on #{node.type}") do |corrector|
corrector.replace(, .text.gsub("@#{tag.tag_name}", tag.tag_name))
end
end
end
|
#on_class(node) ⇒ Object
Also known as:
on_module, on_casgn
28
29
30
|
# File 'lib/rubocop/cop/yard/meaningless_tag.rb', line 28
def on_class(node)
check(node)
end
|