CodeImprover Technical Reference

Metric name: Code Duplication


The same sequence and content of code lines are duplicated several times at different positions in the codebase. This is either due to special circumstances or an indication of stressed or poorly educated programmers that implements some functionality by copy-paste code from somewhere else.
Duplicated code might be caused by languages that need sequences of declarations. One such example could be a (long) list of using statement in a C# file.

Default setting:

More than 7 (seven) lines of identical code are considered code duplication.


If an error is detected and corrected in one of the copies it is very common not to apply the same correction to all other copies. Simply because the copies are not identified.

What to do:

Isolate the duplicated code in a method of its own and replace every copy with a call to the new method.


Remark: The CodeImprover Metrics app does not check for duplicated code. A separate app for duplication-checking is expected to ship in Q1 2021

Context – How it works
Back to – Metrics reference overview