Releases: mpyw/gormreuse
v0.13.2
Documentation Updates
This release contains documentation improvements across the codebase:
Changes
-
Expanded purity package documentation (
internal/ssa/purity/validator.go)- Added detailed Pure Contract explanation
- Documented SSA-based derivation tracking analysis strategy
- Clarified what pure functions CAN do
-
Improved doc comment accuracy (
analyzer.go)- Fixed Session() placement explanation (now correctly shows
.Session()at end of chain) - Added
//gormreuse:immutable-returnto supported directives list
- Fixed Session() placement explanation (now correctly shows
-
README cleanup
- Removed retracted versions warning (handled by go.mod retract directive)
Full Changelog
v0.13.1
What's Changed
Bug Fixes
-
Fix incorrect unused directive detection logic (#51, #52)
//gormreuse:pureand//gormreuse:immutable-returnwere incorrectly reported as unused- Changed detection from "was consulted during analysis" to "does the function have a valid signature"
//gormreuse:pureis now unused only if function has NO*gorm.DBin parameters//gormreuse:immutable-returnis now unused only if function has NO*gorm.DBin return values
-
Treat interface types as potentially containing
*gorm.DBinterface{}parameters/returns are now valid for directives (can hold*gorm.DBat runtime)
-
Also check for
gorm.DB(non-pointer) typegorm.DBby value is also dangerous because it contains*Statementwhich is shared when copied
Improvements
- Improve pointer chain detection in closure captures
- Recursively unwrap
**gorm.DB,***gorm.DB, etc. inClosureCapturesGormDB - Add
containsGormDBThroughPointers()for consistent pointer chain handling
- Recursively unwrap
Refactoring
- Extract signature validation to separate file (
signature.go) - Add comprehensive tests for type checking (generic types, containers, cycle detection)
Retracted Versions
- v0.13.0 is retracted due to incorrect unused directive detection logic
Design Summary
| Function | Purpose | Pointer Chain | interface{} | struct fields |
|---|---|---|---|---|
typeutil.IsGormDB |
SSA analysis | 1 level only | ✗ | ✗ |
containsGormDBThroughPointers |
Closure capture | Recursive | ✗ | ✗ |
containsGormDB |
Directive validation | Recursive | ✓ | ✓ |
Full Changelog: v0.13.0...v0.13.1
v0.13.0
What's Changed
New Features
- Support
//gormreuse:pureand//gormreuse:immutable-returndirectives on closures (#48) - Detect unused
//gormreuse:pureand//gormreuse:immutable-returndirectives (#49)
Bug Fixes
- Optimize
hasCodeBeforeCommentto avoid timeout on large files (#50)
Performance Improvements
- Use
inspector.Preorderfor faster AST traversal (~40% improvement) - Cache
ast/inspector.Inspectorper file to avoid recreation - Cache
fix.Generatoracross violations in the same analysis run - Add
t.Parallelfor faster test execution
Full Changelog: v0.12.0...v0.13.0
v0.12.0
What's Changed
Bug Fixes
- Fix false positives for single-return closure + method chain in loop patterns (#45)
- Add global edit deduplication to prevent duplicate
Session()in suggested fixes
Tests
- Add comprehensive test files for closure loop patterns (
closure_loop.go) - Add comprehensive test files for interface conversion behaviors (
interface_patterns.go)
Full Changelog: v0.11.6...v0.12.0
v0.11.6
What's Changed
Documentation
- docs: update CLAUDE.md for user-defined function reassignment behavior
Updated internal documentation to reflect the new behavior where user-defined functions that return *gorm.DB with the result being assigned are treated like gorm method assignments (no pollution).
Full Changelog: v0.11.5...v0.11.6
v0.11.5
What's Changed
Bug Fixes
- fix: resolve false positive for user-defined function reassignment pattern (#44)
When a user-defined function receives *gorm.DB as argument and returns *gorm.DB with the result being assigned (e.g., q = buildQuery(q, "filter")), treat it like a gorm method assignment instead of marking the argument as polluted.
This enables the common builder pattern:
q := db.Where("base")
if condition1 {
q = buildAlertQuery(q, types) // No longer false positive
}
if condition2 {
q = buildVersionStatusQuery(q, status) // No longer false positive
}
q.Find(nil) // OK - first actual useFull Changelog: v0.11.4...v0.11.5
v0.11.4
Bug Fixes
-
fix: add FindAllMutableRoots for Phi receiver tracing in bound/go/defer (#43)
- Add
FindAllMutableRootsto trace all possible mutable roots from Phi nodes - Process
gostatements in second pass to handle SSA block ordering - Add tests for Phi receiver scenarios with one polluted branch
- Add
-
fix: resolve false positive for chained method calls in switch cases (#41)
Full Changelog
v0.11.3
Bug Fixes
- Fix Session edit position to target innermost CallExpr instead of outermost
- Prevents Session being incorrectly added to wrapper functions like
t.Run()orTransaction() - Session now correctly added to the actual
*gorm.DBmethod call
- Prevents Session being incorrectly added to wrapper functions like
- Add gorm import automatically when Session fix requires it
- Handles both single imports (
import "pkg") and grouped imports (import (...))
- Handles both single imports (
v0.11.2
Changes
Code Cleanup & Refactoring
- Unified
PureFuncSetandImmutableReturnFuncSetinto genericDirectiveFuncSet(-185 lines) - Trimmed excessive documentation in
handler/call.gowhile preserving concrete examples (-880 lines) - Removed unused
analyzedFnfield frompollution.Tracker(-6 lines) - Renamed
PureFuncKeytoFuncKeyfor consistency
Results
- Net reduction: ~1000 lines of code
- Coverage: maintained at ~89%
- All tests passing
Full Changelog: v0.11.1...v0.11.2
v0.11.1
What's Changed
Code Quality Improvements
- Reduce code duplication and improve maintainability (-162 lines)
- Extract common patterns into reusable helper functions
- Coverage improved from 88.8% to 89.4%
Changes
handler/call.go: Unified Go/Defer handlers withprocessGormDBCallCommonWithpollution/tracker.go: Unified violation detection loops withcheckViolationsBetweentracer/root.go: Unified swap-phi detection withisLoopVariableSwap
Full Changelog: v0.11.0...v0.11.1