Commit a29c550
refactor: merge v2 modular architecture into internal package (#17)
* refactor: merge v2 modular architecture into internal package
This refactoring applies the successful pattern from gormreuse/zerologlintctx:
create v2 with ideal architecture, then merge v2→v1.
Key changes:
- Add internal/check: check context module for checker implementations
- Add internal/checker.go: unified checker interfaces (GoStmtChecker, CallChecker)
- Add internal/checkers: individual checker implementations
- goroutine.go: go statement checker
- callarg.go: errgroup/waitgroup/conc/spawner checkers
- gotask.go: gotask library checker
- Add internal/scope: context scope detection
- Reorganize directives:
- internal/directives/* → internal/directive/* (singular)
- Simplified carrier, ignore, spawner modules
- Merge internal/deriver: deriver matcher with OR/AND semantics
- Simplify internal/runner.go: use new checker interfaces
- Consolidate internal/ssa: merge builder and tracer
Package structure after merge:
- internal/check/ - check context for patterns
- internal/checkers/ - individual checker implementations
- internal/deriver/ - derive function matcher
- internal/directive/ - ignore, spawner, carrier directives
- internal/funcspec/ - function specification parsing
- internal/scope/ - context scope detection
- internal/ssa/ - SSA program and tracer
Removed:
- internal/directives/ - replaced by internal/directive
- internal/ssa/helpers.go - merged into tracer.go
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor: consolidate duplicate functions and remove dead code
- Remove dead code packages: internal/context, internal/patterns
- Simplify internal/registry (remove unused Patterns field)
- Simplify internal/apis.go (remove patterns-related code)
- Rename internal/check to internal/probe for clarity
- Move internal/spawnerlabel to internal/checkers/spawnerlabel
- Consolidate duplicate isContextOrCarrierType functions:
- Add carrier.IsCarrierType() as the canonical implementation
- Remove duplicates from probe, scope, and ssa packages
- Clean up internal/typeutil (remove 5 unused exported functions)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add comprehensive package documentation
- Add doc.go files to all internal packages with:
- ASCII architecture diagrams
- Code examples
- API documentation
- Fix redundant import aliases (internal "...")
- Exclude doc.go files from gci formatter in golangci-lint
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor: remove unused functions to improve coverage
Remove dead code functions that are never called:
- probe.Context.Report, FuncOf
- probe.Context.FuncLitOfIdentBefore
- scope.Scope.CtxName
- ssa.Program.EnclosingFunc, findEnclosingFunc
- spawner.FindFuncArgs
Coverage improved from 84.1% to 85.8%
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(ignore): remove unused AllCheckerNames function
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* refactor(ignore): remove unused Entry getter methods
Entry fields are only accessed internally within the package.
External code uses high-level APIs (ShouldIgnore, GetUnusedIgnores).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* refactor(callarg): remove unused variadic support code
- Remove Variadic field from CallArgEntry (never set to true)
- Remove checkVariadic, formatOrdinals functions (dead code)
- Move ordinal function to gotask.go (only user)
Coverage improved: 86.1% → 87.7%
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* test: improve coverage for gotask and spawner checkers
Coverage improvements:
- carrier.matchPkg: 28.6% → 100%
- gotask.callbackCallsDeriver: 50.0% → 83.3%
- callarg.checkFuncArg: 58.3% → 75.0%
- gotask.identIsDeriverCall: 60.0% → 100%
Bug fix:
- Add *ast.ParenExpr case to findConstructorCall to handle (*taskPtr).DoAsync()
New test cases:
- carrier_test.go: unit tests for matchPkg and Parse functions
- gotask/advanced.go: callback variable patterns, derived context variable tests
- gotask/evil.go: pointer dereference limitation documentation
- spawner/spawner.go: factory function patterns
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent f6beeaf commit a29c550
File tree
58 files changed
+3292
-2808
lines changed- internal
- checkers
- spawnerlabel
- context
- deriver
- directives
- carrier
- ignore
- directive
- carrier
- ignore
- spawner
- funcspec
- patterns
- probe
- registry
- scope
- ssa
- typeutil
- testdata
- metatest/tests
- src
- gotask
- spawner
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
58 files changed
+3292
-2808
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | | - | |
22 | | - | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 92 | | |
95 | | - | |
| 93 | + | |
96 | 94 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
101 | 99 | | |
102 | 100 | | |
103 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
104 | 105 | | |
105 | | - | |
106 | | - | |
| 106 | + | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
116 | 125 | | |
117 | 126 | | |
118 | 127 | | |
| |||
124 | 133 | | |
125 | 134 | | |
126 | 135 | | |
127 | | - | |
128 | | - | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
132 | 139 | | |
133 | 140 | | |
134 | 141 | | |
135 | | - | |
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
| |||
156 | 162 | | |
157 | 163 | | |
158 | 164 | | |
159 | | - | |
160 | | - | |
161 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
162 | 169 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
167 | 173 | | |
168 | 174 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 175 | + | |
| 176 | + | |
172 | 177 | | |
| 178 | + | |
| 179 | + | |
173 | 180 | | |
174 | | - | |
| 181 | + | |
175 | 182 | | |
| 183 | + | |
176 | 184 | | |
177 | | - | |
| 185 | + | |
178 | 186 | | |
| 187 | + | |
179 | 188 | | |
180 | | - | |
| 189 | + | |
181 | 190 | | |
182 | | - | |
183 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
184 | 200 | | |
185 | 201 | | |
186 | | - | |
| 202 | + | |
187 | 203 | | |
188 | 204 | | |
189 | 205 | | |
| |||
0 commit comments