which versions are you using: SonarQube Enterprise 10.5.1
how is SonarQube deployed: zip
what are you trying to achieve: Pull Request comment from SonarQube on the wrong linenumber in Azure DevOps Pullrequest (C++/C code), but not in SonarQube where the comment is on the correct line
what have you tried so far to achieve this: Configured the SonarQube Project to comment on Azure DevOps Pullrequests. we have also tried re-executing the SonarQube analysis, but are unsure if this is a coverage.xml problem or other problem. Do note that there is a lot of changes in this PR and also lots and lots of comments. From experience this might be an Azure DevOps problem - I personally think its an cosmetical problem, but I understand that our developers find it annoying. Any tips here are welcome.
Azure DevOps PR - there is a marking of line 216:
SonarQube Project - there is a marking of line 216
SonarQube Project - there is a warning, not sure its correct, but may be the reason if the coverage.xml is the problem. we are not sure
Allright, I think our guys have figured out why this issue arises.
The problem arises because: SonarQube makes the analysis on the merge-commit that Azure DevOps creates, but Azure DevOps doesn’t show the changes from that in the pull-request.
SonarQube GUI shows the code as it looks in the merge-commit. Thats why the comment looks ok in SonarQube.
So, the conclusion is; if there are changes on the main-branch, on top of the pull-request, then SonarQube will miscalculate the line numbers sligtly (in the PR), depending on the amount of added or removed lines of code.
(Hopefully I’ve translated this correctly - I hope that make sense. )
Is this something that could be fixed in a future version or is it by design?
Thanks for looking deeper into it @jensmadsen! If that’s the case, it sure seems we need to look into it a bit closer… I’ve flagged this for attention.