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.
Related
I am trying to add a quality gate in sonarqube, to fail if the new code coverage % drops below the overall code coverage.
Anyone have tried this ?
You're going to have to be more specific. I'm not sure what "overall" means. Are you referring to the "after merge" value? It's also unclear whether you're referring to a "base project" or a pull request or branch.
If you're looking to ensure that the "after merge" coverage on a branch scan satisfies a required threshold, I'm pretty sure you can't do that out of the box with SonarQube, but you should also specify what version of SonarQube you're using.
I implemented a check for whether the "after merge" coverage value of a branch scan satisfies our required threshold, but I had to do it in script code, using the SonarQube Web API. I had it obtain the project's quality gate, along with the resulting coverage from the scan, and if it's below the required number, I have it fail the build with an appropriate message. There's no way to mark the scan itself to be in violation, but at least we can make the build fail.
I'm kinda new to SonarQube and I just found this:
Question: How? Shouldn't the Quality Gate be failing? Or do the quality gate only work for new code?
The quality rules are the default ones
Yes, it is possible. Why? It depends how the Quality Gate is configured.
Copied from SonarQube Quality Gates documentation:
Each Quality Gate condition is a combination of:
measure
comparison operator
error value
For instance, a condition might be:
measure: Blocker issue
comparison operator: >
error value: 0
Which can be stated as: No blocker issues.
Your Quality Gate could be configured to check only new code or even to not check the code at all.
Sonar way (Built-in) Quality Profile on SonarQube 7.9.2 checks only new code:
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.
In a quality gate, we are able to specify values for 'Mutations Coverage', that specify when a warning or error is generated. Is there a way to display the mutations coverage value.
For example in the Measures -> Coverage tab?
This is where It coverage and the number of unit tests are displayed.
Any suggestions would be most welcome
All non-hidden measures (there are some metrics that are hidden either because they're deprecated or because they're calculated solely to feed other metrics) are displayed automatically in the Measures space.
If you have a plugin that's creating Mutations Coverage metrics, those values should already be available. But such measures are not created by default.
Tangential but relevant: SonarQube 6.2 consolidated coverage metrics into simply Coverage. Now you can feed as many coverage reports as you want, assuming the language plugin has been upgraded to support that, but the values are consolidated under the theory that by and large people don't care how the code is covered, only that it is.
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.