Skip to content

Commit 0b021fc

Browse files
committed
feat: enhance golangci-lint configuration for better code quality
- Add 10+ new high-value linters focusing on security, k8s patterns, and code quality - Enhanced error handling with errorlint, nilerr for robust controller code - Added security linters: gosec, bodyclose, contextcheck, noctx - Improved import organization with gci for large project maintainability - Added character safety checks: asciicheck, bidichk - Enhanced testing support with testpackage for Ginkgo conventions - Strategically disabled overly restrictive linters (varnamelen, exhaustruct, etc.) - Maintains compatibility with existing codebase while improving standards Fixes #149 Signed-off-by: Rishi Jat <[email protected]>
1 parent 8e98c80 commit 0b021fc

File tree

1 file changed

+66
-28
lines changed

1 file changed

+66
-28
lines changed

.golangci.yml

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,71 @@
1-
version: "2"
1+
# Enhanced golangci-lint configuration for llm-d-inference-scheduler
2+
# Expanded from 22 to 30+ linters for improved code quality, security, and maintainability
3+
# Focus on practical improvements suitable for Kubernetes controller development
24

35
run:
4-
timeout: 5m
5-
allow-parallel-runners: true
6-
7-
formatters:
8-
enable:
9-
- goimports
10-
- gofmt
6+
timeout: 10m
7+
modules-download-mode: readonly
118

129
linters:
1310
enable:
14-
- copyloopvar
15-
- dupword
16-
- durationcheck
17-
- fatcontext
18-
- ginkgolinter
19-
- gocritic
20-
- govet
21-
- loggercheck
22-
- misspell
23-
- perfsprint
24-
- revive
25-
- unconvert
26-
- makezero
27-
- errcheck
28-
- goconst
29-
- ineffassign
30-
- nakedret
31-
- prealloc
32-
- unparam
33-
- unused
11+
# === ORIGINAL LINTERS (maintained) ===
12+
- copyloopvar # Loop variable capture issues (Go 1.22+)
13+
- dupword # Duplicate words in comments
14+
- durationcheck # Duration multiplication issues (important for k8s timers)
15+
- fatcontext # Nested contexts in loops
16+
- ginkgolinter # Ginkgo test framework linting (CRITICAL - heavily used)
17+
- gocritic # Comprehensive static code analyzer
18+
- govet # Go's built-in static analyzer
19+
- loggercheck # Logger usage patterns (CRITICAL for controller-runtime)
20+
- misspell # Spelling mistakes in comments
21+
- perfsprint # fmt.Sprintf performance issues
22+
- revive # Go best practices and style guide
23+
- unconvert # Unnecessary type conversions
24+
- makezero # Slice declarations with non-zero length
25+
- errcheck # Unchecked errors (CRITICAL for robust Go code)
26+
- goconst # Repeated strings that should be constants
27+
- ineffassign # Ineffectual assignments
28+
- nakedret # Naked returns in functions longer than specified length
29+
- prealloc # Slice pre-allocation opportunities
30+
- unparam # Unused function parameters
31+
- unused # Unused code (helps reduce bloat)
32+
33+
# === NEW HIGH-VALUE ADDITIONS ===
34+
# Formatting and style consistency
35+
- gofmt # Ensures code is gofmt-ed
36+
- goimports # Import organization and unused import removal
37+
38+
# Security enhancements
39+
- gosec # Security vulnerability scanner
40+
- bodyclose # Ensures HTTP response bodies are closed
41+
42+
# Context and resource management (critical for k8s controllers)
43+
- contextcheck # Proper context usage patterns
44+
- noctx # HTTP requests without context
45+
46+
# Character encoding safety
47+
- asciicheck # Non-ASCII identifiers
48+
- bidichk # Dangerous unicode character sequences
49+
50+
# Enhanced error handling
51+
- errorlint # Error wrapping scheme validation
52+
- nilerr # Nil error handling pattern issues
53+
54+
# Code quality improvements
55+
- testpackage # Test package naming conventions
56+
57+
# Import organization for large projects
58+
- gci # Advanced import grouping
59+
60+
disable:
61+
# Linters that are too restrictive or noisy for this project type
62+
- varnamelen # Variable name length (Go idioms favor short names)
63+
- exhaustruct # Exhaustive struct initialization (too restrictive)
64+
- nlreturn # Newlines before returns (too opinionated)
65+
- wsl # Whitespace linter (too opinionated)
66+
- lll # Line length (handled by gofmt)
67+
- gomnd # Magic number detection (too noisy)
68+
- cyclop # Cyclomatic complexity (can be overly strict)
69+
- funlen # Function length (can be overly strict)
70+
- nestif # Nested if statements (can be overly strict)
71+
- gocognit # Cognitive complexity (can be overly strict)

0 commit comments

Comments
 (0)