- 
                Notifications
    
You must be signed in to change notification settings  - Fork 711
 
[CI] Update golangci to v2 #4048
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,167 +1,233 @@ | ||
| --- | ||
| version: "2" | ||
| 
     | 
||
| run: | ||
| concurrency: 6 | ||
| timeout: 5m | ||
| modules-download-mode: readonly | ||
| 
     | 
||
| issues: | ||
| max-issues-per-linter: 0 | ||
| max-same-issues: 0 | ||
| 
     | 
||
| linters: | ||
| disable-all: true | ||
| default: none | ||
| enable: | ||
| - depguard | ||
| - gofmt | ||
| - goimports | ||
| 
         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. They are now "formatters".  | 
||
| - govet | ||
| - ineffassign | ||
| - misspell | ||
| - nakedret | ||
| - prealloc | ||
| - typecheck | ||
| 
         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. No longer a linter and cannot be disabled.  | 
||
| # - asciicheck | ||
| # - bodyclose | ||
| # - dogsled | ||
| # - dupl | ||
| # - errcheck | ||
| # - errorlint | ||
| # - exhaustive | ||
| # - exhaustivestruct | ||
| # - exportloopref | ||
| # - funlen | ||
| # - gci | ||
| # - gochecknoglobals | ||
| # - gochecknoinits | ||
| # - gocognit | ||
| # - goconst | ||
| # - gocritic | ||
| # - gocyclo | ||
| # - godot | ||
| # - godox | ||
| # - goerr113 | ||
| # - gofumpt | ||
| # - goheader | ||
| # - golint | ||
| # - gomnd | ||
| # - gomodguard | ||
| # - goprintffuncname | ||
| # - gosec (gas) | ||
| - gosimple # (megacheck) | ||
| 
         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. Now part of staticcheck.  | 
||
| # - interfacer | ||
| # - lll | ||
| # - maligned | ||
| # - nestif | ||
| # - nlreturn | ||
| # - noctx | ||
| # - nolintlint | ||
| - revive | ||
| # - rowserrcheck | ||
| # - scopelint | ||
| # - sqlclosecheck | ||
| - staticcheck | ||
| - stylecheck | ||
| # - testpackage | ||
| # - tparallel | ||
| - unconvert | ||
| # - unparam | ||
| - unused | ||
| # - whitespace | ||
| # - wrapcheck | ||
| # - wsl | ||
| linters-settings: | ||
| gocritic: | ||
| enabled-checks: | ||
| # Diagnostic | ||
| - appendAssign | ||
| - argOrder | ||
| - badCond | ||
| - caseOrder | ||
| - codegenComment | ||
| - commentedOutCode | ||
| - deprecatedComment | ||
| - dupArg | ||
| - dupBranchBody | ||
| - dupCase | ||
| - dupSubExpr | ||
| - exitAfterDefer | ||
| - flagDeref | ||
| - flagName | ||
| - nilValReturn | ||
| - offBy1 | ||
| - sloppyReassign | ||
| - weakCond | ||
| - octalLiteral | ||
| 
     | 
||
| # Performance | ||
| - appendCombine | ||
| - equalFold | ||
| - hugeParam | ||
| - indexAlloc | ||
| - rangeExprCopy | ||
| - rangeValCopy | ||
| settings: | ||
| staticcheck: | ||
| checks: | ||
| # Below is the default set | ||
| - "all" | ||
| - "-ST1000" | ||
| - "-ST1003" | ||
| - "-ST1016" | ||
| - "-ST1020" | ||
| - "-ST1021" | ||
| - "-ST1022" | ||
| # FIXME: this below this point is disabled for now, but we should investigate | ||
| - "-QF1008" # Omit embedded fields from selector expression https://staticcheck.dev/docs/checks#QF1008 | ||
| - "-QF1003" # Convert if/else-if chain to tagged switch https://staticcheck.dev/docs/checks#QF1003 | ||
| - "-QF1009" # Use time.Time.Equal instead of == operator https://staticcheck.dev/docs/checks#QF1009 | ||
| - "-QF1001" # Apply De Morgan’s law https://staticcheck.dev/docs/checks#QF1001 | ||
| - "-QF1012" # Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...)) https://staticcheck.dev/docs/checks#QF1012 | ||
| - "-ST1005" # Expand call to math.Pow https://staticcheck.dev/docs/checks#QF1005 | ||
| - "-QF1004" # Use strings.ReplaceAll instead of strings.Replace with n == -1 https://staticcheck.dev/docs/checks#QF1004 | ||
| revive: | ||
| enable-all-rules: true | ||
| rules: | ||
| # See https://revive.run/r | ||
| # Below are unsorted, and we might want to review them to decide which one we want to enable | ||
| - name: exported | ||
                
      
                  apostasie marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| disabled: true | ||
| - name: add-constant | ||
| disabled: true | ||
| - name: cognitive-complexity | ||
| disabled: true | ||
| - name: package-comments | ||
| disabled: true | ||
| - name: cyclomatic | ||
| disabled: true | ||
| - name: deep-exit | ||
| disabled: true | ||
| - name: function-length | ||
| disabled: true | ||
| - name: flag-parameter | ||
| disabled: true | ||
| - name: max-public-structs | ||
| disabled: true | ||
| - name: max-control-nesting | ||
| disabled: true | ||
| - name: confusing-results | ||
| disabled: true | ||
| - name: nested-structs | ||
| disabled: true | ||
| - name: import-alias-naming | ||
| disabled: true | ||
| - name: filename-format | ||
| disabled: true | ||
| - name: use-any | ||
| disabled: true | ||
| # FIXME: we should enable these below | ||
| - name: struct-tag | ||
| disabled: true | ||
| - name: redundant-import-alias | ||
| disabled: true | ||
| - name: empty-lines | ||
| disabled: true | ||
| - name: unhandled-error | ||
| disabled: true | ||
| - name: confusing-naming | ||
| disabled: true | ||
| - name: unused-parameter | ||
| disabled: true | ||
| - name: unused-receiver | ||
| disabled: true | ||
| - name: import-shadowing | ||
| disabled: true | ||
| - name: use-errors-new | ||
| disabled: true | ||
| - name: argument-limit | ||
| disabled: true | ||
| - name: time-equal | ||
| disabled: true | ||
| - name: defer | ||
| disabled: true | ||
| - name: early-return | ||
| disabled: true | ||
| - name: comment-spacings | ||
| disabled: true | ||
| - name: function-result-limit | ||
| disabled: true | ||
| - name: unexported-naming | ||
| disabled: true | ||
| - name: unnecessary-stmt | ||
| disabled: true | ||
| - name: if-return | ||
| disabled: true | ||
| - name: unchecked-type-assertion | ||
| disabled: true | ||
| - name: bare-return | ||
| disabled: true | ||
| # Below have been reviewed and disabled | ||
| - name: line-length-limit | ||
| # Better dealt with by formatter golines | ||
| disabled: true | ||
| 
     | 
||
| # Style | ||
| - assignOp | ||
| - boolExprSimplify | ||
| - captLocal | ||
| - commentFormatting | ||
| - commentedOutImport | ||
| - defaultCaseOrder | ||
| - docStub | ||
| - elseif | ||
| - emptyFallthrough | ||
| - emptyStringTest | ||
| - hexLiteral | ||
| - ifElseChain | ||
| - methodExprCall | ||
| - regexpMust | ||
| - singleCaseSwitch | ||
| - sloppyLen | ||
| - stringXbytes | ||
| - switchTrue | ||
| - typeAssertChain | ||
| - typeSwitchVar | ||
| - underef | ||
| - unlabelStmt | ||
| - unlambda | ||
| - unslice | ||
| - valSwap | ||
| - wrapperFunc | ||
| - yodaStyleExpr | ||
| depguard: | ||
| rules: | ||
| no-patent: | ||
| # do not link in golang-lru anywhere (problematic patent) | ||
| deny: | ||
| - pkg: github.com/hashicorp/golang-lru/arc/v2 | ||
| desc: patented (https://github.com/hashicorp/golang-lru/blob/arc/v2.0.7/arc/arc.go#L18) | ||
| pkg: | ||
| # pkg files must not depend on cobra nor anything in cmd | ||
| files: | ||
| - '**/pkg/**/*.go' | ||
| deny: | ||
| - pkg: github.com/spf13/cobra | ||
| desc: pkg must not depend on cobra | ||
| - pkg: github.com/spf13/pflag | ||
| desc: pkg must not depend on pflag | ||
| - pkg: github.com/spf13/viper | ||
| desc: pkg must not depend on viper | ||
| - pkg: github.com/containerd/nerdctl/v2/cmd | ||
| desc: pkg must not depend on any cmd files | ||
| gocritic: | ||
| enabled-checks: | ||
| - appendAssign | ||
| - argOrder | ||
| - badCond | ||
| - caseOrder | ||
| - codegenComment | ||
| - commentedOutCode | ||
| - deprecatedComment | ||
| - dupArg | ||
| - dupBranchBody | ||
| - dupCase | ||
| - dupSubExpr | ||
| - exitAfterDefer | ||
| - flagDeref | ||
| - flagName | ||
| - nilValReturn | ||
| - offBy1 | ||
| - sloppyReassign | ||
| - weakCond | ||
| - octalLiteral | ||
| - appendCombine | ||
| - equalFold | ||
| - hugeParam | ||
| - indexAlloc | ||
| - rangeExprCopy | ||
| - rangeValCopy | ||
| - assignOp | ||
| - boolExprSimplify | ||
| - captLocal | ||
| - commentFormatting | ||
| - commentedOutImport | ||
| - defaultCaseOrder | ||
| - docStub | ||
| - elseif | ||
| - emptyFallthrough | ||
| - emptyStringTest | ||
| - hexLiteral | ||
| - ifElseChain | ||
| - methodExprCall | ||
| - regexpMust | ||
| - singleCaseSwitch | ||
| - sloppyLen | ||
| - stringXbytes | ||
| - switchTrue | ||
| - typeAssertChain | ||
| - typeSwitchVar | ||
| - underef | ||
| - unlabelStmt | ||
| - unlambda | ||
| - unslice | ||
| - valSwap | ||
| - wrapperFunc | ||
| - yodaStyleExpr | ||
| - builtinShadow | ||
| - importShadow | ||
| - initClause | ||
| - nestingReduce | ||
| - paramTypeCombine | ||
| - ptrToRefParam | ||
| - typeUnparen | ||
| - unnamedResult | ||
| - unnecessaryBlock | ||
| exclusions: | ||
| generated: disable | ||
| 
     | 
||
| # Opinionated | ||
| - builtinShadow | ||
| - importShadow | ||
| - initClause | ||
| - nestingReduce | ||
| - paramTypeCombine | ||
| - ptrToRefParam | ||
| - typeUnparen | ||
| - unnamedResult | ||
| - unnecessaryBlock | ||
| 
     | 
||
| depguard: | ||
| rules: | ||
| # pkg files must not depend on cobra nor anything in cmd | ||
| pkg: | ||
| files: | ||
| - "**/pkg/**/*.go" | ||
| deny: | ||
| - pkg: "github.com/spf13/cobra" | ||
| desc: "pkg must not depend on cobra" | ||
| - pkg: "github.com/spf13/pflag" | ||
| desc: "pkg must not depend on pflag" | ||
| - pkg: "github.com/spf13/viper" | ||
| desc: "pkg must not depend on viper" | ||
| - pkg: "github.com/containerd/nerdctl/v2/cmd" | ||
| desc: "pkg must not depend on any cmd files" | ||
| no-patent: | ||
| deny: | ||
| - pkg: "github.com/hashicorp/golang-lru/arc/v2" | ||
| desc: "patented (https://github.com/hashicorp/golang-lru/blob/arc/v2.0.7/arc/arc.go#L18)" | ||
| 
     | 
||
| issues: | ||
| max-issues-per-linter: 0 | ||
| max-same-issues: 0 | ||
| exclude-rules: | ||
| - linters: | ||
| - revive | ||
| text: "unused-parameter" | ||
| 
     | 
||
| output: | ||
| sort-results: true | ||
| formatters: | ||
| settings: | ||
| gci: | ||
| sections: | ||
| - standard | ||
| 
         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. gci is what replaces our import reviser and that configuration defines how we want our import sectioned.  | 
||
| - default | ||
| - prefix(github.com/containerd) | ||
| - localmodule | ||
| no-inline-comments: true | ||
| no-prefix-comments: true | ||
| custom-order: true | ||
| gofumpt: | ||
| extra-rules: true | ||
| golines: | ||
| max-len: 100 | ||
| tab-len: 4 | ||
| shorten-comments: true | ||
| enable: | ||
| - gci | ||
| - gofmt | ||
| # We might consider enabling the following: | ||
| # - gofumpt | ||
| # - golines | ||
| exclusions: | ||
| generated: disable | ||
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.
concurrency does not help - we should let it pick whatever matches max proc.
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.
timeout here does not help either - we have timeouts everywhere, and it is hard to figure out which ones kicks when.
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.
The idea was to limit the CI to avoid overflow and optimize.