.golangci.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. version: "2"
  2. run:
  3. issues-exit-code: 1
  4. tests: true
  5. linters:
  6. default: none
  7. enable:
  8. - asasalint
  9. - bodyclose
  10. - depguard
  11. - errcheck
  12. - errorlint
  13. - godot
  14. - gosec
  15. - govet
  16. - ineffassign
  17. - misspell
  18. - perfsprint
  19. - revive
  20. - staticcheck
  21. - testifylint
  22. - unconvert
  23. - unparam
  24. - unused
  25. - usestdlibvars
  26. - usetesting
  27. settings:
  28. depguard:
  29. rules:
  30. auto/sdk:
  31. files:
  32. - '!internal/global/trace.go'
  33. - ~internal/global/trace_test.go
  34. deny:
  35. - pkg: go.opentelemetry.io/auto/sdk
  36. desc: Do not use SDK from automatic instrumentation.
  37. non-tests:
  38. files:
  39. - '!$test'
  40. - '!**/*test/*.go'
  41. - '!**/internal/matchers/*.go'
  42. deny:
  43. - pkg: testing
  44. - pkg: github.com/stretchr/testify
  45. - pkg: crypto/md5
  46. - pkg: crypto/sha1
  47. - pkg: crypto/**/pkix
  48. otel-internal:
  49. files:
  50. - '**/sdk/*.go'
  51. - '**/sdk/**/*.go'
  52. - '**/exporters/*.go'
  53. - '**/exporters/**/*.go'
  54. - '**/schema/*.go'
  55. - '**/schema/**/*.go'
  56. - '**/metric/*.go'
  57. - '**/metric/**/*.go'
  58. - '**/bridge/*.go'
  59. - '**/bridge/**/*.go'
  60. - '**/trace/*.go'
  61. - '**/trace/**/*.go'
  62. - '**/log/*.go'
  63. - '**/log/**/*.go'
  64. deny:
  65. - pkg: go.opentelemetry.io/otel/internal$
  66. desc: Do not use cross-module internal packages.
  67. - pkg: go.opentelemetry.io/otel/internal/internaltest
  68. desc: Do not use cross-module internal packages.
  69. - pkg: go.opentelemetry.io/otel/internal/matchers
  70. desc: Do not use cross-module internal packages.
  71. otlp-internal:
  72. files:
  73. - '!**/exporters/otlp/internal/**/*.go'
  74. deny:
  75. - pkg: go.opentelemetry.io/otel/exporters/otlp/internal
  76. desc: Do not use cross-module internal packages.
  77. otlpmetric-internal:
  78. files:
  79. - '!**/exporters/otlp/otlpmetric/internal/*.go'
  80. - '!**/exporters/otlp/otlpmetric/internal/**/*.go'
  81. deny:
  82. - pkg: go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal
  83. desc: Do not use cross-module internal packages.
  84. otlptrace-internal:
  85. files:
  86. - '!**/exporters/otlp/otlptrace/*.go'
  87. - '!**/exporters/otlp/otlptrace/internal/**.go'
  88. deny:
  89. - pkg: go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal
  90. desc: Do not use cross-module internal packages.
  91. godot:
  92. exclude:
  93. # Exclude links.
  94. - '^ *\[[^]]+\]:'
  95. # Exclude sentence fragments for lists.
  96. - ^[ ]*[-•]
  97. # Exclude sentences prefixing a list.
  98. - :$
  99. misspell:
  100. locale: US
  101. ignore-rules:
  102. - cancelled
  103. perfsprint:
  104. int-conversion: true
  105. err-error: true
  106. errorf: true
  107. sprintf1: true
  108. strconcat: true
  109. revive:
  110. confidence: 0.01
  111. rules:
  112. - name: blank-imports
  113. - name: bool-literal-in-expr
  114. - name: constant-logical-expr
  115. - name: context-as-argument
  116. arguments:
  117. - allowTypesBefore: '*testing.T'
  118. disabled: true
  119. - name: context-keys-type
  120. - name: deep-exit
  121. - name: defer
  122. arguments:
  123. - - call-chain
  124. - loop
  125. - name: dot-imports
  126. - name: duplicated-imports
  127. - name: early-return
  128. arguments:
  129. - preserveScope
  130. - name: empty-block
  131. - name: empty-lines
  132. - name: error-naming
  133. - name: error-return
  134. - name: error-strings
  135. - name: errorf
  136. - name: exported
  137. arguments:
  138. - sayRepetitiveInsteadOfStutters
  139. - name: flag-parameter
  140. - name: identical-branches
  141. - name: if-return
  142. - name: import-shadowing
  143. - name: increment-decrement
  144. - name: indent-error-flow
  145. arguments:
  146. - preserveScope
  147. - name: package-comments
  148. - name: range
  149. - name: range-val-in-closure
  150. - name: range-val-address
  151. - name: redefines-builtin-id
  152. - name: string-format
  153. arguments:
  154. - - panic
  155. - /^[^\n]*$/
  156. - must not contain line breaks
  157. - name: struct-tag
  158. - name: superfluous-else
  159. arguments:
  160. - preserveScope
  161. - name: time-equal
  162. - name: unconditional-recursion
  163. - name: unexported-return
  164. - name: unhandled-error
  165. arguments:
  166. - fmt.Fprint
  167. - fmt.Fprintf
  168. - fmt.Fprintln
  169. - fmt.Print
  170. - fmt.Printf
  171. - fmt.Println
  172. - name: unnecessary-stmt
  173. - name: useless-break
  174. - name: var-declaration
  175. - name: var-naming
  176. arguments:
  177. - ["ID"] # AllowList
  178. - ["Otel", "Aws", "Gcp"] # DenyList
  179. - name: waitgroup-by-value
  180. testifylint:
  181. enable-all: true
  182. disable:
  183. - float-compare
  184. - go-require
  185. - require-error
  186. exclusions:
  187. generated: lax
  188. presets:
  189. - common-false-positives
  190. - legacy
  191. - std-error-handling
  192. rules:
  193. # TODO: Having appropriate comments for exported objects helps development,
  194. # even for objects in internal packages. Appropriate comments for all
  195. # exported objects should be added and this exclusion removed.
  196. - linters:
  197. - revive
  198. path: .*internal/.*
  199. text: exported (method|function|type|const) (.+) should have comment or be unexported
  200. # Yes, they are, but it's okay in a test.
  201. - linters:
  202. - revive
  203. path: _test\.go
  204. text: exported func.*returns unexported type.*which can be annoying to use
  205. # Example test functions should be treated like main.
  206. - linters:
  207. - revive
  208. path: example.*_test\.go
  209. text: calls to (.+) only in main[(][)] or init[(][)] functions
  210. # It's okay to not run gosec and perfsprint in a test.
  211. - linters:
  212. - gosec
  213. - perfsprint
  214. path: _test\.go
  215. # Ignoring gosec G404: Use of weak random number generator (math/rand instead of crypto/rand)
  216. # as we commonly use it in tests and examples.
  217. - linters:
  218. - gosec
  219. text: 'G404:'
  220. # Ignoring gosec G402: TLS MinVersion too low
  221. # as the https://pkg.go.dev/crypto/tls#Config handles MinVersion default well.
  222. - linters:
  223. - gosec
  224. text: 'G402: TLS MinVersion too low.'
  225. paths:
  226. - third_party$
  227. - builtin$
  228. - examples$
  229. issues:
  230. max-issues-per-linter: 0
  231. max-same-issues: 0
  232. formatters:
  233. enable:
  234. - gofumpt
  235. - goimports
  236. - golines
  237. settings:
  238. goimports:
  239. local-prefixes:
  240. - go.opentelemetry.io
  241. golines:
  242. max-len: 120
  243. exclusions:
  244. generated: lax
  245. paths:
  246. - third_party$
  247. - builtin$
  248. - examples$