New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn if a parameter is documented more than once and remove support for multi-line (/* */
) comments
#19
Conversation
@@ -11,7 +11,7 @@ def check | |||
if dtok.value =~ /\A\s*\[\*([a-zA-Z0-9_]+)\*\]/ or | |||
dtok.value =~ /\A\s*\$([a-zA-Z0-9_]+):: +/ or | |||
dtok.value =~ /\A\s*@param (?:\[.+\] )?([a-zA-Z0-9_]+)(?: +|$)/ | |||
doc_params << $1 | |||
doc_params.unshift( { value: $1, token: dtok }) # Push new params onto start of array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about Hash doc_params
. If the param already exists, add it to Array duplicates
.
You may want to consider also adding a warning on the line with the original. This can make it easy to find the pair of duplicates and merge them. However, not strictly needed and it's probably easy enough if you don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why you wanted a hash, but I guess that'll be needed for fixing some of the other issues I opened.
notify :warning, { | ||
:message => "Duplicate parameter documentation for #{p[:value]}", | ||
:line => p[:token].line, | ||
:column => p[:token].column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The column will have a mismatch since there is a regex. You may want to consider p[:token].column + p[:token].value.match(/\A\s*/)[0].length
(which is OK because all regexes around line 11 start with whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tokens with @param
have two sets of whitespace. eg p[:token].value == ' @param foo'
31a1b95
to
9620689
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are great
Found when testing voxpupuli/puppet-lint-param-docs#19
Found whilst testing voxpupuli/puppet-lint-param-docs#19
/* */
) comments
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how rspec treats duplicate tests, but at least I got confused when I read the code. Other than that 👍
Found when testing voxpupuli/puppet-lint-param-docs#19
Found whilst testing voxpupuli/puppet-lint-param-docs#19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untested, but I think this is slightly cleaner. I think it also means you get all duplicate parameters grouped in the output rather than when they occur.
Slash comments `//` don't even work and aren't in the Puppet 4+ language spec. Core puppet-lint already warns against multi-line comments and they were removed from the Puppet 6 docs. We also have zero tests using them in this plugin.
Fixes #16