.golangci.yml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. # See https://github.com/golangci/golangci-lint#config-file
  2. run:
  3. issues-exit-code: 1 #Default
  4. tests: true #Default
  5. linters:
  6. # Disable everything by default so upgrades to not include new "default
  7. # enabled" linters.
  8. disable-all: true
  9. # Specifically enable linters we want to use.
  10. enable:
  11. - depguard
  12. - errcheck
  13. - godot
  14. - gofmt
  15. - goimports
  16. - gosimple
  17. - govet
  18. - ineffassign
  19. - misspell
  20. - revive
  21. - staticcheck
  22. - typecheck
  23. - unused
  24. issues:
  25. # Maximum issues count per one linter.
  26. # Set to 0 to disable.
  27. # Default: 50
  28. # Setting to unlimited so the linter only is run once to debug all issues.
  29. max-issues-per-linter: 0
  30. # Maximum count of issues with the same text.
  31. # Set to 0 to disable.
  32. # Default: 3
  33. # Setting to unlimited so the linter only is run once to debug all issues.
  34. max-same-issues: 0
  35. # Excluding configuration per-path, per-linter, per-text and per-source.
  36. exclude-rules:
  37. # TODO: Having appropriate comments for exported objects helps development,
  38. # even for objects in internal packages. Appropriate comments for all
  39. # exported objects should be added and this exclusion removed.
  40. - path: '.*internal/.*'
  41. text: "exported (method|function|type|const) (.+) should have comment or be unexported"
  42. linters:
  43. - revive
  44. # Yes, they are, but it's okay in a test.
  45. - path: _test\.go
  46. text: "exported func.*returns unexported type.*which can be annoying to use"
  47. linters:
  48. - revive
  49. # Example test functions should be treated like main.
  50. - path: example.*_test\.go
  51. text: "calls to (.+) only in main[(][)] or init[(][)] functions"
  52. linters:
  53. - revive
  54. include:
  55. # revive exported should have comment or be unexported.
  56. - EXC0012
  57. # revive package comment should be of the form ...
  58. - EXC0013
  59. linters-settings:
  60. depguard:
  61. # Check the list against standard lib.
  62. # Default: false
  63. include-go-root: true
  64. # A list of packages for the list type specified.
  65. # Default: []
  66. packages:
  67. - "crypto/md5"
  68. - "crypto/sha1"
  69. - "crypto/**/pkix"
  70. ignore-file-rules:
  71. - "**/*_test.go"
  72. additional-guards:
  73. # Do not allow testing packages in non-test files.
  74. - list-type: denylist
  75. include-go-root: true
  76. packages:
  77. - testing
  78. - github.com/stretchr/testify
  79. ignore-file-rules:
  80. - "**/*_test.go"
  81. - "**/*test/*.go"
  82. - "**/internal/matchers/*.go"
  83. godot:
  84. exclude:
  85. # Exclude sentence fragments for lists.
  86. - '^[ ]*[-•]'
  87. # Exclude sentences prefixing a list.
  88. - ':$'
  89. goimports:
  90. local-prefixes: go.opentelemetry.io
  91. misspell:
  92. locale: US
  93. ignore-words:
  94. - cancelled
  95. revive:
  96. # Sets the default failure confidence.
  97. # This means that linting errors with less than 0.8 confidence will be ignored.
  98. # Default: 0.8
  99. confidence: 0.01
  100. rules:
  101. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
  102. - name: blank-imports
  103. disabled: false
  104. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
  105. - name: bool-literal-in-expr
  106. disabled: false
  107. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
  108. - name: constant-logical-expr
  109. disabled: false
  110. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
  111. # TODO (#3372) reenable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
  112. - name: context-as-argument
  113. disabled: true
  114. arguments:
  115. allowTypesBefore: "*testing.T"
  116. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
  117. - name: context-keys-type
  118. disabled: false
  119. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
  120. - name: deep-exit
  121. disabled: false
  122. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
  123. - name: defer
  124. disabled: false
  125. arguments:
  126. - ["call-chain", "loop"]
  127. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
  128. - name: dot-imports
  129. disabled: false
  130. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
  131. - name: duplicated-imports
  132. disabled: false
  133. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
  134. - name: early-return
  135. disabled: false
  136. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
  137. - name: empty-block
  138. disabled: false
  139. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
  140. - name: empty-lines
  141. disabled: false
  142. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
  143. - name: error-naming
  144. disabled: false
  145. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
  146. - name: error-return
  147. disabled: false
  148. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
  149. - name: error-strings
  150. disabled: false
  151. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
  152. - name: errorf
  153. disabled: false
  154. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
  155. - name: exported
  156. disabled: false
  157. arguments:
  158. - "sayRepetitiveInsteadOfStutters"
  159. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
  160. - name: flag-parameter
  161. disabled: false
  162. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
  163. - name: identical-branches
  164. disabled: false
  165. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
  166. - name: if-return
  167. disabled: false
  168. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
  169. - name: increment-decrement
  170. disabled: false
  171. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
  172. - name: indent-error-flow
  173. disabled: false
  174. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
  175. - name: import-shadowing
  176. disabled: false
  177. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
  178. - name: package-comments
  179. disabled: false
  180. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
  181. - name: range
  182. disabled: false
  183. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
  184. - name: range-val-in-closure
  185. disabled: false
  186. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
  187. - name: range-val-address
  188. disabled: false
  189. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
  190. - name: redefines-builtin-id
  191. disabled: false
  192. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
  193. - name: string-format
  194. disabled: false
  195. arguments:
  196. - - panic
  197. - '/^[^\n]*$/'
  198. - must not contain line breaks
  199. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
  200. - name: struct-tag
  201. disabled: false
  202. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
  203. - name: superfluous-else
  204. disabled: false
  205. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
  206. - name: time-equal
  207. disabled: false
  208. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
  209. - name: var-naming
  210. disabled: false
  211. arguments:
  212. - ["ID"] # AllowList
  213. - ["Otel", "Aws", "Gcp"] # DenyList
  214. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
  215. - name: var-declaration
  216. disabled: false
  217. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
  218. - name: unconditional-recursion
  219. disabled: false
  220. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
  221. - name: unexported-return
  222. disabled: false
  223. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
  224. - name: unhandled-error
  225. disabled: false
  226. arguments:
  227. - "fmt.Fprint"
  228. - "fmt.Fprintf"
  229. - "fmt.Fprintln"
  230. - "fmt.Print"
  231. - "fmt.Printf"
  232. - "fmt.Println"
  233. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
  234. - name: unnecessary-stmt
  235. disabled: false
  236. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
  237. - name: useless-break
  238. disabled: false
  239. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
  240. - name: waitgroup-by-value
  241. disabled: false