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.

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.