lll: ignore comments containing only URL#3986
Open
ldez wants to merge 1 commit intogolangci:masterfrom
Open
Conversation
mitar
reviewed
Aug 3, 2023
mattdowdell
reviewed
Oct 29, 2023
| lineNumber := 0 | ||
| multiImportEnabled := false | ||
|
|
||
| urlComment := regexp.MustCompile(`\s*//\s*http(s)?://[^ ]+$`) |
Contributor
There was a problem hiding this comment.
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.comI 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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As illustrated in the following example, to ignore long URLs the
nolintdirective should be placed on the top of the comments but this ignoreslllon the whole function..golangci.yml
$ golangci-lint run $Fixes #3983