Hi there,
I’m having issues with pull request support in sonarqube server.
Consider the following scenario
- I have branch
base
with a fileA.java
with the following contents
class A {
public static void main(String[] args) {
String a = "a";
}
}
And commit these changes.
2. I perform a sonar branch analysis of base which leads to the sonarqube server showing the contents of this file.
3. I create a new branch feature
from base
and modify the contents of A.java
class A {
public static void main(String[] args) {
String a = "a";
String b = "b";
}
}
And commit these changes
4. I go back to base
and modify the contents of A.java
to
class A {
public static void main(String[] args) {
String a = "a";
}
public void newFunc() {
String q = "a";
}
}
And commit these changes.
I do not run branch analysis of the code at this point.
- I switch to
feature
branch and merge withbase
so thatA.java
is now
class A {
public static void main(String[] args) {
String a = "a";
String b = "b";
}
public void newFunc() {
String q = "a";
}
}
6.I now run pull request analysis for feature
specifying the pull request parameters -Dsonar.pullrequest.key=1000 -Dsonar.pullrequest.branch=feature -Dsonar.pullrequest.base=base
In the pull request analysis , I see that both String b = "b";
and newFunc()
are considered as new code for this branch , However my expectation is that only String b = "b";
shoudl be considered as new code.
On adding verbose logs, I noticed some of these logs
SCM Step is disabled by configuration
SCM information about changed files in the branch is not available
SCM Publisher is disabled
Checking the source on github for this, I noticed that this error comes up if the ScmProvider is null which happens due SCM being disabled here.
I was wondering what could cause this?
Based on the thread at Pull request diffs show unrelated lines on older PRs. Diff not against merge base? , my expectation is that the sonar scanner would be able to identify the diff in this pull request config and only show the changes on this branch as new code.
PS: This problem does not occur if I run branch analysis at step 4 which is expected.
Also adding my version details:
Sonar Server: Enterprise 9.9.0.65466
Sonar-gradle-plugin: 5.1.0.4882