Skip to content

Commit

Permalink
DocstringParser check of param names skips warning on unknown delegat…
Browse files Browse the repository at this point in the history
…ed params; does warn on duplicate unknown params
  • Loading branch information
notEthan committed Mar 7, 2023
1 parent b3827c9 commit a802e4c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/yard/docstring_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def self.after_parse_callbacks
seen_names = []
infile_info = "\n in file `#{parser.object.file}' " \
"near line #{parser.object.line}"
splat_param = parser.object.parameters.any? { |name, _| name =~ /\A\*/ }
param_tags = []
parser.tags.each do |tag|
next unless tag.tag_name == "param"
Expand All @@ -299,12 +300,14 @@ def self.after_parse_callbacks
if seen_names.include?(tag.name)
log.warn "#{parser.object} @param tag has duplicate parameter name: " \
"#{tag.name} #{infile_info}"
elsif names.include?(tag.name)
seen_names << tag.name
else
end
# warn about unknown params. but not delegated params, where the param tag
# is a reference and the object takes *args or **keywords.
if !names.include?(tag.name) && !((tag.is_a?(Tags::RefTag) || tag.is_a?(Tags::RefTagList)) && splat_param)
log.warn "#{parser.object} @param tag has unknown parameter name: " \
"#{tag.name} #{infile_info}"
end
seen_names << tag.name
end
end

Expand Down

0 comments on commit a802e4c

Please sign in to comment.