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
Sort files on actual uncovered percentage #918
Conversation
This fixes: * Files with covered = 0 and total = 1 and 100% get equal sorting value (1), thus alphabetically interleaving files with 0% and 100% coverage. * Files with covered = 0 and total > 1 end up after files with 100% coverage (or before, if reverse sorting is enabled), but before files that have 100% coverage because total = 0. In terms of coloring, this change leads to color-consistent sorting (red-yellow-green, or green-yellow-red for reverse), but not the current interleaving of colors and coverage percentages.
The intention of the logic was to have the uncovered branches sorted by the total number of branches instead of alphabetical order. So it's more a change than a fix. To you have a screenshot before/after your modification? |
Taking a look at the test results and thinking about it I don't get the reason for having the special case for uncovered. @latk can you recall this?
|
Not sure either :) It seems that in 0418545 the sign of a sorting key got flipped, unclear to me whether that was an accident or intentional. I think at some point the intention of that code was to ensure that 0/1 branches and 0/123 branches are not both sorted as "0%", but effectively as -1% and -123% – more uncovered is worse. However, 0/0 branches should look more like 100%. Under no circumstances should there be NaNs or ZeroDivisionErrors. I suspect that this inconsistency wasn't discovered previously because gcovr depends almost exclusively on end-to-end tests, which are high-fidelity but make it difficult to spot relevant changes in behaviour. Perhaps this PR could add unit tests to demonstrate the expected sort orders under different sort modes. |
I think the
was changed to:
After thinking about it more closely, the specific case of covered doesn't make any sense to me. The same for the usage of the total number of branches if uncovered. |
@hoxell Can you update the reference data by running the docker containers local? I'll update the description for the sort options since the still reference the deprecated options and push this to your branch.. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #918 +/- ##
==========================================
+ Coverage 94.66% 94.70% +0.04%
==========================================
Files 50 50
Lines 3916 3911 -5
Branches 826 824 -2
==========================================
- Hits 3707 3704 -3
+ Misses 130 129 -1
+ Partials 79 78 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGFM. Thanks for fixing this.
@@ -23,7 +23,7 @@ <h1>GCC Code Coverage Report</h1> | |||
</tr> | |||
<tr> | |||
<th scope="row">Date:</th> | |||
<td>0000-00-00 00:00:00</td> | |||
<td>00-00-00 00:00:00</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this change expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also saw this when creating the single file report and fixed the error in the scrubber there. See tests/test_gcovr.py
in https://github.com/gcovr/gcovr/pull/916/files#diff-14fc10b334e44e45733e71ed3f0d748422b8f8dedc6078c92f2ebca731072ccc.
This fixes:
Files with covered = 0 and total = 1 and 100% get equal sorting value (1), thus alphabetically interleaving files with 0% and 100% coverage.
Files with covered = 0 and total > 1 end up after files with 100% coverage (or before, if reverse sorting is enabled), but before files that have 100% coverage because total = 0.
In terms of coloring, this change leads to color-consistent sorting (red-yellow-green, or green-yellow-red for reverse), but not the current interleaving of colors and coverage percentages.