Skip to content

How to Detect Cross Component Clones

Teamscale's clone detection allows detecting so-called cross component clones. A component in this context refers to a component as per Teamscale's architecture conformance model and can essentially be an arbitrary subset of the code within a Teamscale project. This feature enables focusing exclusively on the clone relationships that cross the boundaries of certain code areas. An example would be a situation where the code of a component (or project) was forked from another one, and you are interested in the commonalities between the two components.

For cross component clone detection, Teamscale provides a dedicated finding type Cross Component Clones as well as an additional metric Cross Component Clone Coverage. To enable cross component clone detection, activate one or both of these options in the Cloning analysis group of the project's analysis profile:

Analysis Profile Options

Here, you can also specify the name of the architecture file which specifies the components to use for cross component clone detection, or you can keep the provided default. Please note that providing an architecture model is mandatory for cross component clone detection, i.e. an architecture model with the name configured in the cross component clone detection section of the analysis profile must exist in the project.


The architecture used for cross component clone detection has to be a file-based architecture. It is recommended to set the Finding Creation option to None for this architecture and thus exclusively use it for cross component clone detection.

Cross component clones will be detected as soon as the configured architecture model exists in the project history. If you want to analyse cross component clones for the history of a project, the architecture model has to be added in time-travel model to the project's commit history in Teamscale.

When enabling the Cross Component Clones finding, the clone findings will be divided into two distinct subsets. The standard Clones findings will only contain intra-component clones whereas the Cross Component Clones findings will exclusively contain clones between components as per the provided architecture definition. The standard Clone Coverage metric will remain unchanged and consider both intra-component and inter-component clones. The Cross Component Clone Coverage will exclusively consider inter-component clones.

Cross Component Clone FindingsCross Component Clone Coverage

Please note that both the cross component findings, and the cross component clone coverage are sensitive regarding changes to the architecture model used for the detection. Thus, changing the architecture model may result in findings being removed from one finding type (Clones or Cross Component Clones) and added to the other. Similarly, both metrics can change. Note again that this will only affect the findings/metrics from the point in time on when the change to the architecture takes place. If you want to alter the component definition in the project history, the architecture needs to be edited in time-travel mode.