146 lines
2.8 KiB
YAML
146 lines
2.8 KiB
YAML
# golangci-lint v2 — Gateway 專案
|
||
# 參考:https://golangci-lint.run/docs/configuration/
|
||
# 預設集「standard」= errcheck + govet + ineffassign + staticcheck + unused(取代已棄用的 golint)
|
||
# 再啟用社群常見的品質 / 安全 / 風格 linter,並關閉過度吵雜的規則。
|
||
|
||
version: "2"
|
||
|
||
run:
|
||
timeout: 5m
|
||
tests: true
|
||
modules-download-mode: readonly
|
||
go: "1.26"
|
||
|
||
output:
|
||
formats:
|
||
text:
|
||
print-linter-name: true
|
||
colors: true
|
||
|
||
linters:
|
||
default: standard
|
||
|
||
enable:
|
||
# 錯誤與 context
|
||
- bodyclose
|
||
- contextcheck
|
||
- copyloopvar
|
||
- errname
|
||
- errorlint
|
||
- noctx
|
||
# 安全
|
||
- gosec
|
||
# 風格(revive 為 golint 的現代替代)
|
||
- revive
|
||
- misspell
|
||
- unconvert
|
||
- whitespace
|
||
- gocritic
|
||
- goconst
|
||
- predeclared
|
||
# 測試
|
||
- testifylint
|
||
- thelper
|
||
# HTTP / API 常見
|
||
- rowserrcheck
|
||
- sloglint
|
||
|
||
disable:
|
||
- exhaustruct
|
||
- varnamelen
|
||
- wrapcheck
|
||
- nlreturn
|
||
- wsl
|
||
- wsl_v5
|
||
- dupl
|
||
- depguard
|
||
- tagliatelle
|
||
- ireturn
|
||
- funlen
|
||
- gochecknoglobals
|
||
- gochecknoinits
|
||
|
||
settings:
|
||
gosec:
|
||
excludes:
|
||
- G104
|
||
gocritic:
|
||
enabled-tags:
|
||
- diagnostic
|
||
- style
|
||
- performance
|
||
disabled-checks:
|
||
- hugeParam
|
||
- rangeValCopy
|
||
- whyNoLint
|
||
revive:
|
||
severity: warning
|
||
rules:
|
||
- name: blank-imports
|
||
- name: context-as-argument
|
||
- name: context-keys-type
|
||
- name: dot-imports
|
||
- name: error-return
|
||
- name: error-naming
|
||
- name: exported
|
||
arguments:
|
||
- disableStutteringCheck
|
||
- name: increment-decrement
|
||
- name: indent-error-flow
|
||
- name: range
|
||
- name: receiver-naming
|
||
- name: time-naming
|
||
- name: unexported-return
|
||
- name: var-declaration
|
||
- name: var-naming
|
||
disabled: true
|
||
- name: package-comments
|
||
disabled: true
|
||
- name: comment-spacings
|
||
disabled: true
|
||
errcheck:
|
||
check-type-assertions: true
|
||
check-blank: true
|
||
staticcheck:
|
||
checks:
|
||
- all
|
||
- -ST1000
|
||
- -ST1003
|
||
- -ST1016
|
||
|
||
exclusions:
|
||
generated: lax
|
||
warn-unused: true
|
||
presets:
|
||
- comments
|
||
- common-false-positives
|
||
- std-error-handling
|
||
- legacy
|
||
rules:
|
||
- path: _test\.go
|
||
linters:
|
||
- gosec
|
||
- errcheck
|
||
- funlen
|
||
- gocyclo
|
||
- cyclop
|
||
- path: internal/types/types\.go
|
||
linters:
|
||
- revive
|
||
- gocritic
|
||
paths:
|
||
- generate/doc-generate
|
||
- docs/openapi
|
||
|
||
formatters:
|
||
enable:
|
||
- goimports
|
||
exclusions:
|
||
generated: lax
|
||
paths:
|
||
- generate/doc-generate
|
||
|
||
issues:
|
||
max-issues-per-linter: 0
|
||
max-same-issues: 0
|