Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lll: ignore comments containing only URL#3986

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ldez wants to merge1 commit intogolangci:master
base:master
Choose a base branch
Loading
fromldez:feat/lll-url-comments

Conversation

@ldez
Copy link
Member

@ldezldez commentedAug 3, 2023
edited
Loading

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

.golangci.yml
linters:disable-all:trueenable:    -lll    -typechecklinters-settings:lll:line-length:50
package mainimport"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

batazor, Bysmyyr, and nieomylnieja reacted with thumbs up emojimitar reacted with thumbs down emoji
@ldezldez added enhancementNew feature or improvement linter: updateUpdate the linter implementation inside golangci-lint labelsAug 3, 2023
@ldezldez added the blockedNeed's direct action from maintainer labelOct 9, 2023
lineNumber:=0
multiImportEnabled:=false

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

@mattdowdellmattdowdellOct 29, 2023
edited
Loading

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.

alexandear reacted with thumbs up emoji

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+"

ccoVeille and theory reacted with thumbs up emoji
@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

Reviewers

3 more reviewers

@mitarmitarmitar left review comments

@mattdowdellmattdowdellmattdowdell left review comments

@nieomylniejanieomylniejanieomylnieja left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

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

[8]ページ先頭

©2009-2025 Movatter.jp