You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

.golangci.yml 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. linters:
  2. enable:
  3. - bidichk
  4. # - deadcode # deprecated - https://github.com/golangci/golangci-lint/issues/1841
  5. - depguard
  6. - dupl
  7. - errcheck
  8. - gocritic
  9. # - gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
  10. - gofmt
  11. - gofumpt
  12. - gosimple
  13. - govet
  14. - ineffassign
  15. - nakedret
  16. - nolintlint
  17. - revive
  18. - staticcheck
  19. # - structcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
  20. - stylecheck
  21. - typecheck
  22. - unconvert
  23. - unused
  24. # - varcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
  25. # - wastedassign # disabled - https://github.com/golangci/golangci-lint/issues/2649
  26. enable-all: false
  27. disable-all: true
  28. fast: false
  29. run:
  30. go: "1.20"
  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.20"
  76. depguard:
  77. list-type: denylist
  78. # Check the list against standard lib.
  79. include-go-root: true
  80. packages-with-error-message:
  81. - encoding/json: "use gitea's modules/json instead of encoding/json"
  82. - github.com/unknwon/com: "use gitea's util and replacements"
  83. - io/ioutil: "use os or io instead"
  84. - golang.org/x/exp: "it's experimental and unreliable."
  85. - code.gitea.io/gitea/modules/git/internal: "do not use the internal package, use AddXxx function instead"
  86. issues:
  87. max-issues-per-linter: 0
  88. max-same-issues: 0
  89. exclude-rules:
  90. # Exclude some linters from running on tests files.
  91. - path: _test\.go
  92. linters:
  93. - gocyclo
  94. - errcheck
  95. - dupl
  96. - gosec
  97. - unparam
  98. - staticcheck
  99. - path: models/migrations/v
  100. linters:
  101. - gocyclo
  102. - errcheck
  103. - dupl
  104. - gosec
  105. - linters:
  106. - dupl
  107. text: "webhook"
  108. - linters:
  109. - gocritic
  110. text: "`ID' should not be capitalized"
  111. - path: modules/templates/helper.go
  112. linters:
  113. - gocritic
  114. - linters:
  115. - unused
  116. - deadcode
  117. text: "swagger"
  118. - path: contrib/pr/checkout.go
  119. linters:
  120. - errcheck
  121. - path: models/issue.go
  122. linters:
  123. - errcheck
  124. - path: models/migrations/
  125. linters:
  126. - errcheck
  127. - path: modules/log/
  128. linters:
  129. - errcheck
  130. - path: routers/api/v1/repo/issue_subscription.go
  131. linters:
  132. - dupl
  133. - path: routers/repo/view.go
  134. linters:
  135. - dupl
  136. - path: models/migrations/
  137. linters:
  138. - unused
  139. - linters:
  140. - staticcheck
  141. text: "argument x is overwritten before first use"
  142. - path: modules/httplib/httplib.go
  143. linters:
  144. - staticcheck
  145. # Enabling this would require refactoring the methods and how they are called.
  146. - path: models/issue_comment_list.go
  147. linters:
  148. - dupl
  149. - path: models/update.go
  150. linters:
  151. - unused
  152. - path: cmd/dump.go
  153. linters:
  154. - dupl
  155. - path: services/webhook/webhook.go
  156. linters:
  157. - structcheck
  158. - text: "commentFormatting: put a space between `//` and comment text"
  159. linters:
  160. - gocritic
  161. - text: "exitAfterDefer:"
  162. linters:
  163. - gocritic
  164. - path: modules/graceful/manager_windows.go
  165. linters:
  166. - staticcheck
  167. text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
  168. - path: models/user/openid.go
  169. linters:
  170. - golint
  171. - path: models/user/badge.go
  172. linters:
  173. - revive
  174. text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge"