.golangci.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. run:
  2. go: "1.21"
  3. skip-dirs:
  4. - build
  5. - configs
  6. - deployments
  7. - docs
  8. - scripts
  9. - internal/core
  10. - cmake_build
  11. - mmap
  12. - data
  13. - ci
  14. skip-files:
  15. - partial_search_test.go
  16. build-tags:
  17. - dynamic
  18. - test
  19. linters:
  20. disable-all: true
  21. enable:
  22. - gosimple
  23. - govet
  24. - ineffassign
  25. - staticcheck
  26. - decorder
  27. - depguard
  28. - gofmt
  29. - goimports
  30. - gosec
  31. - revive
  32. - unconvert
  33. - misspell
  34. - typecheck
  35. - durationcheck
  36. - forbidigo
  37. - gci
  38. - whitespace
  39. - gofumpt
  40. - gocritic
  41. linters-settings:
  42. gci:
  43. sections:
  44. - standard
  45. - default
  46. - prefix(github.com/milvus-io)
  47. custom-order: true
  48. govet:
  49. enable: # add extra linters
  50. - nilness
  51. gofumpt:
  52. lang-version: "1.18"
  53. module-path: github.com/milvus-io
  54. goimports:
  55. local-prefixes: github.com/milvus-io
  56. revive:
  57. rules:
  58. - name: unused-parameter
  59. disabled: true
  60. - name: var-naming
  61. severity: warning
  62. disabled: false
  63. arguments:
  64. - ["ID"] # Allow list
  65. - name: context-as-argument
  66. severity: warning
  67. disabled: false
  68. arguments:
  69. - allowTypesBefore: "*testing.T"
  70. - name: datarace
  71. severity: warning
  72. disabled: false
  73. - name: duplicated-imports
  74. severity: warning
  75. disabled: false
  76. - name: waitgroup-by-value
  77. severity: warning
  78. disabled: false
  79. - name: indent-error-flow
  80. severity: warning
  81. disabled: false
  82. arguments:
  83. - "preserveScope"
  84. - name: range-val-in-closure
  85. severity: warning
  86. disabled: false
  87. - name: range-val-address
  88. severity: warning
  89. disabled: false
  90. - name: string-of-int
  91. severity: warning
  92. disabled: false
  93. misspell:
  94. locale: US
  95. gocritic:
  96. enabled-checks:
  97. - ruleguard
  98. settings:
  99. ruleguard:
  100. failOnError: true
  101. rules: "rules.go"
  102. depguard:
  103. rules:
  104. main:
  105. deny:
  106. - pkg: "errors"
  107. desc: not allowed, use github.com/cockroachdb/errors
  108. - pkg: "github.com/pkg/errors"
  109. desc: not allowed, use github.com/cockroachdb/errors
  110. - pkg: "github.com/pingcap/errors"
  111. desc: not allowed, use github.com/cockroachdb/errors
  112. - pkg: "golang.org/x/xerrors"
  113. desc: not allowed, use github.com/cockroachdb/errors
  114. - pkg: "github.com/go-errors/errors"
  115. desc: not allowed, use github.com/cockroachdb/errors
  116. - pkg: "io/ioutil"
  117. desc: ioutil is deprecated after 1.16, 1.17, use os and io package instead
  118. - pkg: "github.com/tikv/client-go/rawkv"
  119. desc: not allowed, use github.com/tikv/client-go/v2/txnkv
  120. - pkg: "github.com/tikv/client-go/v2/rawkv"
  121. desc: not allowed, use github.com/tikv/client-go/v2/txnkv
  122. - pkg: "github.com/gogo/protobuf"
  123. desc: "not allowed, gogo protobuf is deprecated"
  124. - pkg: "github.com/golang/protobuf/proto"
  125. desc: "not allowed, protobuf v1 is deprecated, use google.golang.org/protobuf/proto instead"
  126. forbidigo:
  127. forbid:
  128. - '^time\.Tick$'
  129. - 'return merr\.Err[a-zA-Z]+'
  130. - 'merr\.Wrap\w+\(\)\.Error\(\)'
  131. - '\.(ErrorCode|Reason) = '
  132. - 'Reason:\s+\w+\.Error\(\)'
  133. - 'errors.New\((.+)\.GetReason\(\)\)'
  134. - 'commonpb\.Status\{[\s\n]*ErrorCode:[\s\n]*.+[\s\S\n]*?\}'
  135. - 'os\.Open\(.+\)'
  136. - 'os\.ReadFile\(.+\)'
  137. - 'os\.WriteFile\(.+\)'
  138. - "runtime.NumCPU"
  139. - "runtime.GOMAXPROCS(0)"
  140. #- 'fmt\.Print.*' WIP
  141. issues:
  142. exclude-use-default: false
  143. exclude-rules:
  144. - path: .+_test\.go
  145. linters:
  146. - forbidigo
  147. exclude:
  148. - should have a package comment
  149. - should have comment
  150. - should be of the form
  151. - should not use dot imports
  152. - which can be annoying to use
  153. # Binds to all network interfaces
  154. - G102
  155. # Use of unsafe calls should be audited
  156. - G103
  157. # Errors unhandled
  158. - G104
  159. # file/folder Permission
  160. - G301
  161. - G302
  162. # Potential file inclusion via variable
  163. - G304
  164. # Deferring unsafe method like *os.File Close
  165. - G307
  166. # TLS MinVersion too low
  167. - G402
  168. # Use of weak random number generator math/rand
  169. - G404
  170. # Unused parameters
  171. - SA1019
  172. # defer return errors
  173. - SA5001
  174. # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
  175. max-issues-per-linter: 0
  176. # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
  177. max-same-issues: 0
  178. service:
  179. # use the fixed version to not introduce new linters unexpectedly
  180. golangci-lint-version: 1.55.2