sonarqube-community-branch-plugin
sonarqube-community-branch-plugin copied to clipboard
Unexpected behaviour of NewCode identification with use of reference branch
Describe the bug We are trying out branch analysis We have set Project level setting to use master as reference branch
What we want to achieve:
- Treat master branch as the reference. Update master branch on Sonar by pushing every time there is a merge on master in Git. All the code in a branch , compared to master, should be treated as new code.
- Devs will be creating branches from master, and raising PRs for merging. Before merging, we check with Sonar if its passing quality gates and block the merge if it does not. We have checks on code coverage of New Code.
To Reproduce Steps to reproduce the behavior:
Assume we are Git branch - master Analyse and Push as (sonar.branch.name) master to Sonar
Create branch b1 Modify existing file A Make changes Add Line1 - (line number l1 ) Add Line2 - (line number l2 ) Add Line3 - (line number l3 ) Commit. Analyse and Push as (sonar.branch.name) 'b1' to Sonar (Sonar server shows correctly, 3 lines as new code)
Create branch b2 from b1 Modify existing file A Add Line4 - l4 (line number l4) Commit. Analyse and Push as (sonar.branch.name) 'b2' to Sonar (Sonar server shows correctly, 4 lines as new code)
Merge b1 into master Analyse and Push as 'master' to Sonar
Checkout branch b2 Modify existing file A Modify Line4 - l4 (line number l4) Commit. Analyse and Push as (sonar.branch.name) 'b2' to Sonar (Sonar server incorrectly shows correctly, 4 lines as new code. Expected behaviour is only Line l4 to be shown as New Code as l1,l2,l3 is already merged to master and analysed )
Expected behavior In step 5, Expected behaviour is only one Line l4 to be shown as New Code as l1,l2,l3 is already merged to master and analysed
Screenshots Can share if required
Software Versions
- SonarQube Version: Version 9.5 (build 56709)
- Plugin Version: 1.12.0
- Installed locally using Docker - mc1arke/sonarqube-with-community-branch-plugin:9.5-community
Additional context Any changes being made to the reference branch, 'master' in our case, was not being considered for NewCode identification