Repository navigation
Expand file tree
/
Copy path.golangci.yml
More file actions
127 lines (120 loc) · 4.18 KB
/
Copy path.golangci.yml
File metadata and controls
127 lines (120 loc) · 4.18 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
version: "2"
run:
timeout: 10m
linters:
default: none
enable:
# Bug detection
- govet # Reports suspicious constructs
- ineffassign # Detects unused variable assignments
- staticcheck # Comprehensive static analysis
- unused # Checks for unused code
- errcheck # Check for unchecked errors
- bodyclose # Check HTTP response bodies are closed
- nilerr # Check for nil error returns
- copyloopvar # Check for loop variable capture issues
- exhaustive # Check switch statements cover all enum cases
# Code quality
- misspell # Check for spelling errors
- unconvert # Remove unnecessary type conversions
- unparam # Detect unused function parameters
- prealloc # Find slice declarations that could be pre-allocated
- dupl # Detect copy-pasted code blocks
- gocyclo # Flag functions with high cyclomatic complexity
- gocritic # Broad set of style, performance, and correctness checks
- perfsprint # Detect fmt.Sprintf calls that can be simplified
# Security
- gosec # Security checks
# Dependency hygiene
- depguard # Enforce package import restrictions
settings:
errcheck:
check-type-assertions: true
check-blank: false
misspell:
extra-words:
- typo: "mosquitto"
correction: "mosquitto" # Eclipse Mosquitto MQTT broker (not a misspelling)
gosec:
excludes:
- G104 # Audit errors not checked (too noisy)
- G304 # File path provided as taint input (needed for file operations)
- G301 # Directory permissions (we use 0755 intentionally)
- G302 # File permissions (we use 0644 intentionally for config files)
- G306 # WriteFile permissions (we use 0644 intentionally)
- G112 # Slowloris (proxy server doesn't need ReadHeaderTimeout)
- G101 # Hardcoded credentials (false positive on env var names)
- G115 # Integer overflow (too strict for our use case)
- G404 # Weak random (chaos testing intentionally uses math/rand)
- G204 # Subprocess with variable (benchmark runner needs this)
staticcheck:
checks:
- all
- -SA1019 # Deprecated usage (too strict for some stdlib)
gocyclo:
min-complexity: 30
dupl:
threshold: 150
exhaustive:
default-signifies-exhaustive: true
depguard:
rules:
leaf-packages:
files:
- "**/pkg/ratelimit/*.go"
- "**/pkg/httputil/*.go"
- "**/pkg/util/*.go"
deny:
- pkg: "github.com/getmockd/mockd/pkg/admin"
desc: "leaf packages must not import application packages"
- pkg: "github.com/getmockd/mockd/pkg/engine"
desc: "leaf packages must not import application packages"
- pkg: "github.com/getmockd/mockd/pkg/cli"
desc: "leaf packages must not import application packages"
no-admin-engine-coupling:
files:
- "**/pkg/admin/*.go"
deny:
- pkg: "github.com/getmockd/mockd/pkg/engine"
desc: "admin must not import engine directly — use engineclient HTTP interface"
exclusions:
rules:
# Test files have looser requirements
- path: "_test\\.go"
linters:
- errcheck
- gosec
- ineffassign
- unparam
- prealloc
- dupl
- gocyclo
- gocritic
- perfsprint
- exhaustive
# Benchmarks
# Mock OAuth server — every FormValue/ParseForm triggers G120 (22 occurrences)
# but this is a mock server, not a production auth boundary
- path: "^pkg/oauth/"
linters:
- gosec
text: "G120"
- path: "^benchmarks/"
linters:
- errcheck
- ineffassign
- gosec
- dupl
- gocyclo
- gocritic
- perfsprint
- path: "^tests/"
linters:
- errcheck
- gosec
- unparam
- prealloc
- dupl
- gocyclo
- gocritic
- perfsprint