How to integrate sevntu checks into SonarQubeTM (developer's guide)

Roman Ivanov edited this page Dec 16, 2013 · 1 revision

Create SonarQube’s rule for your check

$ cd sevntu-checkstyle-sonar-plugin
$ vi ./src/main/resources/com/github/sevntu/checkstyle/sonar/checkstyle-extensions.xml

# Add a rule for your check to the specific for the check group: 'sizes',
# 'naming', 'design', 'coding'... Look at the existence rules in the file
# to create your own configuration.

$ mvn clean install
$ cp target/sevntu-checkstyle-sonar-plugin-x.x.x.jar [SONAR_HOME]/extensions/plugins/
$ [SONAR_HOME]/bin/linux-x86-64/ restart

Verify your check’s integration

  • Open Sonar. In Quality Profiles tab create a new profile and set it as default.

  • Open profile and paste check’s key or name into Name/Key field (E.g: com.github.sevntu.checkstyle.checks.sizes.LineLengthExtendedCheck (as a key) or Line Length Extended (as a name)):

  • Activate and configure your check:

  • Run this sonar’s profile on your maven project, there shouldn’t be any errors
# NOTE: This command works for Sonar installed on your localhost and uses mysql DB 
# which is on the localhost as well. Modify maven parameters if needed.

$ mvn sonar:sonar -Dsonar.jdbc.url=jdbc:mysql://localhost:3306/sonarqube -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.username=sonar -Dsonar.jdbc.password=sonar -Dmaven.test.failure.ignore=true -Dsonargraph.prepareForSonar=true -Dsonar.verbose=true -Dsonar.forceAnalysis=true

When releasing sevntu-checkstyle-sonar-plugin project…

  • Activate new checks which will be released

  • Export updated sevntu-checkstyle-sonar-plugin-x.×.×.xml here with replacing the old version (right click on ‘Checkstyle’ link, save as)