.golangci.yml 7.8 KB

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