How to export FindBugs/PMD/Checkstyle rules from Sonar and import into Netbeans

33,301

Solution 1

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

Solution 2

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

Solution 3

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

Share:
33,301
Admin
Author by

Admin

Updated on July 14, 2022

Comments

  • Admin
    Admin almost 2 years

    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.