SonarQube feature branch checks for new code does not show failures but it does on master

Must-share information (formatted with Markdown):

  • sonar-qube-scanner.4.6.2.2472
  • sonar-scanner-cli-4.6.2.2472

The simple requirement is to be able to receive SonarQube quality failures when a running on a feature branch, before the code is merged in master. Instead, the feature branch passes and when it’s merged into master it fails. It seems like there’s a bug with the “new code” setting, and it doesn’t pick up the changes until they are merged.

“New Code” filter applied (for the last 30 days) - shows no issues:

“New Code” filter removed - issues visible in the last 18 days (there are examples with a couple of hours as well):

The “New Code” filter should show the issues in the last 30 days and fail the checks, but it doesn’t.

Hi,

Welcome to the community!

What’s your SonarQube version? (You can find it in the page footer if you’re not sure.)

Also, what’s your branch’s New Code Period set to?

 
Ann

Hi Ann,

Thank you, glad to be here!

The SonarQube version is: SonarQube Enterprise 9.6.1.59531
The New Code Period is set to 30 days.

Thanks,
Smilyan

Hi Smilyan,

Thanks for those details.

Could you share some more details of your feature branch? I gues it’s based on the main branch? Was there any re-basing before merge?

 
Ann

Hi Ann,

Sorry for the late reply, I didn’t see your comment.

The branch was a fresh copy of master, no re-basing. Changes put on the branch then were ran through Sonar and it passed the quality gates. If I log in to Sonar I can see the issues with the branch but when the “New code” filter is applied there are no issues. Merging the branch back into master then and re-running Sonar on the master branch shows failures with the “New code” filter applied.

This happens on multiple occasions on different repositories.

Hi,

Could you confirm the New Code setting on the originating branch, please?

It’s 30 days on the branch as well as on main?

 
Ann

Hi Ann,

Yes, that is correct. The only point is that the name for us is not main but master

Hi Smilyan,

Thanks. And could you provide the analysis log of a branch where issues weren’t detected in the New Code period?

 
Ann