How to make Sonar ignore some classes for codeCoverage metric?

At the time of this writing (which is with SonarQube 4.5.1), the correct property to set is sonar.coverage.exclusions, e.g.: <properties> <sonar.coverage.exclusions>foo/**/*,**/bar/*</sonar.coverage.exclusions> </properties> This seems to be a change from just a few versions earlier. Note that this excludes the given classes from coverage calculation only. All other metrics and issues are calculated. In order to … Read more

SonarQube not picking up Unit Test Coverage

You were missing a few important sonar properties, Here is a sample from one of my builds: sonar.jdbc.dialect=mssql sonar.projectKey=projectname sonar.projectName=Project Name sonar.projectVersion=1.0 sonar.sources=src sonar.language=java sonar.binaries=build/classes sonar.tests=junit sonar.dynamicAnalysis=reuseReports sonar.junit.reportsPath=build/test-reports sonar.java.coveragePlugin=jacoco sonar.jacoco.reportPath=build/test-reports/jacoco.exec The error in Jenkins console output can be pretty useful for getting code coverage to work. Project coverage is set to 0% since there is … Read more

JaCoCo SonarQube incompatible version 1007

As already mentioned, this is due to a break in JaCoCo maven plugin code. You can (temporarily) specify the version in your jenkins maven command like: clean org.jacoco:jacoco-maven-plugin:<version>:prepare-agent install e.g. clean org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:prepare-agent install This was the workaround that helped us. But like most people, I’m still waiting for the fix to come.

Delete a project from SonarQube

You have 2 ways to delete a project: If you are an admin of the project, you can delete it from its configuration actions => See “Deleting a project” in the “Project Administration” documentation page If you are a SonarQube administrator, then you can also delete a project from the “Project Management” page => See … Read more

SonarQube And SonarLint difference

SonarLint lives only in the IDE (IntelliJ, Eclipse and Visual Studio). Its purpose is to give instantaneous feedback as you type your code. For this, it concentrates on what code you are adding or updating. SonarQube is a central server that processes full analyses (triggered by the various SonarQube Scanners). Its purpose is to give … Read more

How to disable warning on Sonar: Hide Utility Class Constructor?

If this class is only a utility class, you should make the class final and define a private constructor: public final class FilePathHelper { private FilePathHelper() { //not called } } This prevents the default parameter-less constructor from being used elsewhere in your code. Additionally, you can make the class final, so that it can’t … Read more

How to configure multi-module Maven + Sonar + JaCoCo to give merged coverage report?

I was in the same situation as you, the half answers scattered throughout the Internet were quite annoying, since it seemed that many people had the same issue, but no one could be bothered to fully explain how they solved it. The Sonar docs refer to a GitHub project with examples that are helpful. What … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)