-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore: Bump golangci-lint to v2 #2083
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
Conversation
b6c9093
to
7a86e4d
Compare
7a86e4d
to
0aa0c60
Compare
.github/workflows/lint.yml
Outdated
staticcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
|
||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up staticcheck | ||
run: go install honnef.co/go/tools/cmd/staticcheck@latest | ||
|
||
- name: Run staticcheck | ||
run: staticcheck ./... | ||
|
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.
Why remove it? Does new golang-ci-lint v2 include staticcheck?
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.
Yes it's included. https://golangci-lint.run/usage/linters/#enabled-by-default
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.
Just FYI, the staticcheck
linter in Golangci-lint V1 is not the same as the standalone Staticcheck linter. The V1 docs included an additional statement that says (golangci/golangci-lint#2894):
It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint.
This statement has been removed in V2.
In V1, stylecheck
, gosimple,
and staticcheck
cover the 4 options of the standalone Staticcheck linter. They have been merged in golangci/golangci-lint#5487, that means the staticcheck
in Golangci-lint V2 now actually works like the standalone Staticcheck linter.
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.
thanks for the context!
I think with v2 we should be safe unless I'm missing something?
.golangci.yaml
Outdated
exclusions: | ||
generated: lax | ||
presets: | ||
- comments | ||
- common-false-positives | ||
- legacy | ||
- std-error-handling | ||
paths: | ||
- third_party$ | ||
- builtin$ | ||
- examples$ | ||
formatters: | ||
exclusions: | ||
generated: lax | ||
paths: | ||
- third_party$ | ||
- builtin$ | ||
- examples$ |
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.
Did you copy this config from somewhere else? Because we only have the examples
directory https://github.com/urfave/cli/tree/main/examples
Since our examples code are minimal, I think we should be able to include them in the linter too and not cause any errors. What do you think?
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.
This was auto-generated by golangci-lint migrate. I think right now it passes lint, so we can keep it like that.
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
`actions/setup-go` uses `go.sum` file as the cache key. The CI needs to clone the repository first in order to restore the cache properly. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
|
||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
|
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.
What type of PR is this?
What this PR does / why we need it:
Bumps to golangci-lint v2.
Which issue(s) this PR fixes:
None
Special notes for your reviewer:
(fill-in or delete this section)
Testing
(fill-in or delete this section)
Release Notes
(REQUIRED)