Backend Notes AUG 13, 2024 • 02 MIN READ
EXCLUSION FILE AND
DUPLICATION CHECK
ON SONARQUBE
Sonarqube is an open source platform developed by SonarSource for continuous inspection of code quality to perform automatic review with static analysis of code to detect bugs and code smells on programming language.
In every Spring project that we create, of course we use Sonarqube to maintain code quality. And sometimes we need to set exceptions for which files can be scanned by Sonarqube.
Setting exclusion file
We can set which files are not scanned by Sonarqube in the file pom.xml
POM.xml XML
<properties>
<sonar.coverage.exclusions>
**/config/*.java,
**/config/**/*.java,
**/constant/*.java,
**/model/*.java,
**/model/**/*.java,
**/model/**/**/*.java,
**/exception/*.java,
**/filter/*.java,
**/repository/*.java,
**/repository/**/*.java,
**/SimulatorServiceApplication.java
</sonar.coverage.exclusions>
</properties>Setting duplication check
We can set it like this
POM.xml XML
<properties>
<sonar.cpd.exclusions>
**/config/*.java,
**/config/**/*.java,
**/constant/*.java,
**/model/*.java,
**/model/**/*.java,
**/model/**/**/*.java
</sonar.cpd.exclusions>
</properties>