-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
lll: ignore comments containing only URL #3986
base: master
Are you sure you want to change the base?
Conversation
@@ -89,6 +90,8 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r | |||
lineNumber := 0 | |||
multiImportEnabled := false | |||
|
|||
urlComment := regexp.MustCompile(`\s*//\s*http(s)?://[^ ]+$`) |
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.
Would it be possible to also exclude URLs used as reference links? e.g.
Here's a [link] and [another][1]!
[link]: https://example.com
[1]: https://example.com
I sometimes use these references to keep Go docs readable when browsing code (inserting long URLs makes following text hard), and given modern godoc uses markdown, this would likely be universally helpful.
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.
For that I specifically use:
exclude-rules:
- linters:
- lll
source: "^// \\[.*\\]: \\w+"
Sometimes in the code you have to leave links to tasks in the tracker or links to discussion of some bugs - to understand why it was done this way. And often they are long links, it would be cool to be able to skip such cases by default. |
As illustrated in the following example, to ignore long URLs the
nolint
directive should be placed on the top of the comments but this ignoreslll
on the whole function..golangci.yml
$ golangci-lint run $
Fixes #3983