-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
128 lines (123 loc) · 4.08 KB
/
.golangci.yml
File metadata and controls
128 lines (123 loc) · 4.08 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
version: "2"
linters:
enable:
- staticcheck # deep semantic analysis (includes gosimple)
- govet
- errcheck # unchecked errors
- gosec # security
- revive # code style
- gocyclo # complexity
- misspell
- unconvert
- unparam
# Added: catch logic bugs, suspicious conditions, shadowed vars
- gocritic # diagnostic + style + performance checks
- errorlint # require %w wrapping, correct error comparisons
- nilerr # returning nil when err is non-nil
- reassign # detect reassignment of function parameters
- wastedassign # detect wasted assignments
# Type safety
- forcetypeassert # catch type assertions without comma-ok
- exhaustive # catch missing enum switch cases
- errchkjson # catch unchecked json marshal/unmarshal errors
# Performance
- perfsprint # flag fmt.Sprintf replaceable by strconv
# Code hygiene
- forbidigo # ban specific dangerous function calls
- nolintlint # require explanation + specific linter on //nolint
# HTTP safety
- bodyclose # check HTTP response bodies are closed
# Security
- asciicheck # reject non-ASCII identifiers
- bidichk # reject bidi Unicode control chars (Trojan Source)
# Correctness
- copyloopvar # flag unnecessary Go <1.22 loop var copies
- durationcheck # catch duration*duration multiplication bugs
- errname # enforce ErrFoo/FooError naming convention
- makezero # catch make([]T, n) + append bug
# Style / readability
- goconst # find repeated magic strings → constants
- nakedret # flag naked returns in long functions
- usestdlibvars # use stdlib constants instead of magic values
- whitespace # remove stray blank lines in function bodies
# Go 1.22+
- intrange # use range-over-integer syntax
- mirror # avoid needless string↔byte conversions
# Testing
- tparallel # catch incorrect t.Parallel() in subtests
# Duplication / maintainability
- dupl # detect copy-pasted code blocks
- maintidx # maintainability index (complexity + LOC + Halstead)
# Function / file size
- funlen # max lines and statements per function
settings:
errcheck:
check-type-assertions: true
gocyclo:
min-complexity: 10
gocritic:
enabled-tags:
- diagnostic # suspicious code patterns, shadowed vars
- style # idiomatic Go
- performance # allocation/copy issues
disabled-checks:
- hugeParam # too noisy for small structs passed by value
- rangeValCopy # noisy, compiler optimises most cases
- ifElseChain # stylistic, not a bug
- unnamedResult # too strict for small functions
errorlint:
errorf: true
asserts: true
comparison: true
revive:
rules:
- name: exported
disabled: true
- name: package-comments
disabled: true
dupl:
threshold: 75
funlen:
lines: 60
statements: 40
forbidigo:
analyze-types: true
maintidx:
under: 60
nolintlint:
require-explanation: true
require-specific: true
exclusions:
generated: strict
rules:
# Test files: suppress gosec, errcheck, gocritic, errorlint, goconst noise.
- path: _test\.go
linters:
- gosec
- errcheck
- gocritic
- errorlint
- forcetypeassert
- goconst
- dupl
- funlen
- maintidx
# CLI tool intentionally opens user-provided files.
- linters:
- gosec
text: "G304"
path: cmd/tq/(processing|filter)\.go
# Integer overflow in Maxrss/HeapInuse conversions is safe.
- linters:
- gosec
text: "G115"
# detect package stutter is pre-existing public API.
- linters:
- revive
text: "stutters"
path: internal/detect/
run:
timeout: 5m
issues:
max-issues-per-linter: 0
max-same-issues: 0