I'm a big fan of SonarQube as a developer. This time though I need to do admin work since I need to configure it from a fresh install. I see this rule in SonarQube "Methods should not have too many lines" but I don't see that it belongs to any of the default profiles ("FindBugs+FB-Contrib", "Sonar Way"). I think that's the reason I don't see any rule violations of this type from any of the projects. I thought this should be part of a common default profile since this is a pretty common violation. How can I add this rule to the profile?
There are other rules that I need to add which I expected also to be in the default/available profiles already.
You can't edit built-in profiles. Instead, you'll have to create a new profile, and then you'll be able to edit the rules to your heart's content. I suggest you initialize your new profile either by copying the rules from the built-in profile of your choice, or by inheriting from that profile. Note that choosing the latter means your profile can (and probably will) be updated by upgrading your analyzers; each new version of SonarJava, for instance, implements new rules and many of them are added to the Sonar way profile.
Related
I have a very large Java project with a massive codebase statically analysed with SonarQube. A part of it, confined to one module, is currently being rewritten. I would like to apply a different quality profile to this part of the codebase without changing the profile for the rest of the project. To be more specific: I would like to disable one of the rules in the current quality profile just for this one module. Is this possible and if yes, how do I do that?
I have been scouring through SonarQube settings looking for any options for this kind of setup. The only thing I have found until now is the option to Restrict Scope of Coding Rules under Project settings > Analysis Scope. Here one can restrict the application of a certain rules or rules to only certain file patterns. Not exactly what I was looking for.
Any ideas?
I am using sonarqube developer's edition and i cannot see any options to deactivate a active rule in any quality profile as there was in basic version.
Can anyone please give me an idea as to to deactivate any active rule while using sonarqube commercial?
Thanks
You can't edit built in profiles. Probably what you want to do is
create a new profile, say P1
set it as the default
copy into it the rules from the profile you have been using
edit (add/delete/update) the rules in P1 to meet your needs
Alternately, 'P1' could inherit from Sonar way, but then you wouldn't be able to remove rules that were added by inheritance, only edit (presumably downgrade) their severities. You would still be able to add new rules and then subsequently remove those rules you had added directly.
We previously directed changed rules in the default sonar way quality profile.
To better track the changes made I created a new one which inherited the default one.
I then restore the built-in profile and reapplied out change in our new profile.
But after a new analysis we now have lot of issues reported as new.
Did I do something wrong ?
thanks for some explanation.
SonarQube Version 5.6
The default contents of the Sonar Way quality profile, can change from version to version as new rules are implemented, altho upgrading a plugin does not automatically add those new rules to an existing Sonar Way profile because of exactly what you saw. So your restoration pulled in all the rules that have been added to the profile since you first started with the plugin (or since the last time you performed a restoration). Additionally, new plugin versions may improve the implementations of existing rules, so new issues can show up after an upgrade even if you don't do a restore.
The restoration is why a lot of new issues were added on your subsequent analysis.
I've read the docs about profile inhertiance [1]. They say that "A rule inherited from a parent cannot be deactivated". Is this on purpose and will it be supported in the future?
When I upgrade some plugin (i.e. the JavaScript analysis plugin) there are new rules and I have to restore the built-in profile "Sonar Way" in order to get the new rules. However when I do this I lose all the previous configurations (deactivated rules) and I have to remember what I've done in the past and repeat that again.
It sounds like you're using the built-in profile as your default profile. If you're happy with the built-in profile as-is, then that's a great way to go. But it sounds like you're not. So instead, I'd suggest you make a copy of Sonar Way, I'll call it 'Copy', and set it as your default profile. Then after each upgrade, you can reset Sonar Way, use the comparison service to see the differences between Copy and Sonar Way and then choose which new changes to apply in Copy.
I would like to use the default rule set provided by sonarqube (5.1.2) which is collected in the default profile "sonar way". Now I need to add/remove some rules. What is the bets practice here? So far I have created a copy of the default profile and applied my changes there. Then after installing a new plugin I noticed that the default profile has been extend by some rules (obviously the useful ones) of that new plugin. So I need to add them manually to my custom profile. I reckon the same happens with updates of the java plugin.
My questions:
Should I work with a copy of the original profile to not pollute it and retain the opportunity to restore it to the factory defaults? (conclusion: manual work every time an update or new plugin comes in)
Should work with the original profile? (will it then still be updated without conflicts on new plugins/updates?)
Is there a way to work with a profile that is linked to the original profile? (like an overlay filesystem over a read only filesystem => OverlayFS)
You might be interested in profile inheritance: http://docs.sonarqube.org/display/SONAR/Non-rule+Profile+Edits+and+Information#Non-ruleProfileEditsandInformation-ProfileInheritance