.golangci.yaml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. linters:
  2. enable:
  3. # Some of the linters below are commented out. We should uncomment and start running them, but they return
  4. # too many problems to fix in one commit. Something for later.
  5. - asasalint # Check for pass []any as any in variadic func(...any).
  6. - asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name.
  7. - bidichk # Checks for dangerous unicode character sequences.
  8. - bodyclose # Checks whether HTTP response body is closed successfully.
  9. - decorder # Check declaration order and count of types, constants, variables and functions.
  10. - dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f()).
  11. - dupl # Tool for code clone detection.
  12. - dupword # Checks for duplicate words in the source code.
  13. - durationcheck # Check for two durations multiplied together.
  14. - errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.
  15. - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
  16. - exhaustive # Check exhaustiveness of enum switch statements.
  17. - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification.
  18. - goimports # Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode.
  19. - gosec # Inspects source code for security problems.
  20. - gosimple # Linter for Go source code that specializes in simplifying code.
  21. - govet # Vet examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes.
  22. - ineffassign # Detects when assignments to existing variables are not used.
  23. - importas # Enforces consistent import aliases.
  24. - misspell # Finds commonly misspelled English words.
  25. - prealloc # Finds slice declarations that could potentially be pre-allocated.
  26. - promlinter # Check Prometheus metrics naming via promlint.
  27. - sloglint # Ensure consistent code style when using log/slog.
  28. - sqlclosecheck # Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed.
  29. - staticcheck # It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary.
  30. - tenv # Tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17.
  31. - testableexamples # Linter checks if examples are testable (have an expected output).
  32. - testifylint # Checks usage of github.com/stretchr/testify.
  33. - tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes.
  34. - unconvert # Remove unnecessary type conversions.
  35. - unused # Checks Go code for unused constants, variables, functions and types.
  36. - wastedassign # Finds wasted assignment statements.
  37. - whitespace # Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.
  38. - zerologlint # Detects the wrong usage of zerolog that a user forgets to dispatch with Send or Msg.
  39. # Other linters are disabled, list of all is here: https://golangci-lint.run/usage/linters/
  40. run:
  41. timeout: 5m
  42. modules-download-mode: vendor
  43. # output configuration options
  44. output:
  45. formats:
  46. - format: 'colored-line-number'
  47. print-issued-lines: true
  48. print-linter-name: true
  49. issues:
  50. # Maximum issues count per one linter.
  51. # Set to 0 to disable.
  52. # Default: 50
  53. max-issues-per-linter: 50
  54. # Maximum count of issues with the same text.
  55. # Set to 0 to disable.
  56. # Default: 3
  57. max-same-issues: 15
  58. # Show only new issues: if there are unstaged changes or untracked files,
  59. # only those changes are analyzed, else only changes in HEAD~ are analyzed.
  60. # It's a super-useful option for integration of golangci-lint into existing large codebase.
  61. # It's not practical to fix all existing issues at the moment of integration:
  62. # much better don't allow issues in new code.
  63. #
  64. # Default: false
  65. new: true
  66. # Show only new issues created after git revision `REV`.
  67. # Default: ""
  68. new-from-rev: ac34f94d423273c8fa8fdbb5f2ac60e55f2c77d5
  69. # Show issues in any part of update files (requires new-from-rev or new-from-patch).
  70. # Default: false
  71. whole-files: true
  72. # Which dirs to exclude: issues from them won't be reported.
  73. # Can use regexp here: `generated.*`, regexp is applied on full path,
  74. # including the path prefix if one is set.
  75. # Default dirs are skipped independently of this option's value (see exclude-dirs-use-default).
  76. # "/" will be replaced by current OS file path separator to properly work on Windows.
  77. # Default: []
  78. exclude-dirs:
  79. - vendor
  80. linters-settings:
  81. # Check exhaustiveness of enum switch statements.
  82. exhaustive:
  83. # Presence of "default" case in switch statements satisfies exhaustiveness,
  84. # even if all enum members are not listed.
  85. # Default: false
  86. default-signifies-exhaustive: true