Version of SonarQube: 8.6.1, Enterprise Edition
When a feature branch is build in CI ( Jenkins) the Quality Gates is green. But after merging this branch to the main line, the QG on the main line fails. This happens only for certain types of changes: e.g. when JUnit test code is upgraded from v4 to v5 other Rules are triggered, e.g. a Test class is no longer allowed to be “public”. If this code is not touched and the class remains public, the QG will not fail on the feature branch. The New Code definition on the feature branch is set to ‘develop’ (this is our long lived branch that feature branches are merged to). The New Code definition of the ‘develop’ branch is set to ‘Previous version’.
But the JUnit 5 rule (java:S5786) does get triggered when the feature is merged to ‘develop’ and fails the Quality Gate.
I would expect that this violation would already occur on the feature branch.
Note that the HEAD of ‘develop’ is merged to the feature branch before running the SonarQube analysis on the feature branch. As it should.
I think the problem is caused by a difference in New Code definition between the feature branch (with Reference branch set to ‘develop’) and the ‘develop’ branch. It seems like on the ‘develop’ scan all issues are found, but on the feature branch scan only issues on New Code are found and not on existing code that has new issues do to JUnit 5 upgrade (which is only a change in a Maven POM file).
Any help would be appreciated.