Code quality and technical debt

Shotgun surgery

Also known as Shotgun surgery, Shotgun surgery in software engineering

By WeavePublished 1 min read

Definition

A code smell in which one conceptual change requires small edits across many modules.

What it means

Shotgun surgery occurs when a single policy or behavior is scattered through many locations. The dispersion increases coordination, review burden, and the chance of missing one occurrence. It differs from a large central change because the problem is breadth of locations rather than size of one edit.

Example

Adding a new invoice status requires edits to validators, formatters, persistence mappings, reports, and tests. The team maps the spread and decides whether a shared policy or clearer boundary would contain future changes.

Limitations

Distributed behavior can be intentional when each layer owns a distinct translation. Centralizing everything may create a large, fragile module. Confirm the change reasons and ownership before consolidating.

How to use the signal

Trace the conceptual rule across locations before consolidating it, since separate translations may be intentional at system boundaries.

Weave can show how scattered changes affect review duration, blocked time, and rework. Use history and architecture analysis to establish the pattern, then use Weave to prioritize it.

How this relates to Weave

Weave can show how scattered changes affect review duration, blocked time, and rework. Use history and architecture analysis to establish the pattern, then use Weave to prioritize it.

Explore Engineering intelligence

Sources and further reading

  1. SonarSource code metrics and analysis documentation