Skip to content
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

Introduce the https://github.com/segmentio/golines linter #1914

Closed
tian000 opened this issue Apr 15, 2021 · 10 comments · Fixed by #5432
Closed

Introduce the https://github.com/segmentio/golines linter #1914

tian000 opened this issue Apr 15, 2021 · 10 comments · Fixed by #5432
Labels
linter: new Support new linter

Comments

@tian000
Copy link

tian000 commented Apr 15, 2021

Is your feature request related to a problem? Please describe.
This linter actually fixes long lines which is very convenient.

Describe the solution you'd like
Please add this linter to golangci-lint

https://github.com/segmentio/golines

@tian000 tian000 added the enhancement New feature or improvement label Apr 15, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 15, 2021

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Apr 15, 2021

Hello,

https://github.com/segmentio/golines

golines is a golang formatter that shortens long lines,

golines is not a linter but a formatter.

I think it's out of the scope of golangci-lint.

@ldez ldez closed this as completed Apr 15, 2021
@ldez ldez added declined and removed enhancement New feature or improvement labels Apr 15, 2021
@tian000
Copy link
Author

tian000 commented Apr 15, 2021

Aren't gofumpt and gofmt formatters, and yet they are part of golangci-lint?

@ldez
Copy link
Member

ldez commented Apr 15, 2021

They are used as linter, to handle long lines there is the lll linter inside golangci-lint.

@tian000
Copy link
Author

tian000 commented Apr 16, 2021

lll does not automatically fix long lines for when using the --fix flag with golangci-lint. This is a convenience that golines would be able to provide.

@colinking
Copy link

@ldez if golines offered separate lint and fix modes which could be toggled via the --fix flag to golangci-lint, then could golines be added as a public linter? I'd love to see it since all of our linting/formatting goes through golangci-lint. I'd be happy to contribute here and downstream to golines to help get this through.

@ldez
Copy link
Member

ldez commented Jul 15, 2021

We already have lll to handle long lines, the lll code is inside golangci-lint.
A fix mode can be added to lll.
FYI I plan to rethink the fix/suggestion system inside golangci-lint.

@vitorf7
Copy link

vitorf7 commented Nov 8, 2022

@ldez One of the biggest gripes I have with lll is that it just looks and cares about a line length.
It does not take into account comments and struct tags. On the other hand golines takes that into account and it could fix comments with specific flags. I have added the request to maybe add a --lint flag or something so that it would have both linting and formatting functionality which means then it could definitely be used along with golangci-lint

matthewhughes-uw added a commit to utilitywarehouse/manifest-checkers that referenced this issue Feb 9, 2024
The motivation here is have to think less about code formatting when
writing code, e.g. " Should I break this long list of args up? Should I
add a newline between all of these args".

The `golangci-lint` team don't want to inlcude this there for reasons[1]
so run it instead via `pre-commit`.

This is using a fork which just has one extra commit[2] until [3] is
merged upstream

[1] golangci/golangci-lint#1914
[2] segmentio/golines@dedb5a0
[3] segmentio/golines#103
@ldez ldez added the linter: new Support new linter label Dec 30, 2024
@ldez ldez removed the declined label Feb 17, 2025
@ldez ldez reopened this Feb 17, 2025
@ldez ldez closed this as completed Feb 19, 2025
@dapick
Copy link

dapick commented Mar 9, 2025

Hi @ldez!
Thank you for making this needed change :)
I want to add golines to our golangci-lint configuration, but I'm having trouble making it work.
Also, I saw there is an effort to add a new 'fmt' action to run the formatters, but it is not available either :(
Are there more steps that need to be done so it can be used?

@ldez
Copy link
Member

ldez commented Mar 9, 2025

For now, golines and golangci-lint fmt are not inside a release.
You should wait for the v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linter: new Support new linter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants