-
Notifications
You must be signed in to change notification settings - Fork 27
Add golang linters #22
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
base: master
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1,253 @@ | ||
| ######################### | ||
| ######################### | ||
| ## Golang Linter rules ## | ||
| ######################### | ||
| ######################### | ||
|
|
||
| # configure golangci-lint | ||
| # see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml | ||
| run: | ||
| # timeout for analysis, e.g. 30s, 5m, default is 1m | ||
| timeout: 10m | ||
|
|
||
| # which dirs to skip: they won't be analyzed; | ||
| # can use regexp here: generated.*, regexp is applied on full path; | ||
| # default value is empty list, but next dirs are always skipped independently | ||
| # from this option's value: | ||
| # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ | ||
| # skip-dirs: | ||
| # - genfiles$ | ||
| # - vendor$ | ||
| # include test files or not, default is true | ||
| tests: true | ||
| # which files to skip: they will be analyzed, but issues from them | ||
| # won't be reported. Default value is empty list, but there is | ||
| # no need to include all autogenerated files, we confidently recognize | ||
| # autogenerated files. If it's not please let us know. | ||
| # skip-files: | ||
| # - ".*\\.pb\\.go" | ||
| # - ".*\\.gen\\.go" | ||
|
|
||
|
|
||
| linters: | ||
| disable-all: true | ||
| # See https://golangci-lint.run/usage/linters/ for more information about the linters | ||
| # Enable specific linter | ||
| # https://golangci-lint.run/usage/linters/#enabled-by-default | ||
| enable: | ||
| # - asasalint | ||
| # - asciicheck | ||
| # - bidichk | ||
| # - bodyclose | ||
| # - canonicalheader | ||
| # - containedctx | ||
| # - contextcheck | ||
| # - copyloopvar | ||
| # - cyclop | ||
| # - decorder | ||
| # - depguard | ||
| # - dogsled | ||
| # - dupl | ||
| # - dupword | ||
| # - durationcheck | ||
| # - err113 | ||
| - errcheck | ||
| # - errchkjson | ||
| # - errname | ||
| - errorlint | ||
| # - execinquery | ||
| # - exhaustive | ||
| # - exhaustruct | ||
| # - exportloopref | ||
| # - fatcontext | ||
| # - forbidigo | ||
| # - forcetypeassert | ||
| # - funlen | ||
| - gci | ||
| # - ginkgolinter | ||
| # - gocheckcompilerdirectives | ||
| # - gochecknoglobals | ||
| # - gochecknoinits | ||
| # - gochecksumtype | ||
| # - gocognit | ||
| - goconst | ||
| - gocritic | ||
| # - gocyclo | ||
| # - godot | ||
| # - godox | ||
| # - gofmt | ||
| # - gofumpt | ||
| # - goheader | ||
| - goimports | ||
| # - gomoddirectives | ||
| # - gomodguard | ||
| - goprintffuncname | ||
| - gosec | ||
| - gosimple | ||
| # - gosmopolitan | ||
| - govet | ||
| # - grouper | ||
| # - importas | ||
| # - inamedparam | ||
| - ineffassign | ||
| # - interfacebloat | ||
| # - intrange | ||
| # - ireturn | ||
| # - lll | ||
| # - loggercheck | ||
| # - maintidx | ||
| # - makezero | ||
| # - mirror | ||
| - misspell | ||
| # - mnd | ||
| # - musttag | ||
| # - nakedret | ||
| # - nestif | ||
| # - nilerr | ||
| # - nilnil | ||
| # - nlreturn | ||
| # - noctx | ||
| # - nolintlint | ||
| # - nonamedreturns | ||
| # - nosprintfhostport | ||
| # - paralleltest | ||
| # - perfsprint | ||
| # - prealloc | ||
| # - predeclared | ||
| # - promlinter | ||
| # - protogetter | ||
| # - reassign | ||
| - revive | ||
| # - rowserrcheck | ||
| # - sloglint | ||
| # - spancheck | ||
| # - sqlclosecheck | ||
| - staticcheck | ||
| # - stylecheck | ||
| # - tagalign | ||
| # - tagliatelle | ||
| # - tenv | ||
| # - testableexamples | ||
| # - testifylint | ||
| # - testpackage | ||
| # - thelper | ||
| # - tparallel | ||
| # - unconvert | ||
| # - unparam | ||
| # - unused | ||
| # - usestdlibvars | ||
| # - varnamelen | ||
| # - wastedassign | ||
| - whitespace | ||
| # - wrapcheck | ||
| # - wsl | ||
| # - zerologlint | ||
| linters-settings: | ||
| errcheck: | ||
| # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; | ||
| # default is false: such cases aren't reported by default. | ||
| check-blank: false | ||
| # report about not checking of errors in type assertions: `a := b.(MyStruct)`; | ||
| # default is false: such cases aren't reported by default. | ||
| check-type-assertions: false | ||
| # List of functions to exclude from checking, where each entry is a single function to exclude. | ||
| # See https://github.com/kisielk/errcheck#excluding-functions for details. | ||
| exclude-functions: | ||
| - (*go.uber.org/zap.Logger).Sync | ||
| gci: | ||
| # list of prefixes to use for grouping imports | ||
| sections: | ||
| - standard | ||
| - default | ||
| - localmodule | ||
| govet: | ||
| # Enable all analyzers. | ||
| # Default: false | ||
| enable-all: true | ||
| # Disable analyzers by name. | ||
| disable: | ||
| - fieldalignment | ||
| - shadow | ||
| gocritic: | ||
| # Which checks should be enabled; can't be combined with 'disabled-checks'; | ||
| # See https://go-critic.github.io/overview#checks-overview | ||
| # To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run` | ||
| # By default list of stable checks is used. | ||
| # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty | ||
| disabled-checks: | ||
| - exitAfterDefer | ||
| - ifElseChain | ||
| - elseif | ||
| # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks. | ||
| # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". | ||
| enabled-tags: | ||
| - diagnostic | ||
| # - style | ||
| # - performance | ||
| # - experimental | ||
| # - opinionated | ||
| # disabled-tags: | ||
| # - experimental | ||
| settings: # settings passed to gocritic | ||
| # captLocal: # must be valid enabled check name | ||
| # paramsOnly: true | ||
| # rangeValCopy: | ||
| # sizeThreshold: 32 | ||
| gosec: | ||
| excludes: | ||
| - G112 # Potential slowloris attack | ||
| 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 | ||
| ignore-words: | ||
| - cancelled | ||
| revive: | ||
| rules: | ||
| - name: struct-tag | ||
| arguments: [ "json,inline" ] | ||
| - name: var-naming | ||
| arguments: | ||
| - [ "ID" ,"UUID" ] # Ignore list. The items in this list does not need to follow the rule of initialisms. https://go.dev/wiki/CodeReviewComments#initialisms | ||
| - ["GRPC"] # Deny list. Add custom initialisms to the linter. | ||
| - name: redundant-import-alias | ||
| - name: comment-spacings | ||
| - name: exported | ||
| arguments: | ||
| - disableStutteringCheck | ||
| - name: package-comments | ||
| unused: | ||
| # Mark all struct fields that have been written to as used. | ||
| # Default: true | ||
| field-writes-are-uses: true | ||
| # Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write. | ||
| # Default: false | ||
| post-statements-are-reads: false | ||
| # Mark all exported identifiers as used. | ||
| # Default: true | ||
| exported-is-used: true | ||
| # Mark all exported fields as used. | ||
| # default: true | ||
| exported-fields-are-used: false | ||
| # Mark all function parameters as used. | ||
| # default: true | ||
| parameters-are-used: true | ||
| # Mark all local variables as used. | ||
| # default: true | ||
| local-variables-are-used: true | ||
| # Mark all identifiers inside generated files as used. | ||
| # Default: true | ||
| generated-is-used: true | ||
| issues: | ||
| # Maximum issues count per one linter. Set to 0 to disable. Default is 50. | ||
| max-per-linter: 0 | ||
| # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. | ||
| max-same-issues: 0 | ||
| include: | ||
| - EXC0013 | ||
| - EXC0014 | ||
| exclude-dirs: | ||
| - clients/kubernetes/types # Exclude the kubernetes client types copied from external sources | ||
|
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. Will these exclude-dirs specific for a project ?
Author
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. Yes
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. Then we can't have this as the common rule? Does go linters allows to merge two rules files? So we can have one with the common rules here and each project can maintain project specific ones in each repos ? |
||
| output: | ||
| show-stats: true | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Will these exclude-functions specific for a project ?