-
Notifications
You must be signed in to change notification settings - Fork 285
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
Fix #808 #986
Conversation
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.
LGTM
For reference, here is what is implemented in gofumpt https://github.com/mvdan/gofumpt/blob/master/format%2Fformat.go#L334 They use a slightly different regexp You can look at historical changes, it gives context |
@@ -165,3 +165,9 @@ func checkNumberOfArguments(expected int, args lint.Arguments, ruleName string) | |||
panic(fmt.Sprintf("not enough arguments for %s rule, expected %d, got %d. Please check the rule's documentation", ruleName, expected, len(args))) | |||
} | |||
} | |||
|
|||
var directiveCommentRE = regexp.MustCompile("//(line |extern |export |[a-z0-9]+:[a-z0-9])") // see https://go-review.googlesource.com/c/website/+/442516/1..2/_content/doc/comment.md#494 |
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 wonder if it needs to be anchored (^
); I did a quick try using the comment below, and it didn't flag that as invalid;
//this is a regular command that's incorrectly formatted //nolint:foobar // because one two three
(disclaimer: I only used the function directly, not in context of the whole code, so perhaps there's already some other code handling this)
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 think you are right, that's why I raised the point
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.
It was fixed with #988
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.
Thanks!
Please note this change had a unexpected (but normal) consequence for me Previously the following syntax were allowed //nolint: somelinter // what ever the reason This one was somehow invalid, and excluded by the code before this PR not it reports a normal error, because it expects //nolint:somelinter // what ever the reason |
Closes #808 by ignoring comments matching the official pattern for directives