CQM-DuplicateCode

Number of cloned lines of code

Counts the number of cloned lines found by the rule: C++CloneDetection.

Motivation

Identical or similar functionality often has to be used in multiple locations. However, instead of extracting the functionality and making it usable, it is duplicated using copy and paste. This way clones can be created that include function parts, whole and multiple functions, complete classes or even complete files. The multiple occurrence of identical code fragments means repeated efforts in understanding, maintaining and testing. In particular, changes have to be made consistently several times, which in turn is very error-prone.

This rule is based on the CQM Quality Indicator: duplizierter Code (p. 183-185).

Reference

Simon, Frank/ Seng, Olaf/ Mohaupt, Thomas (2006): Code-Quality-Management: Technische Qualität industrieller Softwaresysteme transparent und vergleichbar gemacht, 1st ed., Heidelberg, Germany: dpunkt.verlag GmbH.

Possible Messages

This rule has no predefined messages.

Options

clone_detection_rulename

clone_detection_rulename : str = 'C++CloneDetection'

Rule name of the CloneDetection rule from which the clones are found. Note that the rule named here must be explicitly activated. If AxivionC#Frontend is used this defaults to 'C#CloneDetection'; if AxivionRustFrontend is used this defaults to 'RustCloneDetection' if not configured otherwise.
 

display_name

display_name : str = 'Number of cloned lines of code'

Description of the metric shown in the dashboard. If None, rfg_metric_name is used.
 

max_value

max_value : float | None = 15969.0

Maximum allowed value. None if unlimited.
 

min_value

min_value : float | None = 0.0

Minimum allowed value. None if unlimited.
 

rfg_metric_name

rfg_metric_name : str = 'Metric.Clone.LOC'

Name of the node attribute storing the metric value in the RFG.