Cloning Metrics

None of the metrics below are set by the cloning detection tool if thresholds are not met. That is, if an artefact has no CC measure in the output file, that does NOT mean that it has no line in common with other artefacts. In models, metrics default to 0 though.

The two main thresholds are:

CC - Code Cloned

Length of the highest Longest Common Substring (LCS) among all cloned artefacts.

Clones are looked in the whole application, in artefacts with the same language and the same type.

  • Textual detection, using lines, with trailing spaces removed

  • Two artefacts are cloned if they have 90% of lines in common, for LC >= 10

Scope: all artefacts but the root node.

CFTC - Control Flow Token (CFT) Cloned

Length of the highest LCS among all cloned CFT.

Clones are looked in the whole application, in artefacts with the same language and the same type.

  • Algorithmic detection, using CFT characters

  • Two artefacts are cloned if they have 90% of characters in common, for CFT >= 50

Scope: all artefacts but the root node.

CAC - Children Artefact Cloned

Number of clones in direct children of an artefact.

Parent clones are looked in the whole application, in artefacts with the same language and the same type.

Two classes may have two methods in common, for example, without being cloned. The CAC metric for these two classes will be two (assuming that they only have these two methods in common). Such artefacts should be re-factored (using inheritance for example).

  • Use both textual (CC > 0) and algorithmic (CFTC > 0) cloning when counting

  • Two parent artefacts are cloned if 25% of their direct children are cloned

  • Small children artefacts (LC < 10) are taken in account, using exact comparison

Scope: all artefacts but the root node.

CN - Clones Number

Number of cloned artefacts.

Clones are looked in the whole application, in artefacts with the same language and the same type.

  • Use both textual (CC > 0) and algorithmic (CFTC > 0) cloning when counting

Scope: all artefacts but the root node.

RS - Repeated Substrings (Repeated Code Blocks)

Length of all Repeated Substrings in the artefact definition.

That is, duplicated blocks in a function for example.

  • Textual detection, using lines, with trailing spaces removed

  • The metric is triggered if blocks longer than 10 are found, for LC >= 10

Scope: files and all children artefacts.

CFTRS - Repeated Substrings in Control Flow Token

Length of all Repeated Substrings in the artefact CFT.

That is, duplicated algorithmic blocks in a function for example.

  • Algorithmic detection, using CFT characters

  • The metric is triggered if blocks longer than 20 are found, for CFT >= 50

Scope: artefacts with a CFT, like functions.

ICC - Inner Code Cloned

Number of duplicated lines in an artefact.

Clones are looked in all descendants of the artefact. This basically sums all duplicated lines in descendants.

  • Use textual cloning (CC > 0) when counting

Scope: all artefacts.

ICFTC - Inner Control Flow Token Cloned

Number of duplicated tokens in an artefact.

Clones are looked in all descendants of the artefact. This basically sums all cloned tokens in descendants.

  • Use algorithmic cloning (CFTC > 0) when counting

Scope: all artefacts.