-
Notifications
You must be signed in to change notification settings - Fork 207
chore: Upgrades golangci-lint to v2 #3224
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
@@ -1,134 +1,117 @@ | ||
linters-settings: | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
govet: | ||
enable-all: true | ||
|
||
revive: | ||
# see https://github.com/mgechev/revive#available-rules for details. | ||
ignore-generated-header: true | ||
severity: warning | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: dot-imports | ||
- name: error-return | ||
- name: error-strings | ||
- name: error-naming | ||
- name: errorf | ||
- name: exported | ||
- name: indent-error-flow | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: var-naming | ||
- name: var-declaration | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: indent-error-flow | ||
- name: errorf | ||
- name: empty-block | ||
- name: superfluous-else | ||
- name: struct-tag | ||
# Too many unusued parameters, skipping this check for now | ||
#- name: unused-parameter | ||
- name: unreachable-code | ||
- name: redefines-builtin-id | ||
misspell: | ||
locale: US | ||
ignore-words: | ||
- cancelled | ||
lll: | ||
# Default is 120. '\t' is counted as 1 character. | ||
# set our project to 500, as we are adding open api field description in the schema. | ||
# also, for anyone using vscode, use the following configs: | ||
# "rewrap.wrappingColumn": 500 ... requires the rewrap plugin | ||
# "editor.rulers": [500] | ||
line-length: 500 | ||
nestif: | ||
# minimal complexity of if statements to report, 5 by default | ||
min-complexity: 7 | ||
mnd: | ||
checks: | ||
- case | ||
- operation | ||
- return | ||
funlen: | ||
lines: 360 | ||
statements: 120 | ||
version: "2" | ||
run: | ||
modules-download-mode: readonly | ||
tests: true | ||
linters: | ||
disable-all: true | ||
default: none | ||
enable: | ||
- copyloopvar | ||
- dogsled | ||
- errcheck | ||
- exhaustive | ||
- funlen | ||
- gocritic | ||
- gofmt | ||
- goimports | ||
- revive | ||
- mnd | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
- makezero | ||
- misspell | ||
- mnd | ||
- nakedret | ||
- noctx | ||
- nolintlint | ||
- revive | ||
- rowserrcheck | ||
- copyloopvar | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unused | ||
- whitespace | ||
- thelper | ||
- testifylint | ||
- exhaustive | ||
- makezero | ||
- noctx | ||
- testpackage | ||
- thelper | ||
- unconvert | ||
- unused | ||
- usetesting | ||
- whitespace | ||
|
||
# don't enable: | ||
# - tenv # The linter 'tenv' is deprecated (since v1.64.0) due to: Duplicate feature another linter. Replaced by usetesting. | ||
# - deadcode | ||
# - varcheck | ||
# - structcheck | ||
# - depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false] | ||
# - gocyclo # we already have funlen lint | ||
# - dupl # we have a lot of duplicate test cases | ||
# - gochecknoinits # we need the init function for the provider | ||
# - gochecknoglobals # we need some global variables | ||
# - unparam # Forces to create global variables when one variable is repeated in different functions | ||
# - goerr113 # It does not allow you to return an error, you need to save the error in a variable to do it | ||
# - goconst | ||
# - gocognit | ||
issues: | ||
exclude: | ||
- declaration of ".*" shadows declaration at line .* | ||
exclude-rules: | ||
- linters: | ||
- staticcheck | ||
text: "SA1019:" # d.GetOkExists is deprecated: usage is discouraged due to undefined behaviors and may be removed in a future version of the SDK | ||
- linters: | ||
- gocritic | ||
text: "^hugeParam: req is heavy" | ||
- path: "schema\\.go" # exclude rules for schema files as it's auto-genereated from OpenAPI spec | ||
text: "fieldalignment|hugeParam|var-naming|ST1003|S1007|exceeds the maximum|too long|regexpSimplify|nolint" | ||
run: | ||
timeout: 10m | ||
tests: true | ||
build-tags: | ||
- integration | ||
modules-download-mode: readonly | ||
settings: | ||
funlen: | ||
lines: 360 | ||
statements: 120 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
govet: | ||
enable-all: true | ||
lll: | ||
# Default is 120. '\t' is counted as 1 character. | ||
# set our project to 500, as we are adding open api field description in the schema. | ||
# also, for anyone using vscode, use the following configs: | ||
# "rewrap.wrappingColumn": 500 ... requires the rewrap plugin | ||
# "editor.rulers": [500] | ||
line-length: 500 | ||
misspell: | ||
locale: US | ||
ignore-rules: | ||
- cancelled | ||
mnd: | ||
checks: | ||
- case | ||
- operation | ||
- return | ||
nestif: | ||
min-complexity: 7 | ||
revive: | ||
severity: warning | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: dot-imports | ||
- name: error-return | ||
- name: error-strings | ||
- name: error-naming | ||
- name: errorf | ||
- name: exported | ||
- name: indent-error-flow | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: var-naming | ||
- name: var-declaration | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: indent-error-flow | ||
- name: errorf | ||
- name: empty-block | ||
- name: superfluous-else | ||
- name: struct-tag | ||
- name: unreachable-code | ||
- name: redefines-builtin-id | ||
exclusions: | ||
generated: lax | ||
presets: | ||
- comments | ||
- common-false-positives | ||
- legacy | ||
- std-error-handling | ||
rules: | ||
- linters: | ||
- staticcheck | ||
text: "SA1019:" # d.GetOkExists is deprecated: usage is discouraged due to undefined behaviors and may be removed in a future version of the SDK | ||
- linters: | ||
- gocritic | ||
text: "^hugeParam: req is heavy" | ||
- path: schema\.go # exclude rules for schema files as it's auto-genereated from OpenAPI spec | ||
text: fieldalignment|hugeParam|var-naming|ST1003|S1007|exceeds the maximum|too long|regexpSimplify|nolint | ||
- path: (.+)\.go$ | ||
text: declaration of ".*" shadows declaration at line .* | ||
formatters: | ||
enable: | ||
- gofmt | ||
- goimports |
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 |
---|---|---|
|
@@ -105,7 +105,7 @@ func TestSafeValue(t *testing.T) { | |
var intPointer *int | ||
assert.Equal(t, 0, conversion.SafeValue(intPointer)) | ||
var stringPointer *string | ||
assert.Equal(t, "", conversion.SafeValue(stringPointer)) | ||
assert.Empty(t, conversion.SafeValue(stringPointer)) | ||
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. fixes: empty: use assert.NotEmpty (testifylint) |
||
} | ||
|
||
func TestNilForUnknownOrEmpty(t *testing.T) { | ||
|
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 |
---|---|---|
|
@@ -358,7 +358,7 @@ func validateDeliveryType(dt []any) error { | |
oplogInc, oplogIncOk := v["oplog_inc"] | ||
isOpIncSet := oplogIncOk && oplogInc != nil && (oplogInc.(int) > 0) | ||
|
||
if !isPITSet && !(isOpTSSet && isOpIncSet) { | ||
if !isPITSet && (!isOpTSSet || !isOpIncSet) { | ||
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. fixes: QF1001: could apply De Morgan's law (staticcheck) |
||
return fmt.Errorf("%q point_in_time_utc_seconds or oplog_ts and oplog_inc must be set", key) | ||
} | ||
if isPITSet && (isOpTSSet || isOpIncSet) { | ||
|
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
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.
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.
fixes: len: use assert.Len (testifylint)