Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kover exclude rules in Sonarqube scan #156

Closed
johnryM opened this issue Mar 24, 2022 · 6 comments
Closed

Kover exclude rules in Sonarqube scan #156

johnryM opened this issue Mar 24, 2022 · 6 comments
Labels
Question Support request issue type

Comments

@johnryM
Copy link

johnryM commented Mar 24, 2022

I'm using Kover in my Android Project to generate the xml report that's sent to my Sonarqube server.

I would like to exclude all Kotlin classes that are inside a "di" folder but my Kover exclude rules don't seem to work.

My package structure is

Screenshot 2022-03-24 at 18 38 54

My merged report gradle config is

// in root build.gradle

tasks.koverMergedXmlReport {
    enabled = true
    xmlReportFile.set(layout.buildDirectory.file("kover/xml/result.xml"))
    excludes = [
        "*.*Module.*",
        "*.di.*Module*",
        "*.di.*"
    ]
}

sonarqube {
    properties {
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.coverage.jacoco.xmlReportPaths", "$buildDir/kcover/xml/result.xml"


    }
}

project.tasks["sonarqube"].dependsOn "koverMergedXmlReport"

When I run my sonarqube scan. The module files in the various DI folders are visible in the coverage report

Screenshot 2022-03-24 at 18 49 46

Defining "sonar.exclusions property" in my build gradle file does solve this issue

   property("sonar.exclusions","**/di/*")

Is this the correct way of excluding files in the final sonarqube report or is possible to perform the same exclusions by just configuring the Kover merged reports?

@shanshin shanshin added the Question Support request issue type label Mar 29, 2022
@shanshin
Copy link
Collaborator

Hi,
at the moment, full integration with Sonarqube is not implemented, so for the correct display of reports, you need to configure it yourself.

@johnryM
Copy link
Author

johnryM commented Mar 30, 2022

Thanks @shanshin for clarifying. Will there be plans to support full integration with analysis tools like Sonarqube?

@shanshin
Copy link
Collaborator

There are no short-term plans for integration with Sonarqube, but it will be added as soon as the plugin and the IntelliJ Coverage Engine are implemented to a stable state.

@sarn0ld
Copy link

sarn0ld commented Sep 8, 2022

@johnryM with the property you mentioned above you will afaik exclude the files from sonar completely (coverage + static analysis). To just exclude them from coverage you need to use this property:

property "sonar.coverage.exclusions", "**/di/*"

Edit: We need to do the same when using Jacoco reports, so I guess it's just the intended sonarqube behavior that you need to define the exclusions twice.

@johnryM
Copy link
Author

johnryM commented Sep 8, 2022

@sarn0ld In the end we went with your solution. I didn't know it was the same process with Jacoco as well. Thanks for letting me know!

@shanshin
Copy link
Collaborator

Duplicates #268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Support request issue type
Projects
None yet
Development

No branches or pull requests

3 participants