Files
silverwind 37e51013a3 chore: align golangci-lint config with Gitea (#104)
Use the same linters, settings and formatters as Gitea's `.golangci.yml`, so code moving between the two projects meets the same bar. Rules that only apply to Gitea's codebase (its json/ini/cache wrappers, migrations, swagger, process wrapper) are left out, this repo's extra checks (`misspell`, `copyloopvar`, a few revive rules) are kept.

`gci` now owns import grouping (standard, `gitea.dev`, others), so `make fmt` and `make fmt-check` run `golangci-lint fmt`. The unused `.revive.toml` is removed. The rest of the diff fixes the newly reported issues without behavior changes.

_Written by Claude (Opus 5.5)._

Reviewed-on: https://gitea.com/gitea/cli/pulls/104
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: silverwind <[email protected]>
2026-11-07 07:45:18 +00:00

159 lines
3.3 KiB
YAML

version: "2"
output:
sort-order:
- file
linters:
default: none
enable:
- bidichk
- bodyclose
- copyloopvar
- depguard
- dupl
- errcheck
- exhaustruct_v5
- forbidigo
- forcetypeassert
- gocheckcompilerdirectives
- gocritic
- govet
- ineffassign
- mirror
- misspell
- modernize
- nakedret
- nilnil
- nolintlint
- perfsprint
- revive
- staticcheck
- testifylint
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- wastedassign
settings:
depguard:
rules:
main:
deny:
- pkg: io/ioutil
desc: use os or io instead
- pkg: golang.org/x/exp
desc: it's experimental and unreliable
- pkg: github.com/pkg/errors
desc: use builtin errors package instead
forbidigo:
forbid:
- pattern: '^(fmt\.Print(|f|ln)|print|println)$' # default
modernize:
disable:
- embedlit
nolintlint:
allow-unused: false
require-explanation: true
require-specific: true
gocritic:
enabled-checks:
- equalFold
disabled-checks:
- ifElseChain
- singleCaseSwitch
misspell:
locale: US
revive:
severity: error
rules:
- name: blank-imports
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-lines
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: identical-branches
- name: if-return
- name: increment-decrement
- name: indent-error-flow
- name: modifies-value-receiver
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: var-declaration
- name: var-naming
arguments:
- [] # AllowList - do not remove as args for the rule are positional and won't work without lists first
- [] # DenyList
- - skip-initialism-name-checks: true
staticcheck:
checks:
- all
- -ST1003
- -ST1005
- -QF1001
- -QF1006
- -QF1008
testifylint:
disable:
- empty
- go-require
- require-error
usetesting:
os-temp-dir: true
perfsprint:
concat-loop: false
govet:
enable:
- nilness
- unusedwrite
exhaustruct_v5:
explicit-mode: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- dupl
- errcheck
- forbidigo
- staticcheck
- unparam
path: _test\.go
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gci
- gofumpt
settings:
gci:
custom-order: true
sections:
- standard
- prefix(gitea.dev)
- blank
- default
gofumpt:
extra:
group-params: true
exclusions:
generated: lax
run:
timeout: 10m