-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Style/CommentAnnotation reports only first of multiple offending lines #5713
Comments
I can see this is closed but it appears to still be in effect. On rubocop 0.86:
Only marks the first line as problematic. |
I can't see a definitive way to detect whether a TODO on the second line is a new TODO or a continuation of the first line. For example, if we relax the code so it finds every first TODO (or any other keyword) on every line then it would break the following example from the specs:
Here, it would correct the second line from IMHO in this case it's more important to stay safe then find more potential offenses. So I'd vote to keep it as it is. |
That makes sense. I think a note should be added to the docs explaining that the rule will only look at keywords in the first line of a paragraph (consecutive series of comment lines), because otherwise the behavior is confusing. |
…ehaviour of multiline comment blocks.
Good morning everyone,
I stumbled upon some unexpected behavior when working on a project. I created a minimal working example here.
I am working on a class that has multiple
# TODO ...
annotations. Something like this:When running Rubocop, it reports a
Style/CommentAnnotation
offense, because the proper style would be# TODO: ...
. But it does that only for the first and third occurrence, and not for the second one.Even after fixing the first and third line, the second line is never reported as an offense. This also means that
rubicon -a
will never pick that line up and fix it automatically.Expected behavior
When there are
Style/CommentAnnotation
in multiple lines that follow each other, Rubocop should report a violation for each individual line.Actual behavior
When there are
Style/CommentAnnotation
in multiple lines that follow each other, only the first offense is reported.Steps to reproduce the problem
Check out the minimal working example. Download the Gist as a ZIP, extract the archive, execute
bundle
if necessary and runrubocop
in it.RuboCop version
Include the output of
rubocop -V
. Here's an example:The text was updated successfully, but these errors were encountered: