linux-test-project / lcov

LCOV
GNU General Public License v2.0
867 stars 235 forks source link

Feature request - List only non 100% covered files #231

Closed hrishikesh-kadam closed 11 months ago

hrishikesh-kadam commented 11 months ago
Present: ```console lcov --list coverage/lcov.info Reading tracefile coverage/lcov.info |Lines |Functions|Branches Filename |Rate Num|Rate Num|Rate Num ================================================================================ [lib/] config/app_back_button_dispatcher.dart | 100% 25| - 0| - 0 config/app_bloc_observer.dart | 100% 6| - 0| - 0 config/config.dart | 100% 5| - 0| - 0 config/config_non_web.dart | 100% 21| - 0| - 0 constants/theme.dart | 100% 2| - 0| - 0 deferred_loading/defer...ading_placeholder.dart| 100% 10| - 0| - 0 globals.dart | 100% 6| - 0| - 0 helper/helper.dart | 100% 34| - 0| - 0 nasa/cad/bloc/cad_bloc.dart |94.8% 58| - 0| - 0 nasa/cad/bloc/cad_event.dart | 100% 8| - 0| - 0 nasa/cad/bloc/cad_state.dart | 100% 12| - 0| - 0 nasa/cad/cad_route.dart | 100% 6| - 0| - 0 nasa/cad/cad_screen.dart | 100% 198| - 0| - 0 nasa/cad_result/cad_result_route.dart | 100% 15| - 0| - 0 nasa/cad_result/cad_result_screen.dart | 100% 5| - 0| - 0 nasa/route/nasa_route.dart | 100% 4| - 0| - 0 nasa/route/nasa_screen.dart | 100% 7| - 0| - 0 nasa/widgets/choice_chip_input_widget.dart | 100% 85| - 0| - 0 route/home/home_route.dart | 100% 2| - 0| - 0 route/home/home_screen.dart | 100% 7| - 0| - 0 route/settings/bloc/settings_bloc.dart | 100% 24| - 0| - 0 route/settings/bloc/settings_event.dart | 100% 5| - 0| - 0 route/settings/bloc/settings_state.dart | 100% 2| - 0| - 0 route/settings/settings_route.dart | 100% 5| - 0| - 0 route/settings/settings_screen.dart | 100% 73| - 0| - 0 space_data_explorer.dart | 100% 42| - 0| - 0 widgets/app_bar.dart | 100% 22| - 0| - 0 widgets/choice_chip_query_widget.dart | 100% 28| - 0| - 0 widgets/date_filter_widget.dart | 100% 76| - 0| - 0 widgets/filter_chip_query_widget.dart | 100% 30| - 0| - 0 widgets/query_grid_container.dart | 100% 6| - 0| - 0 widgets/radio_dialog.dart | 100% 14| - 0| - 0 widgets/radio_settings_tile.dart | 100% 17| - 0| - 0 widgets/value_range_filter_widget.dart |95.1% 144| - 0| - 0 ================================================================================ Total:|99.0% 1004| - 0| - 0 ```
Expected: ```console lcov --list --some-flag coverage/lcov.info Reading tracefile coverage/lcov.info |Lines |Functions|Branches Filename |Rate Num|Rate Num|Rate Num ================================================================================ [lib/] nasa/cad/bloc/cad_bloc.dart |94.8% 58| - 0| - 0 widgets/value_range_filter_widget.dart |95.1% 144| - 0| - 0 ================================================================================ Total:|99.0% 1004| - 0| - 0 ```

If this can be achieved without feature implementation, please educate me.

My sincere thanks to all the contributors of this helpful tool.

henry2cox commented 11 months ago

lcov --list coverage/lcovinfo | grep -v "| 100% " (you might need a bit more regexp to match only the first '|' - so you don't accidentally filter out files with 100% function coverage or 100% branch coverage...or you might want a bit of sophistication so you don't filter out unless all the metrics are complete).

Or did I miss something? Note that the counts shown in the summary at the bottom still reflect all the files - not just the ones that were not filtered out.

Another way to achieve this is via the genhtml --criteria-script option (see the man page). I suspect that this is closer to what you really want, as it appears that you are trying to define a coverage criteria and/or to generate a report for the project lead.

hrishikesh-kadam commented 11 months ago

(you might need a bit more regexp to match only the first '|' - so you don't accidentally filter out files with 100% function coverage or 100% branch coverage...or you might want a bit of sophistication so you don't filter out unless all the metrics are complete).

Or did I miss something? Note that the counts shown in the summary at the bottom still reflect all the files - not just the ones that were not filtered out.

I think the following grep would work for me to focus on non 100% lines covered files:

lcov --list coverage/lcov.info | grep -v ".*|.*100%.*|.*|"

Another way to achieve this is via the genhtml --criteria-script option (see the man page). I suspect that this is closer to what you really want, as it appears that you are trying to define a coverage criteria and/or to generate a report for the project lead.

I was just trying to list the non 100% lines covered files on the console, so not exploring genhtml option.

I would suggest keeping this issue open if you might be working on the feature request. Or if not then we can close this. Thanks, for the prompt reply.

henry2cox commented 11 months ago

No plan to implement this particular enhancement. It is too limited/too specific to one particular (very rigid) use model.

We prefer flexibility that scales better to large projects. Some code is more important and has a higher target, some is less important - and so forth. Thus: we end up with a callback scheme :-)

I had considered adding a criteria-script callback to lcov - to support the obvious use models - but had not done so because that is still too limited; we typically need annotations and/or differential categorization...and you can see where this is going.

If we are happy with the resolution above: please go ahead and close. Thanks Henry