style: update golangci-lint and trunk configurations

This commit is contained in:
yusing 2025-05-10 10:46:03 +08:00
parent 8fe94d6d14
commit a06787593c
2 changed files with 156 additions and 140 deletions

View file

@ -1,43 +1,76 @@
run: version: "2"
timeout: 10m linters:
default: all
linters-settings:
govet:
enable-all: true
disable: disable:
- shadow - bodyclose
- fieldalignment - containedctx
gocyclo: - contextcheck
min-complexity: 14 - cyclop
misspell: - depguard
locale: US - dupl
- err113
- exhaustive
- exhaustruct
- forcetypeassert
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocyclo
- gosec
- gosmopolitan
- ireturn
- lll
- maintidx
- makezero
- mnd
- nakedret
- nestif
- nilnil
- nlreturn
- noctx
- nonamedreturns
- paralleltest
- prealloc
- rowserrcheck
- sqlclosecheck
- tagliatelle
- testpackage
- tparallel
- varnamelen
- wrapcheck
- wsl
settings:
errcheck:
exclude-functions:
- fmt.Fprintln
forbidigo:
forbid:
- pattern: ^print(ln)?$
funlen: funlen:
lines: -1 lines: -1
statements: 120 statements: 120
forbidigo: gocyclo:
forbid: min-complexity: 14
- ^print(ln)?$
godox: godox:
keywords: keywords:
- FIXME - FIXME
tagalign: gomoddirectives:
align: false replace-allow-list:
sort: true - github.com/abbot/go-http-auth
order: - github.com/gorilla/mux
- description - github.com/mailgun/minheap
- json - github.com/mailgun/multibuf
- toml - github.com/jaguilar/vt100
- yaml - github.com/cucumber/godog
- yml - github.com/http-wasm/http-wasm-host-go
- label govet:
- label-slice-as-struct disable:
- file - shadow
- kv - fieldalignment
- export enable-all: true
stylecheck: misspell:
dot-import-whitelist: locale: US
- github.com/yusing/go-proxy/internal/utils/testing # go tests only
- github.com/yusing/go-proxy/internal/api/v1/utils # api only
revive: revive:
rules: rules:
- name: struct-tag - name: struct-tag
@ -67,69 +100,51 @@ linters-settings:
disabled: true disabled: true
- name: unreachable-code - name: unreachable-code
- name: redefines-builtin-id - name: redefines-builtin-id
gomoddirectives: staticcheck:
replace-allow-list: checks:
- github.com/abbot/go-http-auth - all
- github.com/gorilla/mux - -SA1019
- github.com/mailgun/minheap dot-import-whitelist:
- github.com/mailgun/multibuf - github.com/yusing/go-proxy/internal/utils/testing
- github.com/jaguilar/vt100 - github.com/yusing/go-proxy/internal/api/v1/utils
- github.com/cucumber/godog tagalign:
- github.com/http-wasm/http-wasm-host-go align: false
sort: true
order:
- description
- json
- toml
- yaml
- yml
- label
- label-slice-as-struct
- file
- kv
- export
testifylint: testifylint:
disable: disable:
- suite-dont-use-pkg - suite-dont-use-pkg
- require-error - require-error
- go-require - go-require
staticcheck: exclusions:
checks: generated: lax
- all presets:
- -SA1019 - comments
errcheck: - common-false-positives
exclude-functions: - legacy
- fmt.Fprintln - std-error-handling
linters: paths:
enable-all: true - third_party$
disable: - builtin$
- execinquery # deprecated - examples$
- gomnd # deprecated formatters:
- sqlclosecheck # not relevant (SQL) enable:
- rowserrcheck # not relevant (SQL) - gofmt
- cyclop # duplicate of gocyclo - gofumpt
- depguard # Not relevant - goimports
- nakedret # Too strict exclusions:
- lll # Not relevant generated: lax
- gocyclo # must be fixed paths:
- gocognit # Too strict - third_party$
- nestif # Too many false-positive. - builtin$
- prealloc # Too many false-positive. - examples$
- makezero # Not relevant
- dupl # Too strict
- gci # I don't care
- goconst # Too annoying
- gosec # Too strict
- gochecknoinits
- gochecknoglobals
- wsl # Too strict
- nlreturn # Not relevant
- mnd # Too strict
- testpackage # Too strict
- tparallel # Not relevant
- paralleltest # Not relevant
- exhaustive # Not relevant
- exhaustruct # Not relevant
- err113 # Too strict
- wrapcheck # Too strict
- noctx # Too strict
- bodyclose # too many false-positive
- forcetypeassert # Too strict
- tagliatelle # Too strict
- varnamelen # Not relevant
- nilnil # Not relevant
- ireturn # Not relevant
- contextcheck # too many false-positive
- containedctx # too many false-positive
- maintidx # kind of duplicate of gocyclo
- nonamedreturns # Too strict
- gosmopolitan # not relevant
- exportloopref # Not relevant since go1.22

View file

@ -2,36 +2,37 @@
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml # To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1 version: 0.1
cli: cli:
version: 1.22.10 version: 1.22.15
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) # Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins: plugins:
sources: sources:
- id: trunk - id: trunk
ref: v1.6.7 ref: v1.6.8
uri: https://github.com/trunk-io/plugins uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) # Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes: runtimes:
enabled: enabled:
- node@18.20.5 - node@18.20.5
- python@3.10.8 - python@3.10.8
- go@1.23.2 - go@1.24.3
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) # This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint: lint:
disabled: disabled:
- markdownlint - markdownlint
- yamllint - yamllint
enabled: enabled:
- checkov@3.2.416
- golangci-lint2@2.1.6
- hadolint@2.12.1-beta - hadolint@2.12.1-beta
- actionlint@1.7.7 - actionlint@1.7.7
- git-diff-check - git-diff-check
- gofmt@1.20.4 - gofmt@1.20.4
- golangci-lint@1.64.5 - osv-scanner@2.0.2
- osv-scanner@1.9.2 - oxipng@9.1.5
- oxipng@9.1.4 - prettier@3.5.3
- prettier@3.5.1
- shellcheck@0.10.0 - shellcheck@0.10.0
- shfmt@3.6.0 - shfmt@3.6.0
- trufflehog@3.88.9 - trufflehog@3.88.29
actions: actions:
disabled: disabled:
- trunk-announce - trunk-announce