Summary
In this chapter, we saw what metrics Sonar uses to track code duplication and how to use the code widget inside the project dashboard to locate duplicated code. Sonar covers duplication not only at line block and file level in a single project but detects duplicate code across separate projects too. We created an alert to notify us when duplication reaches threshold values and used the Radiator component to get a better synopsis on duplication and its spread.
Finally, we briefly discussed two of the most common techniques in an effort to attack duplication problems such as method extraction and inheritance.
In the next chapter, we will discuss complexity and review some of the more advanced and critical metrics Sonar features.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access