.golangci.yml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. linters-settings:
  2. govet:
  3. check-shadowing: true
  4. misspell:
  5. locale: US
  6. exhaustive:
  7. default-signifies-exhaustive: true
  8. gomodguard:
  9. blocked:
  10. modules:
  11. - github.com/pkg/errors:
  12. recommendations:
  13. - errors
  14. linters:
  15. enable:
  16. - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
  17. - bidichk # Checks for dangerous unicode character sequences
  18. - bodyclose # checks whether HTTP response body is closed successfully
  19. - contextcheck # check the function whether use a non-inherited context
  20. - decorder # check declaration order and count of types, constants, variables and functions
  21. - depguard # Go linter that checks if package imports are in a list of acceptable packages
  22. - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
  23. - dupl # Tool for code clone detection
  24. - durationcheck # check for two durations multiplied together
  25. - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
  26. - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted.
  27. - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
  28. - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
  29. - exhaustive # check exhaustiveness of enum switch statements
  30. - exportloopref # checks for pointers to enclosing loop variables
  31. - forcetypeassert # finds forced type assertions
  32. - gci # Gci control golang package import order and make it always deterministic.
  33. - gochecknoglobals # Checks that no globals are present in Go code
  34. - gochecknoinits # Checks that no init functions are present in Go code
  35. - gocognit # Computes and checks the cognitive complexity of functions
  36. - goconst # Finds repeated strings that could be replaced by a constant
  37. - gocritic # The most opinionated Go source code linter
  38. - godox # Tool for detection of FIXME, TODO and other comment keywords
  39. - goerr113 # Golang linter to check the errors handling expressions
  40. - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
  41. - gofumpt # Gofumpt checks whether code was gofumpt-ed.
  42. - goheader # Checks is file header matches to pattern
  43. - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
  44. - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
  45. - gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
  46. - goprintffuncname # Checks that printf-like functions are named with `f` at the end
  47. - gosec # Inspects source code for security problems
  48. - gosimple # Linter for Go source code that specializes in simplifying a code
  49. - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
  50. - grouper # An analyzer to analyze expression groups.
  51. - importas # Enforces consistent import aliases
  52. - ineffassign # Detects when assignments to existing variables are not used
  53. - misspell # Finds commonly misspelled English words in comments
  54. - nakedret # Finds naked returns in functions greater than a specified function length
  55. - nilerr # Finds the code that returns nil even if it checks that the error is not nil.
  56. - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value.
  57. - noctx # noctx finds sending http request without context.Context
  58. - predeclared # find code that shadows one of Go's predeclared identifiers
  59. - revive # golint replacement, finds style mistakes
  60. - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
  61. - stylecheck # Stylecheck is a replacement for golint
  62. - tagliatelle # Checks the struct tags.
  63. - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
  64. - tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
  65. - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
  66. - unconvert # Remove unnecessary type conversions
  67. - unparam # Reports unused function parameters
  68. - unused # Checks Go code for unused constants, variables, functions and types
  69. - wastedassign # wastedassign finds wasted assignment statements
  70. - whitespace # Tool for detection of leading and trailing whitespace
  71. disable:
  72. - containedctx # containedctx is a linter that detects struct contained context.Context field
  73. - cyclop # checks function and package cyclomatic complexity
  74. - exhaustivestruct # Checks if all struct's fields are initialized
  75. - forbidigo # Forbids identifiers
  76. - funlen # Tool for detection of long functions
  77. - gocyclo # Computes and checks the cyclomatic complexity of functions
  78. - godot # Check if comments end in a period
  79. - gomnd # An analyzer to detect magic numbers.
  80. - ifshort # Checks that your code uses short syntax for if-statements whenever possible
  81. - ireturn # Accept Interfaces, Return Concrete Types
  82. - lll # Reports long lines
  83. - maintidx # maintidx measures the maintainability index of each function.
  84. - makezero # Finds slice declarations with non-zero initial length
  85. - maligned # Tool to detect Go structs that would take less memory if their fields were sorted
  86. - nestif # Reports deeply nested if statements
  87. - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
  88. - nolintlint # Reports ill-formed or insufficient nolint directives
  89. - paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
  90. - prealloc # Finds slice declarations that could potentially be preallocated
  91. - promlinter # Check Prometheus metrics naming via promlint
  92. - rowserrcheck # checks whether Err of rows is checked successfully
  93. - sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
  94. - testpackage # linter that makes you use a separate _test package
  95. - thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
  96. - varnamelen # checks that the length of a variable's name matches its scope
  97. - wrapcheck # Checks that errors returned from external packages are wrapped
  98. - wsl # Whitespace Linter - Forces you to use empty lines!
  99. issues:
  100. exclude-use-default: false
  101. exclude-rules:
  102. # Allow complex tests, better to be self contained
  103. - path: _test\.go
  104. linters:
  105. - gocognit
  106. # Allow complex main function in examples
  107. - path: examples
  108. text: "of func `main` is high"
  109. linters:
  110. - gocognit
  111. run:
  112. skip-dirs-use-default: false