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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.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. 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. issues:
  86. max-issues-per-linter: 0
  87. max-same-issues: 0
  88. exclude-rules:
  89. # Exclude some linters from running on tests files.
  90. - path: _test\.go
  91. linters:
  92. - gocyclo
  93. - errcheck
  94. - dupl
  95. - gosec
  96. - unparam
  97. - staticcheck
  98. - path: models/migrations/v
  99. linters:
  100. - gocyclo
  101. - errcheck
  102. - dupl
  103. - gosec
  104. - linters:
  105. - dupl
  106. text: "webhook"
  107. - linters:
  108. - gocritic
  109. text: "`ID' should not be capitalized"
  110. - path: modules/templates/helper.go
  111. linters:
  112. - gocritic
  113. - linters:
  114. - unused
  115. - deadcode
  116. text: "swagger"
  117. - path: contrib/pr/checkout.go
  118. linters:
  119. - errcheck
  120. - path: models/issue.go
  121. linters:
  122. - errcheck
  123. - path: models/migrations/
  124. linters:
  125. - errcheck
  126. - path: modules/log/
  127. linters:
  128. - errcheck
  129. - path: routers/api/v1/repo/issue_subscription.go
  130. linters:
  131. - dupl
  132. - path: routers/repo/view.go
  133. linters:
  134. - dupl
  135. - path: models/migrations/
  136. linters:
  137. - unused
  138. - linters:
  139. - staticcheck
  140. text: "argument x is overwritten before first use"
  141. - path: modules/httplib/httplib.go
  142. linters:
  143. - staticcheck
  144. # Enabling this would require refactoring the methods and how they are called.
  145. - path: models/issue_comment_list.go
  146. linters:
  147. - dupl
  148. - path: models/update.go
  149. linters:
  150. - unused
  151. - path: cmd/dump.go
  152. linters:
  153. - dupl
  154. - path: services/webhook/webhook.go
  155. linters:
  156. - structcheck
  157. - text: "commentFormatting: put a space between `//` and comment text"
  158. linters:
  159. - gocritic
  160. - text: "exitAfterDefer:"
  161. linters:
  162. - gocritic
  163. - path: modules/graceful/manager_windows.go
  164. linters:
  165. - staticcheck
  166. text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
  167. - path: models/user/openid.go
  168. linters:
  169. - golint
  170. - path: models/user/badge.go
  171. linters:
  172. - revive
  173. text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge"