.golangci.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. rules:
  62. non-tests:
  63. files:
  64. - "!$test"
  65. - "!**/*test/*.go"
  66. - "!**/internal/matchers/*.go"
  67. deny:
  68. - pkg: "testing"
  69. - pkg: "github.com/stretchr/testify"
  70. - pkg: "crypto/md5"
  71. - pkg: "crypto/sha1"
  72. - pkg: "crypto/**/pkix"
  73. otlp-internal:
  74. files:
  75. - "!**/exporters/otlp/internal/**/*.go"
  76. deny:
  77. - pkg: "go.opentelemetry.io/otel/exporters/otlp/internal"
  78. desc: Do not use cross-module internal packages.
  79. otlptrace-internal:
  80. files:
  81. - "!**/exporters/otlp/otlptrace/*.go"
  82. - "!**/exporters/otlp/otlptrace/internal/**.go"
  83. deny:
  84. - pkg: "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal"
  85. desc: Do not use cross-module internal packages.
  86. otlpmetric-internal:
  87. files:
  88. - "!**/exporters/otlp/otlpmetric/internal/*.go"
  89. - "!**/exporters/otlp/otlpmetric/internal/**/*.go"
  90. deny:
  91. - pkg: "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
  92. desc: Do not use cross-module internal packages.
  93. otel-internal:
  94. files:
  95. - "**/sdk/*.go"
  96. - "**/sdk/**/*.go"
  97. - "**/exporters/*.go"
  98. - "**/exporters/**/*.go"
  99. - "**/schema/*.go"
  100. - "**/schema/**/*.go"
  101. - "**/metric/*.go"
  102. - "**/metric/**/*.go"
  103. - "**/bridge/*.go"
  104. - "**/bridge/**/*.go"
  105. - "**/example/*.go"
  106. - "**/example/**/*.go"
  107. - "**/trace/*.go"
  108. - "**/trace/**/*.go"
  109. deny:
  110. - pkg: "go.opentelemetry.io/otel/internal$"
  111. desc: Do not use cross-module internal packages.
  112. - pkg: "go.opentelemetry.io/otel/internal/attribute"
  113. desc: Do not use cross-module internal packages.
  114. - pkg: "go.opentelemetry.io/otel/internal/internaltest"
  115. desc: Do not use cross-module internal packages.
  116. - pkg: "go.opentelemetry.io/otel/internal/matchers"
  117. desc: Do not use cross-module internal packages.
  118. godot:
  119. exclude:
  120. # Exclude links.
  121. - '^ *\[[^]]+\]:'
  122. # Exclude sentence fragments for lists.
  123. - '^[ ]*[-•]'
  124. # Exclude sentences prefixing a list.
  125. - ':$'
  126. goimports:
  127. local-prefixes: go.opentelemetry.io
  128. misspell:
  129. locale: US
  130. ignore-words:
  131. - cancelled
  132. revive:
  133. # Sets the default failure confidence.
  134. # This means that linting errors with less than 0.8 confidence will be ignored.
  135. # Default: 0.8
  136. confidence: 0.01
  137. rules:
  138. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
  139. - name: blank-imports
  140. disabled: false
  141. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
  142. - name: bool-literal-in-expr
  143. disabled: false
  144. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
  145. - name: constant-logical-expr
  146. disabled: false
  147. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
  148. # TODO (#3372) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
  149. - name: context-as-argument
  150. disabled: true
  151. arguments:
  152. allowTypesBefore: "*testing.T"
  153. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
  154. - name: context-keys-type
  155. disabled: false
  156. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
  157. - name: deep-exit
  158. disabled: false
  159. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
  160. - name: defer
  161. disabled: false
  162. arguments:
  163. - ["call-chain", "loop"]
  164. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
  165. - name: dot-imports
  166. disabled: false
  167. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
  168. - name: duplicated-imports
  169. disabled: false
  170. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
  171. - name: early-return
  172. disabled: false
  173. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
  174. - name: empty-block
  175. disabled: false
  176. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
  177. - name: empty-lines
  178. disabled: false
  179. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
  180. - name: error-naming
  181. disabled: false
  182. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
  183. - name: error-return
  184. disabled: false
  185. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
  186. - name: error-strings
  187. disabled: false
  188. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
  189. - name: errorf
  190. disabled: false
  191. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
  192. - name: exported
  193. disabled: false
  194. arguments:
  195. - "sayRepetitiveInsteadOfStutters"
  196. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
  197. - name: flag-parameter
  198. disabled: false
  199. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
  200. - name: identical-branches
  201. disabled: false
  202. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
  203. - name: if-return
  204. disabled: false
  205. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
  206. - name: increment-decrement
  207. disabled: false
  208. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
  209. - name: indent-error-flow
  210. disabled: false
  211. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
  212. - name: import-shadowing
  213. disabled: false
  214. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
  215. - name: package-comments
  216. disabled: false
  217. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
  218. - name: range
  219. disabled: false
  220. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
  221. - name: range-val-in-closure
  222. disabled: false
  223. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
  224. - name: range-val-address
  225. disabled: false
  226. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
  227. - name: redefines-builtin-id
  228. disabled: false
  229. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
  230. - name: string-format
  231. disabled: false
  232. arguments:
  233. - - panic
  234. - '/^[^\n]*$/'
  235. - must not contain line breaks
  236. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
  237. - name: struct-tag
  238. disabled: false
  239. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
  240. - name: superfluous-else
  241. disabled: false
  242. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
  243. - name: time-equal
  244. disabled: false
  245. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
  246. - name: var-naming
  247. disabled: false
  248. arguments:
  249. - ["ID"] # AllowList
  250. - ["Otel", "Aws", "Gcp"] # DenyList
  251. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
  252. - name: var-declaration
  253. disabled: false
  254. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
  255. - name: unconditional-recursion
  256. disabled: false
  257. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
  258. - name: unexported-return
  259. disabled: false
  260. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
  261. - name: unhandled-error
  262. disabled: false
  263. arguments:
  264. - "fmt.Fprint"
  265. - "fmt.Fprintf"
  266. - "fmt.Fprintln"
  267. - "fmt.Print"
  268. - "fmt.Printf"
  269. - "fmt.Println"
  270. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
  271. - name: unnecessary-stmt
  272. disabled: false
  273. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
  274. - name: useless-break
  275. disabled: false
  276. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
  277. - name: waitgroup-by-value
  278. disabled: false