Overwriting quality gate in sonar - sonarqube

Is there a way to overwrite the quality gate status of a Sonarqube (5.6) project?
Use case is that we check for technical dept on new code to not be higher than 5%. In case there are additional rules activated in the quality profile, next time a project was checked it will violate the quality gate, even though the technical dept was not introduced by new code but with new rules instead.

Currently there is no way to overwrite quality gate status. From this thread on Google Groups by G. Ann Campbell:
There's not. The best approach is a strategy one: only update the profile / add rules when a new version is just beginning.
Of course, that doesn't really address the issue that new rules raise "new" issues on old code. For that I don't have an answer.

Related

How to skip issue in Sonar Quality gates very first time

I am planing to integrate my project with SonarQube. My project code base is there for many years. After the very first integration I want to skip all the issues and code coverage. I only want the new code to follow the rules and report issues. Otherwise I want my project to get pass the gates with out considering the old code.
Simply use the new ... issues conditions in your Quality Gate, i.e.
Metric Operator Error
New Blocker Issues is greater than 0
New Critical Issues is greater than 0
New Major Issues is greater than 0
This way, the Quality Gate of the first scan will always be green.

Updating project status under a change in quality gate

I recently used sonarqube api to create a dynamic quality gate, it increases or decreases the acceptable number for the project, according to the number of lines of code, but I'm having some problems ...
It works like this, after the analysis I use the number of lines and calculate the quality gate to increase or lower the acceptable limit
I use the sonar line count itself to avoid mismatching information, but whenever I update a quality gate, the project status is not updated.
For example, if a project was with the quality gate with the status "Passed", after I update the quality gate, it should change the status to "Failed", but it remains "Passed" because I did not perform a new analysis.
How can I request pro sonar to re-execute the project status according to the quality gate change?
I'm using sonarqube 6.0
Thanks
You have no choice but to re-run an analysis if you want your quality gate to be updated.
Just as a side note: it looks like you are trying to hack SonarQube features, I would not recommend to go into that way because you will for sure face problems. Instead, I highly encourage you to read "Water Leak Changes the Game for Technical Debt Management" and consider using the built-in quality gate that puts the focus on new code: this is the best and easiest way to improve code quality over-time with almost no effort and no friction.

SonarQube projects pass Quality Gate when there is no data?

I'm using SonarQube 5.4 and I noticed that when a metric, which is used to calculate the Quality Gate status, is missing then that is handled in the same way as if the criteria was met.
Isn't it more intuitive that the Quality Gate fails if there is missing information to determine the status?
Or at least that it is configurable to fail by default if there is missing data?
Instead of having the quality gate able to deal with a missing code coverage measure our goal is to find a standard way to force coverage to 0 when there is no coverage information available for one source file. This is not an easy subject but this is something that we'll try to fix part of https://jira.sonarsource.com/browse/MMF-345.

SonarQube Quality Gates for Manual Measures

I am using some manual metrics on my SonarQube Project. I want to use my own manual metrics as a condition on a Quality Gate. I searched through documentation and internet. I could not find anything about the topic. The SonarQube allows to use only system metrics. Are there any way to use Manual Metrics on a condition in QualityGate ?
Quality Gate conditions can actually be created based on manual metrics, but some metric types are not available: DATA, RATING and (obviously) Quality Gate status.
Manual metrics are created with the hidden attribute set to NULL in the database. Changing it to 0 makes the manual metric appear in the "Add Condition" dropdown of the quality gates.
Since the manual metrics seem to work fine with the quality gates, I assume this is a bug in SonarQube.
Credit to Stefan Egli's comment which guided me in the right direction.

SonarQube exclude based on date?

Now that the Cutoff date plugin for Sonar is deprecated (I've tried it, and it doesn't seem to work at all), is there any way to exclude issues based on a set date?
For a large project, it is desirable to really start at fresh at given point.
Maintaining a low alert threshold ( < 100 alerts ) is much more manageable for the developers than cluttering the issues listings with old history/low priority issues. (1500++). Identifying the new and relevant ones are then much harder.
What we want to focus on are new issues.
Example:
when you have changed the quality rules for say 200.000+ lines of code, you really only are interested in what is produced from now on and changes to already existing code that breaks the new rules.
If my feeling is correct, you're not aware of the way to work with differential periods in SonarQube. Because out-of-the-box SonarQube is designed to cover such common use case. See :
http://www.sonarqube.org/differentials-four-ways-to-see-whats-changed/
http://www.sonarqube.org/using-differentials-to-move-the-team-in-the-right-direction/
http://www.sonarqube.org/differentials-but-wait-theres-more/

Resources