Repository navigation
feat(di): DI002 transitive — a singleton weakly holding a transient that drags in a scoped - #64
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The transitive form of DI002
Extends DI002 (shipped direct in #63) to the transitive case: a singleton holding a
WeakReference<Transient>whose transient strongly depends on a scoped service.The weak edge enters the transient, but the scoped it drags in is still root-resolved and app-lived — a captive one hop below the weak reference. The weak ref keeps the entry edge off the DI001 strong graph, but the captive scoped underneath is the smell → DI002 (warning), with the full path shown.
How
find_weak_captive_dependenciesnow runs the same strong-edge DFS DI001 does, rooted at each weak dep instead of the strong deps: a scoped reached directly (WeakReference<Scoped>) or through a weakly-held transient's strong deps is reported; transients are followed, singleton edges are another singleton's own pass, cycles guarded. Core-only — the extractor already emitsweak_depsand the transient's strong deps.Pinned in CI
DiCaptiveSample.csaddsWeakReport, so thewpf-extractorjob now asserts exactly 3 DI002:WeakCache→ AppDbContextWeakCacheOpt→ AppDbContextWeakReport→ UnitOfWork → AppDbContextWeakReportcarries the pathWeakReport -> UnitOfWork -> AppDbContext; the existing exactly-4-DI001 / exactly-1-DI003 counts andWeakClockHoldersilence are unchanged. The unit test asserts the set + the transitive path.Validated: ruff + mypy clean, ownir 98/98, the 3-DI002 bridge with the transitive path.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Rg8kSk1YT14x7A1vo5zgED
Generated by Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Documentation
Tests