Problem- Quality Gate Blocker on New Code from Existing Issue

  • SonarCloud Developer
  • Bitbucket Pipeline Scan
  • Recently transitioned project from SonarQube

Hello! We are having a problem with old issues showing up as blockers for Quality Gates on what should be new code.

Our team recently transitioned over from SonarQube to SonarCloud MTM and are having issues with “New Code”. The previous definition we used was the mainline branch as the reference branch and on that branch we defined a 30 day “number of days” time period for new code. That does not appear to be an option in SonarCloud, so we are using the “previous version option”, although in testing this issue has occurred in the “number of days” setting as well.

The problem is really old issues that do not have a history of ever being closed and have nothing to do with new code are presenting as blockers. These methods and blocks of code have been untouched for years.

Can someone please assist?


Hi,

Welcome to the community!

Your second screenshot shows that your issue was raised on June 27. Would that be the date you first analyzed the project on SonarCloud?

When a project is first analyzed, all the issues raised in that analysis get the analysis date, rather than all being backdated to when the code was last touched.

 
HTH,
Ann

No, we only started using SonarCloud this year, in June 27th 2017 we were still using SonarQube. The problem isn’t that the issues aren’t being backdated it is that items already raised years ago are being considered blockers now.

Hi,

Sorry, somehow my brain turned off before I got to the year. :woman_facepalming:

So going back to the screenshot that shows your failing Quality Gate, I see two broken conditions

  • Reliability Rating < A
  • Blockers > 0

Both of these seem to be Overall conditions. They don’t count only against new code, but against everything.

So your Quality Gate is working exactly as designed (by you).

 
Ann

No, the quality gate conditions are only on new code.

Hi,

I don’t think the Quality Gate you’re showing is what’s applied. Because if it were, then the failed conditions shown on your project homepage would include the words “on New Code”.

 
Ann

If that was the case, wouldn’t all branches in the project be affected? We are only experiencing this issue on a subset. Also, shouldn’t I be able to see additional Quality Gates under “Quality Gates”? If it can be applied from elsewhere, I would not know where to look.

Hi,

When was 9.0-API-251 last analyzed? Perhaps the Quality Gate assigned to the project was changed since those passing branches were last analyzed?

You should be able to see which Quality Gate is applied on the Project Information tab…

 
Ann

I can confirm the Quality Gate assigned to the project is only listed as “New Code”. To my understanding there was never any Quality Gate without the New Code condition.

That branch ran 6 days ago. I do not have the ability to re-analyze that specific branch right now but that specific issue was merged into a different branch which I was able to re-analyze today and it is still having that problem.


Hi,

Okay, I’m finally registering that your homepage screenshots don’t include New and Overall tabs. That means we’re dealing with a short-lived branch, where only “new” code and “new” conditions are considered. (Sorry, I’m a little slow sometimes.)

So then this is either about the definition of new code for your branch or about the SCM data available during analysis.

This docs section is labeled for PRs, but it applies here too.

Can you provide the full analysis log for this branch?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann