.golangci.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. - gofumpt
  15. - goimports
  16. - gosec
  17. - gosimple
  18. - govet
  19. - ineffassign
  20. - misspell
  21. - revive
  22. - staticcheck
  23. - typecheck
  24. - unused
  25. issues:
  26. # Maximum issues count per one linter.
  27. # Set to 0 to disable.
  28. # Default: 50
  29. # Setting to unlimited so the linter only is run once to debug all issues.
  30. max-issues-per-linter: 0
  31. # Maximum count of issues with the same text.
  32. # Set to 0 to disable.
  33. # Default: 3
  34. # Setting to unlimited so the linter only is run once to debug all issues.
  35. max-same-issues: 0
  36. # Excluding configuration per-path, per-linter, per-text and per-source.
  37. exclude-rules:
  38. # TODO: Having appropriate comments for exported objects helps development,
  39. # even for objects in internal packages. Appropriate comments for all
  40. # exported objects should be added and this exclusion removed.
  41. - path: '.*internal/.*'
  42. text: "exported (method|function|type|const) (.+) should have comment or be unexported"
  43. linters:
  44. - revive
  45. # Yes, they are, but it's okay in a test.
  46. - path: _test\.go
  47. text: "exported func.*returns unexported type.*which can be annoying to use"
  48. linters:
  49. - revive
  50. # Example test functions should be treated like main.
  51. - path: example.*_test\.go
  52. text: "calls to (.+) only in main[(][)] or init[(][)] functions"
  53. linters:
  54. - revive
  55. # It's okay to not run gosec in a test.
  56. - path: _test\.go
  57. linters:
  58. - gosec
  59. # Igonoring gosec G404: Use of weak random number generator (math/rand instead of crypto/rand)
  60. # as we commonly use it in tests and examples.
  61. - text: "G404:"
  62. linters:
  63. - gosec
  64. # Igonoring gosec G402: TLS MinVersion too low
  65. # as the https://pkg.go.dev/crypto/tls#Config handles MinVersion default well.
  66. - text: "G402: TLS MinVersion too low."
  67. linters:
  68. - gosec
  69. include:
  70. # revive exported should have comment or be unexported.
  71. - EXC0012
  72. # revive package comment should be of the form ...
  73. - EXC0013
  74. linters-settings:
  75. depguard:
  76. rules:
  77. non-tests:
  78. files:
  79. - "!$test"
  80. - "!**/*test/*.go"
  81. - "!**/internal/matchers/*.go"
  82. deny:
  83. - pkg: "testing"
  84. - pkg: "github.com/stretchr/testify"
  85. - pkg: "crypto/md5"
  86. - pkg: "crypto/sha1"
  87. - pkg: "crypto/**/pkix"
  88. otlp-internal:
  89. files:
  90. - "!**/exporters/otlp/internal/**/*.go"
  91. deny:
  92. - pkg: "go.opentelemetry.io/otel/exporters/otlp/internal"
  93. desc: Do not use cross-module internal packages.
  94. otlptrace-internal:
  95. files:
  96. - "!**/exporters/otlp/otlptrace/*.go"
  97. - "!**/exporters/otlp/otlptrace/internal/**.go"
  98. deny:
  99. - pkg: "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal"
  100. desc: Do not use cross-module internal packages.
  101. otlpmetric-internal:
  102. files:
  103. - "!**/exporters/otlp/otlpmetric/internal/*.go"
  104. - "!**/exporters/otlp/otlpmetric/internal/**/*.go"
  105. deny:
  106. - pkg: "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
  107. desc: Do not use cross-module internal packages.
  108. otel-internal:
  109. files:
  110. - "**/sdk/*.go"
  111. - "**/sdk/**/*.go"
  112. - "**/exporters/*.go"
  113. - "**/exporters/**/*.go"
  114. - "**/schema/*.go"
  115. - "**/schema/**/*.go"
  116. - "**/metric/*.go"
  117. - "**/metric/**/*.go"
  118. - "**/bridge/*.go"
  119. - "**/bridge/**/*.go"
  120. - "**/example/*.go"
  121. - "**/example/**/*.go"
  122. - "**/trace/*.go"
  123. - "**/trace/**/*.go"
  124. deny:
  125. - pkg: "go.opentelemetry.io/otel/internal$"
  126. desc: Do not use cross-module internal packages.
  127. - pkg: "go.opentelemetry.io/otel/internal/attribute"
  128. desc: Do not use cross-module internal packages.
  129. - pkg: "go.opentelemetry.io/otel/internal/internaltest"
  130. desc: Do not use cross-module internal packages.
  131. - pkg: "go.opentelemetry.io/otel/internal/matchers"
  132. desc: Do not use cross-module internal packages.
  133. godot:
  134. exclude:
  135. # Exclude links.
  136. - '^ *\[[^]]+\]:'
  137. # Exclude sentence fragments for lists.
  138. - '^[ ]*[-•]'
  139. # Exclude sentences prefixing a list.
  140. - ':$'
  141. goimports:
  142. local-prefixes: go.opentelemetry.io
  143. misspell:
  144. locale: US
  145. ignore-words:
  146. - cancelled
  147. revive:
  148. # Sets the default failure confidence.
  149. # This means that linting errors with less than 0.8 confidence will be ignored.
  150. # Default: 0.8
  151. confidence: 0.01
  152. rules:
  153. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
  154. - name: blank-imports
  155. disabled: false
  156. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
  157. - name: bool-literal-in-expr
  158. disabled: false
  159. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
  160. - name: constant-logical-expr
  161. disabled: false
  162. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
  163. # TODO (#3372) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
  164. - name: context-as-argument
  165. disabled: true
  166. arguments:
  167. allowTypesBefore: "*testing.T"
  168. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
  169. - name: context-keys-type
  170. disabled: false
  171. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
  172. - name: deep-exit
  173. disabled: false
  174. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
  175. - name: defer
  176. disabled: false
  177. arguments:
  178. - ["call-chain", "loop"]
  179. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
  180. - name: dot-imports
  181. disabled: false
  182. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
  183. - name: duplicated-imports
  184. disabled: false
  185. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
  186. - name: early-return
  187. disabled: false
  188. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
  189. - name: empty-block
  190. disabled: false
  191. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
  192. - name: empty-lines
  193. disabled: false
  194. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
  195. - name: error-naming
  196. disabled: false
  197. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
  198. - name: error-return
  199. disabled: false
  200. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
  201. - name: error-strings
  202. disabled: false
  203. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
  204. - name: errorf
  205. disabled: false
  206. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
  207. - name: exported
  208. disabled: false
  209. arguments:
  210. - "sayRepetitiveInsteadOfStutters"
  211. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
  212. - name: flag-parameter
  213. disabled: false
  214. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
  215. - name: identical-branches
  216. disabled: false
  217. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
  218. - name: if-return
  219. disabled: false
  220. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
  221. - name: increment-decrement
  222. disabled: false
  223. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
  224. - name: indent-error-flow
  225. disabled: false
  226. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
  227. - name: import-shadowing
  228. disabled: false
  229. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
  230. - name: package-comments
  231. disabled: false
  232. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
  233. - name: range
  234. disabled: false
  235. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
  236. - name: range-val-in-closure
  237. disabled: false
  238. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
  239. - name: range-val-address
  240. disabled: false
  241. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
  242. - name: redefines-builtin-id
  243. disabled: false
  244. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
  245. - name: string-format
  246. disabled: false
  247. arguments:
  248. - - panic
  249. - '/^[^\n]*$/'
  250. - must not contain line breaks
  251. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
  252. - name: struct-tag
  253. disabled: false
  254. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
  255. - name: superfluous-else
  256. disabled: false
  257. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
  258. - name: time-equal
  259. disabled: false
  260. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
  261. - name: var-naming
  262. disabled: false
  263. arguments:
  264. - ["ID"] # AllowList
  265. - ["Otel", "Aws", "Gcp"] # DenyList
  266. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
  267. - name: var-declaration
  268. disabled: false
  269. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
  270. - name: unconditional-recursion
  271. disabled: false
  272. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
  273. - name: unexported-return
  274. disabled: false
  275. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
  276. - name: unhandled-error
  277. disabled: false
  278. arguments:
  279. - "fmt.Fprint"
  280. - "fmt.Fprintf"
  281. - "fmt.Fprintln"
  282. - "fmt.Print"
  283. - "fmt.Printf"
  284. - "fmt.Println"
  285. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
  286. - name: unnecessary-stmt
  287. disabled: false
  288. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
  289. - name: useless-break
  290. disabled: false
  291. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
  292. - name: waitgroup-by-value
  293. disabled: false