cloc
cloc copied to clipboard
percentage calculations excluding sum row
I found this package to be very helpful for a quick look at code complexity. Thank you!
One thing that struck me as counter-intuitive, however, is that the sum row is always listed as 50% in the percentage columns. This makes it hard to interpret the actual percentages. For example the blank lines from C++ files should be 63% here instead of 31.5%.
> cloc(system.file("extdata", package="cloc"))
# A tibble: 3 × 10
source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct
<chr> <chr> <int> <dbl> <int> <dbl> <int> <dbl> <int> <dbl>
1 extdata C++ 1 0.25 142 0.254 41 0.315 63 0.235
2 extdata R 1 0.25 138 0.246 24 0.185 71 0.265
3 extdata SUM 2 0.5 280 0.5 65 0.5 134 0.5
What do you think about excluding the sum row from the denominator of these calculations? https://github.com/hrbrmstr/cloc/blob/master/R/cloc.R#L102-L105
The sum row of percentage columns could then be corrected to 100% after, or set as NA.