Structure · Maintainability
Functions with nearly identical bodies
rust_doctor::structure::near_duplicate_function_body
Factor the shared shape into one function and pass what differs, or keep both and record why they must stay apart.
- Category
- Maintainability
- Default level
- warn
- Tier
- P3
- Producer
- Structure
- Diff scope
- line
Not a defect when
The similar functions are parallel cases expected to diverge, such as per-protocol handlers or test cases sharing a setup shape, where a common abstraction would obscure each one.
What it reads
Complexity, and families of near-duplicate code.
Tier
Lowest tier: real, and rarely urgent.
The tier bounds how severe a rule may be; its category bounds the tier.Diff scope
The changed line itself.
What--scope contextual looks at to decide whether a change caused the finding.Change it
Turn it off, or make it blocking, without touching the code it flags:
rust-doctor --rule rust_doctor::structure::near_duplicate_function_body=off .
rust-doctor --rule rust_doctor::structure::near_duplicate_function_body=error .