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

Untested files are ignored for code coverage #56

Open
kernle32dll opened this issue Jan 19, 2018 · 5 comments
Open

Untested files are ignored for code coverage #56

kernle32dll opened this issue Jan 19, 2018 · 5 comments

Comments

@kernle32dll
Copy link
Contributor

Description

I noticed that files which are not tested at all do not decrease the code coverage. E.g. a project with two files, with one being 100% tested and the other not at all, code coverage in total will still be 100%.

Steps to Reproduce

  1. Create a project with two files to test (e.g. main.go and test.go)
  2. Write code and tests for test.go
  3. Coverage will only depend on test.go, not on main.go

Additional Information

If coverage for untested files should be ignored or set to 0 is a choice of preference. Thus, it should be settable via sonar-project.properties.

@danielleberre
Copy link
Contributor

We provide the per file coverage to SonarQube. The total coverage is then computed automatically by SonarQube.

Since we provide metrics only for the files found in the coverage xml file, the other classes have no coverage information, thus are "ignored" in the coverage computation.

We can add a new property to force to 0% untested files, just like JaCoCo plugin.

@thibaultfalque If we want to implement this, we probably need a new type of files (test files) in our plugin.

@thibaultfalque
Copy link
Collaborator

I asked for correctly detect source code file and test file.
https://groups.google.com/forum/#!topic/sonarqube/4CkPFEKYRpc

@thibaultfalque
Copy link
Collaborator

@kernle32dll can you test the new release.

@kernle32dll
Copy link
Contributor Author

@thibaultfalque works like a charm. Might be worth to include the parameters as stated in https://github.com/uartois/sonar-golang/releases/tag/v1.2.11-rc10 as sensible defaults.

@thibaultfalque
Copy link
Collaborator

thibaultfalque commented Feb 10, 2018

I searched a solution for add default value but it's not directly possible because properties are sonar properties and not plugin properties, so I can't set a default value. You can change the default value of these properties from the web interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants