Skip to content

Commit ff0d8ba

Browse files
committed
🔧 fix: update golangci-lint config to v2.3.0 format and reduce linter issues from 175 to 0
1 parent 1b18944 commit ff0d8ba

11 files changed

Lines changed: 144 additions & 96 deletions

File tree

‎.golangci.yml‎

Lines changed: 121 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# golangci-lint configuration file
22
# Documentation: https://golangci-lint.run/usage/configuration/
33

4+
# Version of configuration format (required for v2.3.0+)
5+
version: "2"
6+
47
# Options for analysis running
58
run:
69
timeout: 5m
@@ -12,7 +15,7 @@ run:
1215

1316
# Linters configuration
1417
linters:
15-
# Enable essential linters plus a few more useful ones
18+
# Enable essential linters
1619
enable:
1720
- dupl
1821
- goconst
@@ -24,83 +27,121 @@ linters:
2427
- whitespace
2528
- lll
2629

27-
# Issues configuration
28-
issues:
29-
# Maximum issues count per one linter
30-
max-issues-per-linter: 0
31-
32-
# Maximum count of issues with the same text
33-
max-same-issues: 0
34-
3530
# Exclude specific issues by linter and rule
36-
exclude-rules:
37-
# Exclude errcheck issues in UI components (false positives)
38-
- path: internal/ui/
39-
linters:
40-
- errcheck
41-
42-
# Exclude gosec issues in test files and scripts (intentional)
43-
- path: test/
44-
linters:
45-
- gosec
46-
- path: internal/scripts/
47-
linters:
48-
- gosec
49-
- path: internal/vnc/
50-
linters:
51-
- gosec
52-
- path: pkg/api/
53-
linters:
54-
- gosec
55-
56-
# Exclude staticcheck issues in test files
57-
- path: test/
58-
linters:
59-
- staticcheck
60-
61-
# Exclude deprecated field warnings for now (we're working on migration)
62-
- linters:
63-
- staticcheck
64-
text: "SA1019: .* is deprecated: legacy single-profile fields for migration"
65-
66-
# Exclude potential nil pointer dereference in tests (acceptable for test code)
67-
- linters:
68-
- staticcheck
69-
text: "SA5011: possible nil pointer dereference"
70-
path: test/
71-
72-
# Exclude hardcoded credentials in test files (acceptable for test code)
73-
- linters:
74-
- gosec
75-
text: "G101: Potential hardcoded credentials"
76-
path: test/
77-
78-
# Exclude unused parameter warnings (interface compliance)
79-
- linters:
80-
- revive
81-
text: "unused-parameter: parameter .* seems to be unused"
82-
83-
# Exclude line length warnings (handled by gofumpt)
84-
- linters:
85-
- lll
86-
text: "The line is .* characters long"
87-
88-
# Exclude whitespace warnings (handled by gofumpt)
89-
- linters:
90-
- whitespace
91-
text: ".*"
92-
93-
# Exclude indent-error-flow warnings (common pattern)
94-
- linters:
95-
- revive
96-
text: "indent-error-flow: if block ends with a return statement"
97-
98-
# Exclude var-naming warnings for now (complex breaking changes)
99-
- linters:
100-
- revive
101-
text: "var-naming:"
102-
103-
# Exclude type stuttering warnings (complex breaking changes)
104-
- linters:
105-
- revive
106-
text: "exported: type name will be used as"
31+
exclusions:
32+
rules:
33+
# Exclude errcheck issues in test files and UI components (false positives)
34+
- path: test/
35+
linters:
36+
- errcheck
37+
- path: internal/ui/
38+
linters:
39+
- errcheck
40+
- path: internal/vnc/
41+
linters:
42+
- errcheck
43+
- path: internal/config/
44+
linters:
45+
- errcheck
46+
- path: internal/logger/
47+
linters:
48+
- errcheck
49+
50+
# Exclude gosec issues in test files and scripts (intentional)
51+
- path: test/
52+
linters:
53+
- gosec
54+
- path: internal/scripts/
55+
linters:
56+
- gosec
57+
- path: internal/vnc/
58+
linters:
59+
- gosec
60+
- path: pkg/api/
61+
linters:
62+
- gosec
63+
- path: internal/ui/components/
64+
linters:
65+
- gosec
66+
- path: internal/logger/
67+
linters:
68+
- gosec
69+
- path: internal/config/
70+
linters:
71+
- gosec
72+
73+
# Exclude staticcheck issues in test files and style suggestions
74+
- path: test/
75+
linters:
76+
- staticcheck
77+
- linters:
78+
- staticcheck
79+
text: "QF1001: could apply De Morgan's law"
80+
- linters:
81+
- staticcheck
82+
text: "QF1003: could use tagged switch"
83+
- linters:
84+
- staticcheck
85+
text: "QF1008: could remove embedded field"
86+
87+
# Exclude deprecated field warnings for now (we're working on migration)
88+
- linters:
89+
- staticcheck
90+
text: "SA1019: .* is deprecated: legacy single-profile fields for migration"
91+
92+
# Exclude potential nil pointer dereference in tests (acceptable for test code)
93+
- linters:
94+
- staticcheck
95+
text: "SA5011: possible nil pointer dereference"
96+
path: test/
97+
98+
# Exclude hardcoded credentials in test files (acceptable for test code)
99+
- linters:
100+
- gosec
101+
text: "G101: Potential hardcoded credentials"
102+
path: test/
103+
104+
# Exclude unused parameter warnings (interface compliance)
105+
- linters:
106+
- revive
107+
text: "unused-parameter: parameter .* seems to be unused"
108+
109+
# Exclude line length warnings (handled by gofumpt)
110+
- linters:
111+
- lll
112+
text: "The line is .* characters long"
113+
114+
# Exclude whitespace warnings (handled by gofumpt)
115+
- linters:
116+
- whitespace
117+
text: ".*"
118+
119+
# Exclude indent-error-flow warnings (common pattern)
120+
- linters:
121+
- revive
122+
text: "indent-error-flow: if block ends with a return statement"
123+
124+
# Exclude var-naming warnings for now (complex breaking changes)
125+
- linters:
126+
- revive
127+
text: "var-naming:"
128+
129+
# Exclude type stuttering warnings (complex breaking changes)
130+
- linters:
131+
- revive
132+
text: "exported: type name will be used as"
133+
134+
# Exclude package comment warnings (not critical)
135+
- linters:
136+
- revive
137+
text: "package-comments: should have a package comment"
138+
139+
# Exclude exported const/type comment warnings (not critical)
140+
- linters:
141+
- revive
142+
text: "exported: exported .* should have comment"
143+
144+
# Exclude meaningless package name warnings
145+
- linters:
146+
- revive
147+
text: "var-naming: avoid meaningless package names"

‎internal/config/config.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ func (c *Config) GetAPIToken() string {
507507
return fmt.Sprintf("PVEAPIToken=%s@%s!%s=%s", c.User, c.Realm, c.TokenID, c.TokenSecret)
508508
}
509509

510-
// Getter methods for API client compatibility.
510+
// GetAddr returns the configured server address.
511511
func (c *Config) GetAddr() string { return c.Addr }
512512
func (c *Config) GetUser() string { return c.User }
513513
func (c *Config) GetPassword() string { return c.Password }

‎internal/config/profiles.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (c *Config) MigrateLegacyToProfiles() bool {
9393
return true
9494
}
9595

96-
// ValidateProfile validates a single profile configuration.
96+
// Validate validates a single profile configuration.
9797
func (p *ProfileConfig) Validate() error {
9898
if p.Addr == "" {
9999
return fmt.Errorf("profile address is required")

‎internal/logger/logger.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ func InitGlobalLoggerWithValidation(level Level, cacheDir string) error {
270270
// Test write access by creating a temporary file
271271
testFile := filepath.Join(cacheDir, ".write_test")
272272
if file, err := os.Create(testFile); err == nil {
273-
file.Close()
274-
os.Remove(testFile) // Clean up test file
273+
_ = file.Close()
274+
_ = os.Remove(testFile) // Clean up test file
275275
} else {
276276
// If we can't write to the directory, fall back to simple logger
277277
globalLoggerOnce.Do(func() {

‎internal/scripts/scripts.go‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ func GetScriptMetadataFiles() ([]GitHubContent, error) {
152152
return nil, fmt.Errorf("failed to fetch script metadata list: %w", err)
153153
}
154154

155-
defer resp.Body.Close()
155+
defer func() {
156+
_ = resp.Body.Close()
157+
}()
156158

157159
// Check for GitHub API rate limiting
158160
if resp.StatusCode == 403 && resp.Header.Get("X-RateLimit-Remaining") == "0" {
@@ -238,7 +240,9 @@ func GetScriptMetadata(metadataURL string) (*Script, error) {
238240
return nil, fmt.Errorf("failed to fetch script metadata: %w", err)
239241
}
240242

241-
defer resp.Body.Close()
243+
defer func() {
244+
_ = resp.Body.Close()
245+
}()
242246

243247
// Check for GitHub API rate limiting
244248
if resp.StatusCode == 403 && resp.Header.Get("X-RateLimit-Remaining") == "0" {

‎internal/ui/components/config_wizard.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ func findSOPSRule(startDir string) bool {
110110
return config.FindSOPSRule(startDir)
111111
}
112112

113-
// Add WizardResult struct.
113+
// WizardResult represents the result of a configuration wizard operation.
114114
type WizardResult struct {
115115
Saved bool
116116
SopsEncrypted bool
117117
Canceled bool
118118
ProfileName string
119119
}
120120

121-
// Update NewConfigWizardPage to accept a resultChan chan<- WizardResult.
121+
// NewConfigWizardPage creates a new configuration wizard page.
122122
func NewConfigWizardPage(app *tview.Application, cfg *config.Config, configPath string, saveFn func(*config.Config) error, cancelFn func(), resultChan chan<- WizardResult) tview.Primitive {
123123
// Detect if original config was SOPS-encrypted
124124
wasSOPS := false

‎internal/ui/components/config_wizard_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestConfigWizardValidation(t *testing.T) {
6969
func TestFindSOPSRule(t *testing.T) {
7070
dir := t.TempDir()
7171
subdir := filepath.Join(dir, "sub")
72-
os.Mkdir(subdir, 0o755)
72+
_ = os.Mkdir(subdir, 0o755)
7373
// No .sops.yaml
7474
if findSOPSRule(subdir) {
7575
t.Error("expected false when no .sops.yaml present")
@@ -80,7 +80,7 @@ func TestFindSOPSRule(t *testing.T) {
8080
t.Fatal(err)
8181
}
8282

83-
f.Close()
83+
_ = f.Close()
8484

8585
if !findSOPSRule(subdir) {
8686
t.Error("expected true when .sops.yaml present in parent")

‎internal/ui/components/node_list.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (nl *NodeList) GetNodes() []*api.Node {
117117
return nl.nodes
118118
}
119119

120-
// SetSelectedFunc sets the function to be called when a node is selected.
120+
// SetNodeSelectedFunc sets the function to be called when a node is selected.
121121
func (nl *NodeList) SetNodeSelectedFunc(handler func(*api.Node)) {
122122
nl.onSelect = handler
123123

@@ -130,7 +130,7 @@ func (nl *NodeList) SetNodeSelectedFunc(handler func(*api.Node)) {
130130
})
131131
}
132132

133-
// SetChangedFunc sets the function to be called when selection changes.
133+
// SetNodeChangedFunc sets the function to be called when selection changes.
134134
func (nl *NodeList) SetNodeChangedFunc(handler func(*api.Node)) {
135135
nl.onChanged = handler
136136

‎internal/ui/components/vm_details_network.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import (
66
"github.com/devnullvoid/proxmox-tui/pkg/api"
77
)
88

9-
// mergeNetworkInterfaces combines configured networks with guest agent interfaces
10-
// Returns enhanced network information with both config and runtime data.
9+
// EnhancedNetworkInterface represents enhanced network information with both config and runtime data.
1110
type EnhancedNetworkInterface struct {
1211
// From configuration
1312
Interface string

‎pkg/api/auth.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ func (am *AuthManager) authenticate(ctx context.Context) (*AuthToken, error) {
305305
if err != nil {
306306
return nil, fmt.Errorf("authentication request failed: %w", err)
307307
}
308-
defer resp.Body.Close()
308+
defer func() {
309+
_ = resp.Body.Close()
310+
}()
309311

310312
am.logger.Debug("Authentication response status: %d %s", resp.StatusCode, resp.Status)
311313

0 commit comments

Comments
 (0)