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

percentage calculations excluding sum row #12

Open
bhogan-mitre opened this issue Mar 8, 2022 · 0 comments
Open

percentage calculations excluding sum row #12

bhogan-mitre opened this issue Mar 8, 2022 · 0 comments

Comments

@bhogan-mitre
Copy link

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.

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

No branches or pull requests

1 participant