-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yaml
More file actions
171 lines (143 loc) · 4.7 KB
/
Copy path.golangci.yaml
File metadata and controls
171 lines (143 loc) · 4.7 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
version: "2"
formatters:
enable:
- gofmt # Standard Go formatting
- goimports # Import formatting and organization
- gci # Canonical import grouping and formatting
- gofumpt # Stricter gofmt with additional style rules
settings: {}
linters:
# Start with no defaults and explicitly enable linters
default: none
enable:
# Core linters - essential for code quality
- errcheck # Check for unchecked errors
- govet # Reports suspicious constructs
- staticcheck # Go static analysis
- unused # Check for unused code
- ineffassign # Detect ineffectual assignments
# Style and consistency
- misspell # Find commonly misspelled words
# Modern Go features
- copyloopvar # Detect loop variable issues (Go 1.22+)
# Code quality
- gocritic # Comprehensive meta-linter
- revive # Fast, configurable, extensible linter
- unconvert # Remove unnecessary type conversions
# Security
- gosec # Security-focused linter
# Complexity
- gocyclo # Compute cyclomatic complexity
# Best practices
- nolintlint # Reports ill-formed or insufficient nolint directives
- bodyclose # Check for unclosed HTTP response bodies
settings:
errcheck:
# Ignore these functions for error checking (common in CLI tools)
exclude-functions:
- fmt.Fprint
- fmt.Fprintf
- fmt.Fprintln
- (io.Writer).Write
- (*github.com/fatih/color.Color).Fprintf
gocyclo:
# Maximum cyclomatic complexity - TUI handlers can be naturally complex
min-complexity: 35
gosec:
# Exclude rules that are false positives for CLI tools
excludes:
- G104 # Audit errors not checked (handled by errcheck)
- G304 # File path provided as taint input (expected in CLI tools)
- G306 # WriteFile permissions (0644 is fine for config files)
misspell:
locale: US
govet:
# Enable all analyzers
enable-all: true
disable:
- shadow
- fieldalignment
- unusedwrite # Common in test structs with intentional field writes
gocritic:
# Enable multiple check groups
enabled-tags:
- diagnostic
- style
- performance
disabled-checks:
- paramTypeCombine # Can be noisy for CLI flag definitions
- unnamedResult # Allow unnamed results for simple functions
- evalOrder # Too pedantic about expression evaluation order
- singleCaseSwitch # Single case switch is acceptable for consistency
- ifElseChain # Long if-else chains can be clearer than switch
- builtinShadow # Allow shadowing in test files
- stringXbytes # Allow string conversion for comparison
- emptyStringTest # Allow len(s) == 0 style
- hugeParam # Allow large struct parameters
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: increment-decrement
- name: var-naming
- name: var-declaration
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: errorf
- name: superfluous-else
- name: unreachable-code
exclusions:
# Use common presets for sensible defaults
presets:
- std-error-handling
- common-false-positives
rules:
# Exclude errcheck in test files
- path: _test\.go
linters:
- errcheck
- gosec
# Exclude staticcheck SA4006 and SA9003 in test files
- path: _test\.go
text: "SA4006|SA9003"
# Exclude gocritic nestingReduce as it's stylistic
- linters:
- gocritic
text: "nestingReduce"
issues:
# Maximum issues count per linter (0 = unlimited)
max-issues-per-linter: 50
# Maximum count of same issues (0 = unlimited)
max-same-issues: 10
# Make issues output unique by line
uniq-by-line: false
run:
# Timeout for analysis
timeout: 5m
# Modules download mode (readonly for CI)
modules-download-mode: readonly
# Include test files in analysis
tests: true
# Build tags to use during analysis
build-tags: []
output:
# Format for output
formats:
text:
path: stdout
print-issued-lines: true
print-linter-name: true
colors: true
# Sort order for issues
sort-order:
- file
- linter
# Show statistics per linter
show-stats: false