.golangci.yml 4.3 KB

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