-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path.golangci.yml
More file actions
128 lines (115 loc) · 3.16 KB
/
.golangci.yml
File metadata and controls
128 lines (115 loc) · 3.16 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"
run:
timeout: 5m
tests: true
linters:
enable:
# Default/essential
- govet
- errcheck
- staticcheck
- unused
- ineffassign
# Code quality
- gocritic
- gocyclo
- misspell
- unconvert
- unparam
# Security
- gosec
# Style consistency
- revive
- nolintlint
settings:
errcheck:
check-blank: false
exclude-functions:
# Common functions where ignoring errors is acceptable
- os.Setenv
- os.Unsetenv
- os.RemoveAll
- os.Chdir
- os.Getwd
- os.UserHomeDir
# Print functions where errors are generally not actionable
- fmt.Fprintf
- fmt.Fprintln
- fmt.Fprint
- (io.Closer).Close
gocyclo:
min-complexity: 30 # CLI tools often have complex switch statements
gocritic:
enabled-tags:
- diagnostic
- performance
disabled-checks:
- hugeParam # Too noisy for value receivers on small structs
- appendCombine # Style preference, not a bug
- ifElseChain # Style preference
- wrapperFunc # Style preference
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
disabled: true # Too noisy for CLI tools
- name: increment-decrement
- name: var-naming
disabled: true # Intentional shadowing of stdlib errors package
- 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 # unparam handles this
- name: unreachable-code
- name: redefines-builtin-id
gosec:
excludes:
- G104 # Audit errors not checked (errcheck handles this)
- G204 # Subprocess with variable (expected for CLI that runs user commands)
- G301 # Directory permissions 0755 (standard for CLI tools)
- G304 # File path from variable (common in CLI tools)
- G306 # WriteFile permissions 0644 (standard for config files)
- G602 # Slice bounds (false positive in controlled code)
nolintlint:
require-explanation: true
require-specific: true
exclusions:
generated: lax
presets:
- comments
- std-error-handling
rules:
# Allow Close() errors to be ignored in defer statements
- linters:
- errcheck
source: "defer.*Close\\(\\)"
# Allow forceRemove errors to be ignored in lock cleanup
- linters:
- errcheck
source: "forceRemove\\("
# Test files can be more relaxed
- path: _test\.go
linters:
- gocyclo
- gosec
- errcheck
- unparam
formatters:
enable:
- gofmt
- goimports