How to configure SonarQube to detect new code compared with development

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube : Enterprise EditionVersion 7.9.1 (build 27448)
  • what are you trying to achieve
    For Android project, we are trying to detect new code compared to the Development branch, based on that we are planning to apply quality gates such as code coverage on new and etc

we are using following Sonar configuration on Android

sonarqube {
properties {
if (project.hasProperty(“branch”) && project.branch != “development”) {
property “sonar.branch.name”, branch
property “sonar.branch.target”, “development”
}

        property "sonar.projectName", *************
        property "sonar.projectVersion", branch
        property "sonar.dynamicAnalysis", "reuseReports"
        property "sonar.java.coveragePlugin", "jacoco"
        property "sonar.host.url", "**********"
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.scm.disabled", "False"
        property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"

        properties["sonar.sources"] = android.sourceSets.main.java.srcDirs
        properties["sonar.tests"] = android.sourceSets.androidTest.java.srcDirs

        properties["sonar.java.binaries"] = files("${buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes/")
        properties["sonar.java.binaries"] += files("${buildDir}/tmp/kotlin-classes/debug/")
        properties['sonar.java.test.binaries'] = files("${buildDir}/intermediates/javac/debugAndroidTest/compileDebugAndroidTestJavaWithJavac/classes/")
    }
}
  • what have you tried so far to achieve this

In Sonar portal we tried 5 days, 15 days and previous_version for New Code Period.
When we tried previous_version for the first commit we are not getting New Code Difference. Then after New code is detected as the difference between the code used for the first commit we did and on the new commit code.

Hi,

Welcome to the community!

8.4 introduced the ability to use a reference branch for your New Code Period. Looks like you’ll need to upgrade. Note that 8.5 is due next week.

 
HTH,
Ann

Hey Ann,
Thanks for your response, my request is almost similar to

Looks like it is available in 7.9.1, can you please check once.

Thanks,
K.Raghavendra Kumar.