0
votes

The scenario below is not working for me.

I performed two analysis t1 and t2 as described below

t1: Code with 13.6% coverage is analysed and sent to SonarQube server. Here I am using /d:sonar.projectDate=2016-11-24 as parameter to the scanner. It is 61 lines of code in t1.

enter image description here

t2: Removed the date parameter. Added new code without coverage and also added some duplicated lines. It is 158 lines of code in t2. Coverage dropped to 3.8%. Meaning that lots of code was introduced without the expected coverage.

enter image description here

Questions:

  1. Why is my quality gate still not failing? I am using default quality gate on a local instance. Anything less then 80% should fail the quality gate.
  2. I see some other posts where people say that SCM should be enabled for this to work. What would be the relation? Does anybody know how this coverage on new code is really calculated?
  3. If I enable "common-cs:InsufficientLineCoverage" then the quality gate fail. But it is not related to the thresold that exists on the quality gate, it will follow the thresold of the rule which by default is 65%.

Context where it happens:

  1. Local instance with Default Profile and Quality Gates
  2. SonarQube 6.1
  3. Scanner 2.2.0.24
  4. C# Plugin 5.5.0.479
1

1 Answers

1
votes
  • to be able to determine what is new code, SonarQube relies on the SCM (commit date) information provided
  • the sonar.projectDate parameter is used to rewrite the history of a project to have an evolution of issues created at different point of times
  • if you cannot use an SCM plugin (why not?), then change your Quality Gate to fail if the overall coverage is lower than 80%. The Quality Gate will then fail as long as the project coverage is lower than 80%