Skip to content

Commit 823d764

Browse files
authored
Merge pull request #30 from renatolond/fix/alert_about_missing_tags
Adds a missing case for mismatch name
2 parents f1f2d65 + 1895ba5 commit 823d764

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

lib/rubocop/cop/yard/mismatch_name.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def on_def(node)
6767

6868
# Documentation only or just `@return` is a common form of documentation.
6969
# The subsequent features will be limited to cases where both `@param` and `@option` are present.
70-
unless docstring.tags.find { |tag| (tag.tag_name == 'param' && !tag.instance_of?(::YARD::Tags::RefTagList)) || tag.tag_name == 'option' }
70+
unless docstring.tags.find { |tag| (tag.tag_name == 'param' && !(tag.instance_of?(::YARD::Tags::RefTagList) && tag.name.nil?)) || tag.tag_name == 'option' }
7171
return false
7272
end
7373
node.arguments.each do |argument|

smoke/generated/mismatch_name.json

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,43 @@
122122
"column": 3
123123
}
124124
},
125+
{
126+
"severity": "convention",
127+
"message": "This method has argument `arg2`, But not documented",
128+
"cop_name": "YARD/MismatchName",
129+
"corrected": false,
130+
"correctable": true,
131+
"location": {
132+
"start_line": 33,
133+
"start_column": 3,
134+
"last_line": 33,
135+
"last_column": 28,
136+
"length": 26,
137+
"line": 33,
138+
"column": 3
139+
}
140+
},
125141
{
126142
"severity": "convention",
127143
"message": "`context,` is not found in method arguments of [context]",
128144
"cop_name": "YARD/MismatchName",
129145
"corrected": false,
130146
"correctable": false,
131147
"location": {
132-
"start_line": 52,
148+
"start_line": 56,
133149
"start_column": 18,
134-
"last_line": 52,
150+
"last_line": 56,
135151
"last_column": 25,
136152
"length": 8,
137-
"line": 52,
153+
"line": 56,
138154
"column": 18
139155
}
140156
}
141157
]
142158
}
143159
],
144160
"summary": {
145-
"offense_count": 8,
161+
"offense_count": 9,
146162
"target_file_count": 1,
147163
"inspected_file_count": 1
148164
}

smoke/generated/mismatch_name_correct.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def doc_only(arg)
3434
def ref_only(arg)
3535
end
3636

37+
# @param arg1 (see #other)
38+
# @param [Object] arg2
39+
def partial_ref(arg1, arg2)
40+
end
41+
3742
# @param [String] arg
3843
def rest_block(arg, *, **, &block)
3944
end

smoke/mismatch_name.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def doc_only(arg)
3030
def ref_only(arg)
3131
end
3232

33+
# @param arg1 (see #other)
34+
def partial_ref(arg1, arg2)
35+
end
36+
3337
# @param [String] arg
3438
def rest_block(arg, *, **, &block)
3539
end

0 commit comments

Comments
 (0)