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 2.4KB

Move macaron to chi (#14293) Use [chi](https://github.com/go-chi/chi) instead of the forked [macaron](https://gitea.com/macaron/macaron). Since macaron and chi have conflicts with session share, this big PR becomes a have-to thing. According my previous idea, we can replace macaron step by step but I'm wrong. :( Below is a list of big changes on this PR. - [x] Define `context.ResponseWriter` interface with an implementation `context.Response`. - [x] Use chi instead of macaron, and also a customize `Route` to wrap chi so that the router usage is similar as before. - [x] Create different routers for `web`, `api`, `internal` and `install` so that the codes will be more clear and no magic . - [x] Use https://github.com/unrolled/render instead of macaron's internal render - [x] Use https://github.com/NYTimes/gziphandler instead of https://gitea.com/macaron/gzip - [x] Use https://gitea.com/go-chi/session which is a modified version of https://gitea.com/macaron/session and removed `nodb` support since it will not be maintained. **BREAK** - [x] Use https://gitea.com/go-chi/captcha which is a modified version of https://gitea.com/macaron/captcha - [x] Use https://gitea.com/go-chi/cache which is a modified version of https://gitea.com/macaron/cache - [x] Use https://gitea.com/go-chi/binding which is a modified version of https://gitea.com/macaron/binding - [x] Use https://github.com/go-chi/cors instead of https://gitea.com/macaron/cors - [x] Dropped https://gitea.com/macaron/i18n and make a new one in `code.gitea.io/gitea/modules/translation` - [x] Move validation form structs from `code.gitea.io/gitea/modules/auth` to `code.gitea.io/gitea/modules/forms` to avoid dependency cycle. - [x] Removed macaron log service because it's not need any more. **BREAK** - [x] All form structs have to be get by `web.GetForm(ctx)` in the route function but not as a function parameter on routes definition. - [x] Move Git HTTP protocol implementation to use routers directly. - [x] Fix the problem that chi routes don't support trailing slash but macaron did. - [x] `/api/v1/swagger` now will be redirect to `/api/swagger` but not render directly so that `APIContext` will not create a html render. Notices: - Chi router don't support request with trailing slash - Integration test `TestUserHeatmap` maybe mysql version related. It's failed on my macOS(mysql 5.7.29 installed via brew) but succeed on CI. Co-authored-by: 6543 <6543@obermui.de>
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. linters:
  2. enable:
  3. - gosimple
  4. - deadcode
  5. - typecheck
  6. - govet
  7. - errcheck
  8. - staticcheck
  9. - unused
  10. - structcheck
  11. - varcheck
  12. - golint
  13. - dupl
  14. #- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
  15. - gofmt
  16. - misspell
  17. - gocritic
  18. enable-all: false
  19. disable-all: true
  20. fast: false
  21. run:
  22. timeout: 3m
  23. linters-settings:
  24. gocritic:
  25. disabled-checks:
  26. - ifElseChain
  27. - singleCaseSwitch # Every time this occurred in the code, there was no other way.
  28. issues:
  29. exclude-rules:
  30. # Exclude some linters from running on tests files.
  31. - path: _test\.go
  32. linters:
  33. - gocyclo
  34. - errcheck
  35. - dupl
  36. - gosec
  37. - unparam
  38. - staticcheck
  39. - path: models/migrations/v
  40. linters:
  41. - gocyclo
  42. - errcheck
  43. - dupl
  44. - gosec
  45. - linters:
  46. - dupl
  47. text: "webhook"
  48. - linters:
  49. - gocritic
  50. text: "`ID' should not be capitalized"
  51. - path: modules/templates/helper.go
  52. linters:
  53. - gocritic
  54. - linters:
  55. - unused
  56. - deadcode
  57. text: "swagger"
  58. - path: contrib/pr/checkout.go
  59. linters:
  60. - errcheck
  61. - path: models/issue.go
  62. linters:
  63. - errcheck
  64. - path: models/migrations/
  65. linters:
  66. - errcheck
  67. - path: modules/log/
  68. linters:
  69. - errcheck
  70. - path: routers/routes/web.go
  71. linters:
  72. - dupl
  73. - path: routers/api/v1/repo/issue_subscription.go
  74. linters:
  75. - dupl
  76. - path: routers/repo/view.go
  77. linters:
  78. - dupl
  79. - path: models/migrations/
  80. linters:
  81. - unused
  82. - linters:
  83. - staticcheck
  84. text: "argument x is overwritten before first use"
  85. - path: modules/httplib/httplib.go
  86. linters:
  87. - staticcheck
  88. # Enabling this would require refactoring the methods and how they are called.
  89. - path: models/issue_comment_list.go
  90. linters:
  91. - dupl
  92. - linters:
  93. - misspell
  94. text: '`Unknwon` is a misspelling of `Unknown`'
  95. - path: models/update.go
  96. linters:
  97. - unused
  98. - path: cmd/dump.go
  99. linters:
  100. - dupl
  101. - path: services/webhook/webhook.go
  102. linters:
  103. - structcheck
  104. - text: "commentFormatting: put a space between `//` and comment text"
  105. linters:
  106. - gocritic
  107. - text: "exitAfterDefer:"
  108. linters:
  109. - gocritic