29

My company has sonar set up to with various plugins (PMD, FindBugs, CheckStyle), and although it is very useful as is (it runs after every Jenkins build that was triggered by a check-in to SVN), I would like it if I could run these various plugins on my local machine before I check the code in.

We have a set of rules already set up in Sonar, so ideally I would like to be able to export that ruleset, perhaps do some munging of the data, and then import the resulting rules into my IDE (Netbeans 7.0.1) into the respective plugins. Is there any way to do this? I've searched all over and short of going through and manually adding each rule to the various plugins, there doesn't appear to be a way to do this. Is there something I'm missing?

TL;DR (Summary): I'd like to export a profile from sonar and import the rule settings into the PMD, Findbugs, and CheckStyle plugins in Netbeans.

frapen
  • 147
  • 2
  • 15
jalsk
  • 293
  • 1
  • 3
  • 6
  • What about the Resharper/StyleCop plugin? The permanent link only provides a xml file which I can´t import into the tools. – Camal Apr 22 '15 at 15:21

4 Answers4

28

Each Sonar profile publishes it's Checkstyle, FIndbugs and PMD configuration under the permalinks tab.

Assuming you've got Sonar installed locally, the following link shows the configuration files used by the "Sonar Way" profile:

http://localhost:9000/profiles/permalinks/2

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
10

You don't need your own Sonar installation. You can get the configuration of any of Sonar's built-in Quality Profiles from Sonar's Nemo site:

There are about a dozen Java Quality Profiles. A commonly used profile - Sonar way with Findbugs - is available at:

http://nemo.sonarsource.org/rules_configuration/index/135

The initial Profile view just lists all the rules. Don't use the "Download" link on that view. That just gives you a CSV listing of the merged rules across all tools. Helpful for review, but not what you're asking for.

To export the tool-specific configuration, select the Permalinks tab/view. Those links return the configuration file in the form expected by each tool. For example, here's the link for the FindBugs XML configuration file:

http://nemo.sonarsource.org/profiles/export?format=findbugs&language=java&name=Sonar%2520way%2520with%2520Findbugs

  • There is some merit to run a local server for using a profile different from the one exposed by a centralized server. This is specially true in very large organizations where getting a Sonar server (or any type of resource for that matter) configure to a team's needs becomes difficult. Or when developers experiment with different profiles before making recommendations to integrate back to the centralized profiles. – luis.espinal Feb 12 '15 at 20:47
2

SonarLint is the newer plugin and it doesn't support Checkstyle/PMD/FindBugs profiles anymore. Everything has to be migrated to squid rules and configured on the SonarQube server under Quality Profiles. You need to connect to the server using connected mode and set your custom quality profile as default so that local analysis would show issues related to your quality profile. More information about SonarLint Plugin and connected mode can be found at http://www.sonarlint.org/eclipse/index.html#Connected

0

Another simple mechanism is to use : Backing up / Restoring a Profile See : http://docs.sonarqube.org/display/SONAR/Profile+Existence+Edits

Taking backup from an instance(source) will give you a backup.xml file on your local machine and then on another instance(destination) you can restore it.

fly2matrix
  • 2,351
  • 12
  • 13