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

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