Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Several quality profiles for one project

Tags:

sonarqube

Is there a way to have several profiles for one project in Sonar ?

For example we have a Java EE project with : EJB and WebApp (JSP and Back Bean). We have 3 quality profiles: Java, Web and XML. To "execute" these 3 profiles on our project we run three sonar analysis and create 3 result projects in Sonar.

We use views to regroupe these three projects, is there a way to have one project that use 3 profiles and not use views?

We want to use views to group different projects and not on the same project.

like image 584
Wilda Avatar asked Jun 17 '13 12:06

Wilda


2 Answers

You can't have multiple profiles for the same project. But if you want this, you just have to create your own custom profile which has all the rules defined in your profiles. For Example, let's say you have quality profile "Android Lint" and "Sonar Way", and if you wan't to check your project against both these profiles, just do the following:

  1. Go to Quality Profiles tab in SonarQube
  2. Click on Back Up on the Profiles you want. It will download an .xml file for each profile.
  3. Just go through the .xml file and figure out how it is written and then Create a new .xml file which contains the rules of both the profiles and give it a cool name.
  4. Go back to Quality Profiles tab in SonarQube
  5. Click on Restore Profile and upload your .xml file.
  6. That's it.

You now have your own custom quality profile with all the rules that you want.

UPDATE: In the latest version of SonarQube (I am using 6.2), you can use the concept of "Inheritance" to combine multiple quality profiles. You can now set a parent quality profile for any profile. Using this you can chain multiple quality profiles.

  • See: SonarQube: How to apply multiple quality profiles to one project?
like image 61
Henry Avatar answered Oct 20 '22 07:10

Henry


Just expanding on @guitarium 's answer above:

For SonarQube 7, you can simply do the following on the SonarQube web portal to add extra rules from other profiles into a custom profile (same as merging, really):

  1. Go into Quality Profiles and click the dropdown next to a profile you want to merge
  2. select Copy
  3. Give the copy a cool name
  4. Click on the new copy to go into it's Quality Profiles page
  5. Go to Actions -> Activate more rules
  6. Click Bulk Change , then Activate in and select your new cool profile
  7. You now have a super cool merged profile. Nice job
like image 42
Fuzzy Analysis Avatar answered Oct 20 '22 08:10

Fuzzy Analysis