Commit 8303c2a
committed
fix: resolve all bugs and improve code quality (v0.16.1)
Comprehensive bug fixes discovered through systematic code audit using parallel
agent searches, ast-grep, and race detection. This release fixes 19 bugs total
(11 CRITICAL/HIGH + 8 MEDIUM/LOW).
1. **PANIC prevention**: Fixed array index out of bounds in snapshot/capture.go
- Added bounds checking before accessing split results
- Prevents runtime panic when parsing empty Java version output
2. **Resource leak**: Fixed file handle leak in cli/update.go
- Added defer f.Close() immediately after file creation
- Ensures cleanup even on error paths
3. **Signal handler leak**: Fixed in ui/progress.go
- Call signal.Stop() before signal.Notify() to prevent duplicate registrations
- Prevents goroutine and memory leaks on repeated Start() calls
4. **Error handling**: Fixed GetInstalledPackages errors in brew.go
- Check and propagate errors instead of using empty maps
- Prevents skipping package installations silently
5. **Error handling**: Fixed brew doctor error ignored in brew.go
- Check error from brew doctor command
- Enables proper diagnostics of brew issues
6. **HTTP leak**: Fixed response body not deferred in auth/login.go
- Use defer resp.Body.Close() immediately after Get
- Prevents connection leaks on panic or early return
7. **Dead code**: Fixed unreachable error check in npm.go
- Check if parts[0] is empty string (strings.Split never returns empty slice)
- Properly catches invalid version format
8-9. **npm errors**: Fixed GetInstalledPackages errors ignored in npm.go (2 instances)
- Check errors at lines 113 and 147
- Propagate errors instead of silently using empty maps
10. **Goroutine leak**: Fixed in CheckForUpdatesAsync by adding context cancellation
- Added context.Context parameter to allow graceful shutdown
- Prevents goroutine leaks when app exits
11. **Deadlock prevention**: Fixed render() calls under mutex in progress.go
- Moved I/O operations outside of mutex.Lock()
- Prevents potential deadlock when rendering progress
12. **Network error handling**: Fixed connection close in CheckNetwork
- Check and handle conn.Close() errors properly
- Improves error diagnostics
13. **Version parsing**: Fixed empty string silent failures in snapshot/capture.go
- Return empty string consistently on parse failure
- More predictable error handling
14. **String slicing**: Fixed logic error in brew.go
- Fixed: checks >60 but now slices at 60 (was 57)
- Consistent truncation behavior
15. **Error handling**: Fixed os.UserHomeDir() errors ignored in updater.go
- Proper error checking and propagation
- Prevents using empty string as home directory
16. **Performance**: Reused HTTP client via sync.Once in updater.go
- Reduces overhead of creating new client per request
- Better resource utilization
17-18. **Dead code**: Removed redundant len(parts) > 0 checks in npm.go
- strings.Split() always returns at least 1 element
- Cleaned up unreachable conditions
Added coverage files to .gitignore:
- coverage.out, coverage.html, *.coverprofile
✅ All tests passing: go test ./internal/... -short
✅ No race conditions: go test -race ./internal/... -short
✅ Version bumped: 0.16.0 → 0.16.11 parent 2d28fbe commit 8303c2a
9 files changed
Lines changed: 107 additions & 41 deletions
File tree
- internal
- auth
- brew
- cli
- npm
- snapshot
- ui
- updater
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
153 | | - | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
| |||
477 | 480 | | |
478 | 481 | | |
479 | 482 | | |
480 | | - | |
| 483 | + | |
481 | 484 | | |
482 | 485 | | |
483 | 486 | | |
| |||
529 | 532 | | |
530 | 533 | | |
531 | 534 | | |
532 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
533 | 538 | | |
534 | 539 | | |
535 | 540 | | |
| |||
546 | 551 | | |
547 | 552 | | |
548 | 553 | | |
549 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
550 | 558 | | |
551 | 559 | | |
552 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | 79 | | |
81 | 80 | | |
82 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
| |||
110 | 108 | | |
111 | 109 | | |
112 | 110 | | |
113 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
| |||
201 | 205 | | |
202 | 206 | | |
203 | 207 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
473 | 478 | | |
474 | 479 | | |
475 | 480 | | |
| |||
479 | 484 | | |
480 | 485 | | |
481 | 486 | | |
| 487 | + | |
482 | 488 | | |
483 | 489 | | |
484 | 490 | | |
| |||
491 | 497 | | |
492 | 498 | | |
493 | 499 | | |
| 500 | + | |
494 | 501 | | |
495 | | - | |
496 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
497 | 507 | | |
498 | 508 | | |
499 | 509 | | |
500 | 510 | | |
| 511 | + | |
501 | 512 | | |
502 | 513 | | |
503 | 514 | | |
504 | 515 | | |
505 | 516 | | |
506 | 517 | | |
| 518 | + | |
507 | 519 | | |
508 | 520 | | |
509 | 521 | | |
510 | 522 | | |
511 | 523 | | |
512 | 524 | | |
| 525 | + | |
513 | 526 | | |
514 | 527 | | |
515 | 528 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | | - | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
156 | | - | |
157 | 159 | | |
158 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
159 | 164 | | |
160 | 165 | | |
161 | 166 | | |
| |||
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
183 | | - | |
184 | 188 | | |
| 189 | + | |
185 | 190 | | |
186 | 191 | | |
187 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| |||
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
39 | | - | |
| 46 | + | |
40 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
41 | 54 | | |
42 | 55 | | |
43 | 56 | | |
| |||
77 | 90 | | |
78 | 91 | | |
79 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
80 | 100 | | |
81 | | - | |
| 101 | + | |
82 | 102 | | |
83 | 103 | | |
84 | 104 | | |
| |||
97 | 117 | | |
98 | 118 | | |
99 | 119 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
103 | 126 | | |
104 | 127 | | |
105 | 128 | | |
106 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
107 | 135 | | |
108 | 136 | | |
109 | 137 | | |
| |||
117 | 145 | | |
118 | 146 | | |
119 | 147 | | |
120 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
121 | 153 | | |
122 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
123 | 157 | | |
124 | 158 | | |
125 | 159 | | |
| |||
0 commit comments