← Rule catalog

Structure · Maintainability

Functions with identical bodies apart from names

rust_doctor::structure::duplicate_function_body

Keep one definition and call it from the other sites, or make what differs between them a parameter.

Category
Maintainability
Default level
warn
Tier
P3
Producer
Structure
Diff scope
line

Not a defect when

The copies live in independently versioned crates or in test fixtures, or implement the same trait for unrelated types, where a shared helper would couple code meant to evolve separately.

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::duplicate_function_body=off .
rust-doctor --rule rust_doctor::structure::duplicate_function_body=error .

Set it once in rust-doctor.toml

Other Maintainability rules