.golangci.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. # This file contains all available configuration options
  2. # with their default values.
  3. service:
  4. suggested-changes:
  5. disabled: true
  6. # options for analysis running
  7. run:
  8. # default concurrency is a available CPU number
  9. concurrency: 4
  10. # timeout for analysis, e.g. 30s, 5m, default is 1m
  11. timeout: 5m
  12. # exit code when at least one issue was found, default is 1
  13. issues-exit-code: 1
  14. # include test files or not, default is true
  15. tests: true
  16. # list of build tags, all linters use it. Default is empty list.
  17. build-tags:
  18. # which dirs to skip: issues from them won't be reported;
  19. # can use regexp here: generated.*, regexp is applied on full path;
  20. # default value is empty list, but default dirs are skipped independently
  21. # from this option's value (see skip-dirs-use-default).
  22. skip-dirs:
  23. # default is true. Enables skipping of directories:
  24. # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
  25. skip-dirs-use-default: true
  26. # which files to skip: they will be analyzed, but issues from them
  27. # won't be reported. Default value is empty list, but there is
  28. # no need to include all autogenerated files, we confidently recognize
  29. # autogenerated files. If it's not please let us know.
  30. skip-files:
  31. # output configuration options
  32. output:
  33. # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
  34. format: colored-line-number
  35. # print lines of code with issue, default is true
  36. print-issued-lines: true
  37. # print linter name in the end of issue text, default is true
  38. print-linter-name: true
  39. # make issues output unique by line, default is true
  40. uniq-by-line: true
  41. # all available settings of specific linters
  42. linters-settings:
  43. dogsled:
  44. # checks assignments with too many blank identifiers; default is 2
  45. max-blank-identifiers: 2
  46. dupl:
  47. # tokens count to trigger issue, 150 by default
  48. threshold: 100
  49. errcheck:
  50. # report about not checking of errors in type assertions: `a := b.(MyStruct)`;
  51. # default is false: such cases aren't reported by default.
  52. check-type-assertions: false
  53. # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
  54. # default is false: such cases aren't reported by default.
  55. check-blank: false
  56. # path to a file containing a list of functions to exclude from checking
  57. # see https://github.com/kisielk/errcheck#excluding-functions for details
  58. exclude:
  59. funlen:
  60. lines: 60
  61. statements: 40
  62. gocognit:
  63. # minimal code complexity to report, 30 by default (but we recommend 10-20)
  64. min-complexity: 20
  65. goconst:
  66. # minimal length of string constant, 3 by default
  67. min-len: 3
  68. # minimal occurrences count to trigger, 3 by default
  69. min-occurrences: 3
  70. gocritic:
  71. # Which checks should be enabled; can't be combined with 'disabled-checks';
  72. # See https://go-critic.github.io/overview#checks-overview
  73. # To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
  74. # By default list of stable checks is used.
  75. enabled-checks:
  76. # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
  77. # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
  78. enabled-tags:
  79. - performance
  80. settings: # settings passed to gocritic
  81. captLocal: # must be valid enabled check name
  82. paramsOnly: true
  83. rangeValCopy:
  84. sizeThreshold: 32
  85. gocyclo:
  86. # minimal code complexity to report, 30 by default (but we recommend 10-20)
  87. min-complexity: 10
  88. godox:
  89. # report any comments starting with keywords, this is useful for TODO or FIXME comments that
  90. # might be left in the code accidentally and should be resolved before merging
  91. keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
  92. gofmt:
  93. # simplify code: gofmt with `-s` option, true by default
  94. simplify: true
  95. goimports:
  96. # put imports beginning with prefix after 3rd-party packages;
  97. # it's a comma-separated list of prefixes
  98. local-prefixes:
  99. golint:
  100. # minimal confidence for issues, default is 0.8
  101. min-confidence: 0.8
  102. gomnd:
  103. settings:
  104. mnd:
  105. # the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
  106. checks: argument,case,condition,operation,return,assign
  107. govet:
  108. # report about shadowed variables
  109. check-shadowing: false
  110. # settings per analyzer
  111. settings:
  112. printf: # analyzer name, run `go tool vet help` to see all analyzers
  113. funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
  114. - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
  115. - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
  116. - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
  117. - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
  118. # enable or disable analyzers by name
  119. enable:
  120. - atomicalign
  121. enable-all: false
  122. disable:
  123. - shadow
  124. disable-all: false
  125. lll:
  126. # max line length, lines longer will be reported. Default is 120.
  127. # '\t' is counted as 1 character by default, and can be changed with the tab-width option
  128. line-length: 120
  129. # tab width in spaces. Default to 1.
  130. tab-width: 1
  131. maligned:
  132. # print struct with more effective memory layout or not, false by default
  133. suggest-new: true
  134. misspell:
  135. # Correct spellings using locale preferences for US or UK.
  136. # Default is to use a neutral variety of English.
  137. # Setting locale to US will correct the British spelling of 'colour' to 'color'.
  138. locale: US
  139. ignore-words:
  140. - automizely
  141. nakedret:
  142. # make an issue if func has more lines of code than this setting and it has naked returns; default is 30
  143. max-func-lines: 30
  144. prealloc:
  145. # XXX: we don't recommend using this linter before doing performance profiling.
  146. # For most programs usage of prealloc will be a premature optimization.
  147. # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
  148. # True by default.
  149. simple: true
  150. range-loops: true # Report preallocation suggestions on range loops, true by default
  151. for-loops: false # Report preallocation suggestions on for loops, false by default
  152. rowserrcheck:
  153. packages:
  154. - github.com/jmoiron/sqlx
  155. unparam:
  156. # Inspect exported functions, default is false. Set to true if no external program/library imports your code.
  157. # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
  158. # if it's called for subdir of a project it can't find external interfaces. All text editor integrations
  159. # with golangci-lint call it on a directory with the changed file.
  160. check-exported: false
  161. unused:
  162. # treat code as a program (not a library) and report unused exported identifiers; default is false.
  163. # XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
  164. # if it's called for subdir of a project it can't find funcs usages. All text editor integrations
  165. # with golangci-lint call it on a directory with the changed file.
  166. check-exported: false
  167. whitespace:
  168. multi-if: false # Enforces newlines (or comments) after every multi-line if statement
  169. multi-func: false # Enforces newlines (or comments) after every multi-line function signature
  170. wsl:
  171. # If true append is only allowed to be cuddled if appending value is
  172. # matching variables, fields or types on line above. Default is true.
  173. strict-append: true
  174. # Allow calls and assignments to be cuddled as long as the lines have any
  175. # matching variables, fields or types. Default is true.
  176. allow-assign-and-call: true
  177. # Allow multiline assignments to be cuddled. Default is true.
  178. allow-multiline-assign: true
  179. # Allow declarations (var) to be cuddled.
  180. allow-cuddle-declarations: false
  181. # Allow trailing comments in ending of blocks
  182. allow-trailing-comment: false
  183. # Force newlines in end of case at this limit (0 = never).
  184. force-case-trailing-whitespace: 0
  185. linters:
  186. enable:
  187. - golint
  188. - govet
  189. disable:
  190. - maligned
  191. - prealloc
  192. - ineffassign
  193. - unparam
  194. disable-all: false
  195. presets:
  196. - bugs
  197. - unused
  198. fast: false
  199. issues:
  200. # List of regexps of issue texts to exclude, empty list by default.
  201. # But independently from this option we use default exclude patterns,
  202. # it can be disabled by `exclude-use-default: false`. To list all
  203. # excluded by default patterns execute `golangci-lint run --help`
  204. exclude:
  205. - composite literal uses unkeyed fields
  206. # Excluding configuration per-path, per-linter, per-text and per-source
  207. exclude-rules:
  208. # Exclude some linters from running on tests files.
  209. - path: test\.go
  210. linters:
  211. - gocyclo
  212. - errcheck
  213. - dupl
  214. - gosec
  215. - unused
  216. - varcheck
  217. - deadcode
  218. # Exclude known linters from partially hard-vendored code,
  219. # which is impossible to exclude via "nolint" comments.
  220. - path: pkg/crypto/
  221. text: "weak cryptographic primitive"
  222. linters:
  223. - gosec
  224. # Exclude some staticcheck messages
  225. - linters:
  226. - staticcheck
  227. text: "SA9003:"
  228. # Exclude lll issues for long lines with go:generate
  229. - linters:
  230. - lll
  231. source: "^//go:generate "
  232. # Independently from option `exclude` we use default exclude patterns,
  233. # it can be disabled by this option. To list all
  234. # excluded by default patterns execute `golangci-lint run --help`.
  235. # Default value for this option is true.
  236. exclude-use-default: true
  237. # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
  238. max-issues-per-linter: 0
  239. # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
  240. max-same-issues: 0
  241. # Show only new issues: if there are unstaged changes or untracked files,
  242. # only those changes are analyzed, else only changes in HEAD~ are analyzed.
  243. # It's a super-useful option for integration of golangci-lint into existing
  244. # large codebase. It's not practical to fix all existing issues at the moment
  245. # of integration: much better don't allow issues in new code.
  246. # Default is false.
  247. new: false