Sonar Component view and cobertura code coverage report view differ - code-coverage

When I look at my Sonar Components view I see a lot of classes with code coverage. However, when I click the unit test code coverage percentile to retrieve the view of packages from which the percentile is derived from, I only get a subset of the covered packages/classes that are listed in the Components view. So Components view contains all classes in code coverage view, but code coverage view is a subset of the code covered classes in the Components view.
Any ideas what would make this like this?

You don't see all the classes on the code coverage drilldown page because classes which have 100% code coverage are hidden (as there's nothing to do about them). On the other side, the component page shows all the components, whatever their measures on specific metrics are.
This is a general behaviour in Sonar. You can find all the classes though the components page, because this service is made to navigate through your code. But in the drilldown pages (measures or violations based), you will only see classes which have "issues" because this service is made to hunt quality flaws.
in violation drilldown, you won't see classes which don't have any violation
in measure drilldown, you won't see classes which have the "best value" for the selected metric (=> 100% for code coverage for instance)

Related

File coverage tab is always loading and never shows coverage files when using OpenCover plugin in Jenkins

Background
I'm using OpenCover 4.7.1221 to run vstest.console.exe in a Jenkins pipeline via bat script in a steps block to generate a coverage.xml file. Then, I'm running the Code Coverage API plugin with the OpenCover plugin adapter (```publishCoverage adapters: [opencoverAdapter```) to generate the code coverage from the coverage.xml file. My setup is very similar to the setup used in the following [this blog post][1].
When the job is complete, a Coverage Report link displays on the menu. When I click the Coverage Report link, there is a Coverage Overview chart and a Coverage Trend chart. Below the two charts, there's a Coverage Details section that has two tabs. The default selected tab is File Coverage and the other tab is Package Overview.
If I click Package Overview, a code coverage heat map displays with the heading, "OpenCover coverage: coverage.xml". However, when I click the File Coverage tab, it displays a DataTables.net table that just says, "Loading - please wait ...". This table never changes and never shows any files or source code as I'm guessing it's supposed to.
I have searched for answers and found nothing. I searched images and found nothing. Most articles, forum posts, or blogs use ReportGenerator.exe to create an HTML report and import that into Jenkins, and I have done that successfully, but I'm curious why nothing ever loads on the File Coverage tab.
Question
Does this not work and is that why I'm only seeing the ReportGenerator.exe output in my searches? I'm primarily interested in whether or not this ever works so I can decide whether to continue spending time on it. If it does work and someone has a working example, that would be great, too.
Thanks!
The same issue occurs with llvm-cov, so it appears that the plugin is currently broken. With an older version of the plugin, the data was all visible.

Exclude Packages, Files, and Classes from Cobertura Jenkins report?

I'm trying to get Cobertura code coverage reports integrated into Jenkins for my company's AngularJS project. It's working, however, packages files and classes with es5 AngularJS project are always 100%. What I'm more focused on obviously, are the methods lines and conditionals.
Since the first 3 metrics are always 100% the graph leaves little to be desired as I can't zoom in close enough to notice slight changes in the metrics.
Is there a way to exclude Packages, Files, and Classes from the report?

Overall (integration + unit tests) coverage on single file code view

I'm getting integration and unit tests coverage with sonarqube (v4.4). But the most important information is which parts of the code aren't covered by any of tests at all. I can easily get this information for whole projects on widgets, but on file view there is no option for overall coverage. Is this possible at all?
I'm attaching a screen that possibly will explain my intentions better.
This has been added in 4.5, see https://jira.codehaus.org/browse/SONAR-5474

Need to get only Unit Test Coverage results using SONAR

Is there any way I could JUST get the unit test code coverage results on SONAR. My project is to just focus on the code coverage and not on code issues/violations/rules etc.
It would be a big time saver for me. As the project that I am dealing with has million lines of code. I have all my jacoco.exec files generated and appended. Sonar analyses in and out of our code and which takes hours. code standards,rules,violations,issues for which my project is not concerned off.
Any help on this would be highly appreciative.
Regards
Eajaz
This is really an edge case for the use of SonarQube.
If you use an empty quality profile for analysis, you should not get any issue on your code, only metrics - including coverage, which seems your main concern.

Aggregate jmockit-coverage output with emma coverage output

Is there a way to aggregate code coverage data from jmockit-coverage and emma coverage? I can run the two different coverage steps in two separate junit ant tasks and generate the coverage data in two directories. Just not sure if the coverage outputs from these two are compatible and can be merged to display together.
No, they can't be aggregated into a single HTML report, since these are two different code coverage tools, which know nothing about each other. Of course, someone could create yet another tool which would do that; personally, I don't see much value in it, though.

Resources