Skip to content

Conversation

@ldez
Copy link
Member

@ldezldez commented Aug 3, 2023

As illustrated in the following example, to ignore long URLs the nolint directive should be placed on the top of the comments but this ignores lll on the whole function.

.golangci.yml
linters: disable-all: trueenable: - lll - typechecklinters-settings: lll: line-length: 50
package main import"fmt"// main runs the app.// https://github.com/walle/lll/blob/4438bccd245f7e87a5a69023625f01e7035c05c0/utils.go#L15////nolint:lllfuncmain(){fmt.Println("Foo") }
$ golangci-lint run  $

Fixes#3983

@ldezldez added enhancement New feature or improvement linter: update Update the linter implementation inside golangci-lint labels Aug 3, 2023
@ldezldez added the blocked Need's direct action from maintainer label Oct 9, 2023
lineNumber:=0
multiImportEnabled:=false

urlComment:=regexp.MustCompile(`\s*//\s*http(s)?://[^ ]+$`)
Copy link
Contributor

@mattdowdellmattdowdellOct 29, 2023

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.

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: - lllsource: "^// \\[.*\\]: \\w+"

@batazor
Copy link

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.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blockedNeed's direct action from maintainerenhancementNew feature or improvementlinter: updateUpdate the linter implementation inside golangci-lint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lll: Ignore long URLs, strings, and struct tags

5 participants

@ldez@batazor@mitar@mattdowdell@nieomylnieja