SonarQube analysis only on changed method or changed lines
Current Process:
Analyzed complete code in master branch and make it as reference for feature branches
SonarQube analysis done on changed lines in new code (based on reference branch)
Issue: Quality Gate failed due to analysis report on unchanged methods or unchanged lines.
Example:
Test.cs file contains 5 methods containing some common data
Developer changed in Method1-line1
In first analysis sonar shows code smell in Method1-line1
Developer fixes code smell in Method1-line1
In second analysis report shows code smell or bugs in other Methods (which are unchanged)
please help me to configure the server based on requirements.
Thanks in advance.
StingyJack
(Andrew Stanton)
July 26, 2022, 12:12pm
2
Do you run the sonar scan on the changes in a feature branch before the merge into the main branch or run the scan on the main branch after they are merged?
Usually people do the former while it’s PR, but the message posted says the latter.
Thank you for your response
we are running analysis on feature branch code before merging.
PR will be merged to main branch after build success
StingyJack
(Andrew Stanton)
July 26, 2022, 4:39pm
4
Is the second analysis that you are looking at for the same PR/branch or is it from the main/master branch?
for step 4 did the developer push another commit to the same remote branch and trigger a re-run of the pipeline for that branch?
How have you defined “new code” ?
Is the second analysis that you are looking at for the same PR/branch or is it from the main/master branch?
Ans: Yes, It is Same PR/Branch
for step 4 did the developer push another commit to the same remote branch and trigger a re-run of the pipeline for that branch?
Ans: Yes
How have you defined “new code” ?
New Code is defined with reference branch.
Analyzed complete code in master branch and make it as reference for feature branches
![image|690x238](upload://i1LfRMR4uShDS0Dlp5SI92cUSGJ.png)