Sonar code duplication metrics

Sonar uses the following four metrics to cover code duplication. Duplicated lines can also be expressed as a percentage value and we will create an alert with a threshold value of five percent.

Name

Description

Duplicated Lines

Number of physical lines touched by duplication.

Duplicated Blocks

Number of duplicated blocks participating in duplication.

Duplicated Files

Number of files containing duplicated lines or blocks.

Density of Duplicated Lines

Sonar code duplication metrics

Creating Duplicated Code Alert

Log in to Sonar and navigate to the custom packt profile configuration screen. Add a new alert as shown in the following screenshot: ...

Get Sonar Code Quality Testing Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.