-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
88 lines (81 loc) · 3.54 KB
/
Copy path.golangci.yml
File metadata and controls
88 lines (81 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# golangci-lint v2 config for opendbx
#
# spec-0.10 D-1: 9 精选 business linter + nolintlint meta-linter (10 total).
# Schema reference: https://golangci-lint.run/usage/configuration/
#
# 9 业务 linter (errcheck/govet/staticcheck/gosec/revive/errorlint/ineffassign/
# nilnil/unused) + nolintlint meta. 选用理由见 opendbrb/docs/lint-policy.md § 1.
#
# 推迟 linter (spec-0.10 § 5.1 + spec-0.11 test-framework forward):
# - gofumpt / gci (stricter formatters → spec-0.11)
# - gocyclo / funlen / nestif (复杂度阈值 → spec-0.11 with 5-layer test)
# - 全 ~80 个其他 linter → 永不全开 (噪音哲学 spec-0.10 ❌-5)
#
# Suppression policy (spec-0.10 D-6 / lint-policy.md § 3):
# 每条 //nolint / // #nosec / // errcode-lint:exempt 注释必含
# `-- spec-X.Y D-N: <reason>` 后缀。suppression-lint (spec-0.10 D-2.5) 自动 enforce.
#
# Version lock: golangci-lint v2.0.2 (spec-0.9 D-2 ci.yml pinned).
version: "2"
run:
timeout: 5m
linters:
# spec-0.10 R2 codex LOW-3 + DoD #1: `default: none` 是机器可比对的 drift 防御.
# Schema 自动 + drift 双保, 不需额外 `disable:` 列表 (LOW-3 推荐).
default: none
enable:
# === 9 business linters (spec-0.10 D-1) ===
- errcheck # unchecked error return (CLAUDE.md 规则 7 错误三件套基础)
- govet # Go vet (printf / shift / unreachable)
- staticcheck # SA series code quality (dead store / unused / wrong wrap)
- gosec # security G series (CLAUDE.md 规则 6; spec-0.9 D-2 落地)
- revive # 替代 deprecated golint
- errorlint # error wrapping correctness (spec-0.6 errcode 链 Unwrap 配套)
- ineffassign # ineffective assignment
- nilnil # `return nil, nil` 反模式 (CLAUDE.md 规则 5 无半实现)
- unused # unused identifiers (dead code)
# === 1 meta-linter ===
- nolintlint # //nolint 注释自洽 (与 spec-0.10 D-2.5 suppression-lint 互补)
settings:
revive:
# spec-0.10 R2 codex LOW-2: 仅 3 子规则白名单, 不全开 revive.
# 复杂度/风格类规则推 spec-0.11 (gocyclo/funlen/nestif) 同期定阈值.
rules:
- name: package-comments
- name: var-naming
- name: exported
exclusions:
rules:
# error message capitalization conventions differ in opendbx (Code/
# Message/Hint triple — Message may start with capital noun) — disable
# this errorlint sub-rule.
- linters: [errorlint]
text: "error strings should not be capitalized"
- path: _test\.go
linters: [goconst, gosec]
# Stage-0 scaffolding: stub doc.go files contain only a package
# comment + design ref; revive's "exported" rule complains about
# packages with no exported identifiers, which is intentional here.
- path: internal/.*/doc\.go
linters: [revive]
# tools/dep-allowlist-check intentionally takes a user-supplied path
# to allowlist.yml; gosec G304 (potential file inclusion via variable)
# is the intended interface here.
- path: tools/dep-allowlist-check/.*\.go
text: "G304:"
linters: [gosec]
# cmd/opendbx subcommand stubs are stage-0 placeholders; they
# legitimately ignore writer error returns (writer is bytes.Buffer
# in tests, os.Stdout in prod — neither fails). Will become real
# error-aware code in spec-0.3.
- path: cmd/opendbx/.*\.go
linters: [errcheck]
formatters:
enable:
- gofmt
- goimports
output:
formats:
text:
path: stdout
colors: true