-
Notifications
You must be signed in to change notification settings - Fork 30
feat(ci): migrate to golangci-lint v2 #7302
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
Open
rubenhoenle
wants to merge
1
commit into
main
Choose a base branch
from
feat/golang-ci-lint-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,7 +183,7 @@ func (c *KeyFlow) SetToken(accessToken, refreshToken string) error { | |
| c.tokenMutex.Lock() | ||
| c.token = &TokenResponseBody{ | ||
| AccessToken: accessToken, | ||
| ExpiresIn: int(exp.Time.Unix()), | ||
| ExpiresIn: int(exp.Unix()), | ||
| RefreshToken: refreshToken, | ||
| Scope: defaultScope, | ||
| TokenType: defaultTokenType, | ||
|
|
@@ -334,6 +334,7 @@ func (c *KeyFlow) createAccessToken() (err error) { | |
|
|
||
| // createAccessTokenWithRefreshToken creates an access token using | ||
| // an existing pre-validated refresh token | ||
| // | ||
| // Deprecated: This method will be removed in future versions. Access tokens are going to be refreshed without refresh token. | ||
| // This will be removed after 2026-07-01. | ||
| func (c *KeyFlow) createAccessTokenWithRefreshToken() (err error) { | ||
|
|
@@ -391,11 +392,11 @@ func (c *KeyFlow) requestToken(grant, assertion string) (*http.Response, error) | |
| } | ||
|
|
||
| payload := strings.NewReader(body.Encode()) | ||
| req, err := http.NewRequest(http.MethodPost, c.config.TokenUrl, payload) | ||
| req, err := http.NewRequest(http.MethodPost, c.config.TokenUrl, payload) //nolint:gosec // G704: Tainted URL is expected here | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also disable this one |
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| req.Header.Add("Content-Type", "application/x-www-form-urlencoded") | ||
|
|
||
| return c.authClient.Do(req) | ||
| return c.authClient.Do(req) //nolint:gosec // G704: Tainted URL is expected here | ||
| } | ||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,102 +1,99 @@ | ||
| # This file contains all available configuration options | ||
| # with their default values. | ||
|
|
||
| version: "2" | ||
|
|
||
| # options for analysis running | ||
| run: | ||
| # default concurrency is a available CPU number | ||
| concurrency: 4 | ||
|
|
||
| # timeout for analysis, e.g. 30s, 5m, default is 1m | ||
| timeout: 5m | ||
| linters-settings: | ||
| goimports: | ||
| # put imports beginning with prefix after 3rd-party packages; | ||
| # it's a comma-separated list of prefixes | ||
| local-prefixes: github.com/stackitcloud/stackit-sdk-go | ||
| depguard: | ||
| rules: | ||
| main: | ||
| list-mode: lax # Everything is allowed unless it is denied | ||
| deny: | ||
| - pkg: "github.com/stretchr/testify" | ||
| desc: Do not use a testing framework | ||
| misspell: | ||
| # Correct spellings using locale preferences for US or UK. | ||
| # Default is to use a neutral variety of English. | ||
| # Setting locale to US will correct the British spelling of 'colour' to 'color'. | ||
| locale: US | ||
| golint: | ||
| min-confidence: 0.8 | ||
| gosec: | ||
| excludes: | ||
| # Suppressions: (see https://github.com/securego/gosec#available-rules for details) | ||
| - G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck | ||
| - G102 # "Bind to all interfaces" -> since this is normal in k8s | ||
| - G304 # "File path provided as taint input" -> too many false positives | ||
| - G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close() | ||
| nakedret: | ||
| max-func-lines: 0 | ||
| revive: | ||
| ignore-generated-header: true | ||
| severity: error | ||
| # https://github.com/mgechev/revive | ||
| rules: | ||
| - name: errorf | ||
| - name: context-as-argument | ||
| - name: error-return | ||
| - name: increment-decrement | ||
| - name: indent-error-flow | ||
| - name: superfluous-else | ||
| - name: unused-parameter | ||
| - name: unreachable-code | ||
| - name: atomic | ||
| - name: empty-lines | ||
| - name: early-return | ||
| gocritic: | ||
| enabled-tags: | ||
| - performance | ||
| - style | ||
| - experimental | ||
| disabled-checks: | ||
| - wrapperFunc | ||
| - typeDefFirst | ||
| - ifElseChain | ||
| - dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
| linters: | ||
| enable: | ||
| # https://golangci-lint.run/usage/linters/ | ||
| # default linters | ||
| - gosimple | ||
| - govet | ||
| - ineffassign | ||
| - staticcheck | ||
| - typecheck | ||
| - unused | ||
| # additional linters | ||
| - bodyclose | ||
| - depguard | ||
| - errorlint | ||
| - forcetypeassert | ||
| - gochecknoinits | ||
| - gocritic | ||
| - gofmt | ||
| - goimports | ||
| - gosec | ||
| - misspell | ||
| - nakedret | ||
| - revive | ||
| - depguard | ||
| - bodyclose | ||
| - sqlclosecheck | ||
| - wastedassign | ||
| - forcetypeassert | ||
| - errcheck | ||
| disable: | ||
| - noctx # false positive: finds errors with http.NewRequest that dont make sense | ||
| - unparam # false positives | ||
| issues: | ||
| exclude-use-default: false | ||
| exclude-rules: | ||
| # This ignores all deprecation warnings in the old wait packages while we have the compatibilty layer in place | ||
| - path: ^wait/[^/]+\.go$ | ||
| linters: | ||
| - staticcheck | ||
| text: "SA1019:" | ||
| go: 1.25 | ||
| settings: | ||
| depguard: | ||
| rules: | ||
| main: | ||
| list-mode: lax # Everything is allowed unless it is denied | ||
| deny: | ||
| - pkg: github.com/stretchr/testify | ||
| desc: Do not use a testing framework | ||
| gocritic: | ||
| disabled-checks: | ||
| - wrapperFunc | ||
| - typeDefFirst | ||
| - ifElseChain | ||
| - dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
| enabled-tags: | ||
| - performance | ||
| - style | ||
| - experimental | ||
| gosec: | ||
| excludes: | ||
| # Suppressions: (see https://github.com/securego/gosec#available-rules for details) | ||
| - G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck | ||
| - G102 # "Bind to all interfaces" -> since this is normal in k8s | ||
| - G304 # "File path provided as taint input" -> too many false positives | ||
| - G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close() | ||
| misspell: | ||
| # Correct spellings using locale preferences for US or UK. | ||
| # Default is to use a neutral variety of English. | ||
| # Setting locale to US will correct the British spelling of 'colour' to 'color'. | ||
| locale: US | ||
| nakedret: | ||
| max-func-lines: 0 | ||
| revive: | ||
| severity: error | ||
| # https://github.com/mgechev/revive | ||
| rules: | ||
| - name: errorf | ||
| - name: context-as-argument | ||
| - name: error-return | ||
| - name: increment-decrement | ||
| - name: indent-error-flow | ||
| - name: superfluous-else | ||
| - name: unused-parameter | ||
| - name: unreachable-code | ||
| - name: atomic | ||
| - name: empty-lines | ||
| - name: early-return | ||
| exclusions: | ||
| generated: lax | ||
| rules: | ||
| - linters: | ||
| - staticcheck | ||
| # This ignores all deprecation warnings in the old wait packages while we have the compatibilty layer in place | ||
| path: wait/[^/]+\.go$ | ||
| text: "SA1019:" | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| formatters: | ||
| enable: | ||
| - gofmt | ||
| - goimports | ||
| settings: | ||
| goimports: | ||
| # put imports beginning with prefix after 3rd-party packages; | ||
| # it's a comma-separated list of prefixes | ||
| local-prefixes: | ||
| - github.com/stackitcloud/stackit-sdk-go | ||
| exclusions: | ||
| generated: lax | ||
| paths: | ||
| - third_party$ | ||
| - builtin$ |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
I'd disable this gosec rule, a lot of false positives and I'd expect no true positive in our code.