您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

.golangci.yml 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. linters:
  2. enable:
  3. - gosimple
  4. - deadcode
  5. - typecheck
  6. - govet
  7. - errcheck
  8. - staticcheck
  9. - unused
  10. - structcheck
  11. - varcheck
  12. - dupl
  13. #- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
  14. - gofmt
  15. - gocritic
  16. - bidichk
  17. - ineffassign
  18. - revive
  19. - gofumpt
  20. - depguard
  21. - nakedret
  22. - unconvert
  23. - wastedassign
  24. - nolintlint
  25. - stylecheck
  26. enable-all: false
  27. disable-all: true
  28. fast: false
  29. run:
  30. go: 1.19
  31. timeout: 10m
  32. skip-dirs:
  33. - node_modules
  34. - public
  35. - web_src
  36. linters-settings:
  37. stylecheck:
  38. checks: ["all", "-ST1005", "-ST1003"]
  39. nakedret:
  40. max-func-lines: 0
  41. gocritic:
  42. disabled-checks:
  43. - ifElseChain
  44. - singleCaseSwitch # Every time this occurred in the code, there was no other way.
  45. revive:
  46. ignore-generated-header: false
  47. severity: warning
  48. confidence: 0.8
  49. errorCode: 1
  50. warningCode: 1
  51. rules:
  52. - name: blank-imports
  53. - name: context-as-argument
  54. - name: context-keys-type
  55. - name: dot-imports
  56. - name: error-return
  57. - name: error-strings
  58. - name: error-naming
  59. - name: exported
  60. - name: if-return
  61. - name: increment-decrement
  62. - name: var-naming
  63. - name: var-declaration
  64. - name: package-comments
  65. - name: range
  66. - name: receiver-naming
  67. - name: time-naming
  68. - name: unexported-return
  69. - name: indent-error-flow
  70. - name: errorf
  71. - name: duplicated-imports
  72. - name: modifies-value-receiver
  73. gofumpt:
  74. extra-rules: true
  75. lang-version: "1.19"
  76. depguard:
  77. # TODO: use depguard to replace import checks in gitea-vet
  78. list-type: denylist
  79. # Check the list against standard lib.
  80. include-go-root: true
  81. packages-with-error-message:
  82. - encoding/json: "use gitea's modules/json instead of encoding/json"
  83. - github.com/unknwon/com: "use gitea's util and replacements"
  84. issues:
  85. max-issues-per-linter: 0
  86. max-same-issues: 0
  87. exclude-rules:
  88. # Exclude some linters from running on tests files.
  89. - path: _test\.go
  90. linters:
  91. - gocyclo
  92. - errcheck
  93. - dupl
  94. - gosec
  95. - unparam
  96. - staticcheck
  97. - path: models/migrations/v
  98. linters:
  99. - gocyclo
  100. - errcheck
  101. - dupl
  102. - gosec
  103. - linters:
  104. - dupl
  105. text: "webhook"
  106. - linters:
  107. - gocritic
  108. text: "`ID' should not be capitalized"
  109. - path: modules/templates/helper.go
  110. linters:
  111. - gocritic
  112. - linters:
  113. - unused
  114. - deadcode
  115. text: "swagger"
  116. - path: contrib/pr/checkout.go
  117. linters:
  118. - errcheck
  119. - path: models/issue.go
  120. linters:
  121. - errcheck
  122. - path: models/migrations/
  123. linters:
  124. - errcheck
  125. - path: modules/log/
  126. linters:
  127. - errcheck
  128. - path: routers/api/v1/repo/issue_subscription.go
  129. linters:
  130. - dupl
  131. - path: routers/repo/view.go
  132. linters:
  133. - dupl
  134. - path: models/migrations/
  135. linters:
  136. - unused
  137. - linters:
  138. - staticcheck
  139. text: "argument x is overwritten before first use"
  140. - path: modules/httplib/httplib.go
  141. linters:
  142. - staticcheck
  143. # Enabling this would require refactoring the methods and how they are called.
  144. - path: models/issue_comment_list.go
  145. linters:
  146. - dupl
  147. - path: models/update.go
  148. linters:
  149. - unused
  150. - path: cmd/dump.go
  151. linters:
  152. - dupl
  153. - path: services/webhook/webhook.go
  154. linters:
  155. - structcheck
  156. - text: "commentFormatting: put a space between `//` and comment text"
  157. linters:
  158. - gocritic
  159. - text: "exitAfterDefer:"
  160. linters:
  161. - gocritic
  162. - path: modules/graceful/manager_windows.go
  163. linters:
  164. - staticcheck
  165. text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
  166. - path: models/user/openid.go
  167. linters:
  168. - golint
  169. - path: models/user/badge.go
  170. linters:
  171. - revive
  172. text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge"