This repository was archived by the owner on Nov 10, 2025. It is now read-only.
Commit 040cb97
authored
feat: Add automatic error comparison and type assertion fixes (#96)
Signed-off-by: Kemal Akkoyun <[email protected]>
Co-authored-by: ccoVeille <[email protected]>
Enhance errorlint analyzer with automatic fixes for:
- Error comparisons using `==` and `!=`
- Type assertions on errors
- Error switches
Adds suggested fixes to:
- Replace direct error comparisons with `errors.Is()`
- Convert type assertions to use `errors.As()`
- Transform error switches to use `errors.Is()` and `errors.As()`
Includes new test cases and golden files to validate the new automatic fixing capabilities.
* feat: Improve errorlint with better variable naming and error handling
- Add function for meaningful error variable names
- Preserve original "ok" variable names in type assertions
- Use errors.As() with generated variable names
- Add tests for custom and wrapped errors1 parent aa9b5f9 commit 040cb97
File tree
7 files changed
+1368
-16
lines changed- errorlint
- testdata/src
- errorassert
- errorcompare
7 files changed
+1368
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
27 | 45 | | |
28 | 46 | | |
29 | 47 | | |
| |||
70 | 88 | | |
71 | 89 | | |
72 | 90 | | |
| 91 | + | |
| 92 | + | |
73 | 93 | | |
74 | 94 | | |
75 | 95 | | |
| |||
95 | 115 | | |
96 | 116 | | |
97 | 117 | | |
| 118 | + | |
| 119 | + | |
98 | 120 | | |
99 | 121 | | |
100 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
0 commit comments