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

Wrong language Complexity/Lines calculation when using -wide #412

Open
RobertZickler opened this issue Oct 13, 2023 · 1 comment
Open

Wrong language Complexity/Lines calculation when using -wide #412

RobertZickler opened this issue Oct 13, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@RobertZickler
Copy link

RobertZickler commented Oct 13, 2023

Describe the bug

When the output is generated with -wide the Complexity/Lines is calculated. This is okay for one or multiple files. But then the Complexity/Lines is accumulated to sum up to the language Complexity/Lines. But this is not correct.

Example:

─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Language                              Files     Lines   Blanks  Comments     Code Complexity Complexity/Lines
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
C Header                                  3       526       67        71      338         27            44.70
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
~\the\path\to\project\files\header_file_1.h       397       42        43      312         13             4.17
~\the\path\to\project\files\header_file_2.h       107       21        23       63         11            17.46
~\the\path\to\project\files\header_file_3.h        22        4         5       13          3            23.08

The language result seems to be calculated like this:

$$ 4.17\,{Complexity \over Lines} + 17.46 \,{Complexity \over Lines} + 23.08\,{Complexity \over Lines} = 44.70\,{Complexity \over Lines} $$

The problem even extends to the total calculation:

─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Language                              Files     Lines   Blanks  Comments     Code Complexity Complexity/Lines
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
C Header                                  3       526       67        71      338         27            44.70
C                                         3     15081     1824      2779    10478       2567           383.42
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Total                                     6     15607     1891      2850    10816       2594           428.12

To Reproduce

scc.exe --no-cocomo --no-size --sort complexity --wide header_file_1.h header_file_2.h header_file_3.h

The error is also produced when run without --by-file

Expected behavior

The Complexity/Lines should not be added from each file to produce the language-Complexity/Lines. Instead, it should be calculated on the summed up language Complexity and Lines. In the above example, the correct Complexity/Lines for C Header would be:

$$ {27 \,Complexity \over 338 \,(Code)Lines} = 7.99 \,{Complexity \over Lines} $$

And for the total result:

$$ {2594 \,Complexity \over 10816 \,Lines} = 23.98 \,{Complexity \over Lines} $$

Alternatively: if the described output is by design, the headline Complexity/Lines is wrong for the language and total results. But I could not find any description on the reason why the sum of the file Complexity/Lines is equivalent to the language or total Complexity/Lines.

One more thing: It would be nice to have the option to sort the files by Complexity/Lines. Current options are:

-s, --sort string     column to sort by [files, name, lines, blanks, code, comments, complexity] (default "files")

Desktop:

  • OS: Windows 10 LTSB 1607
  • Version: scc version 3.1.0
@boyter boyter added the bug Something isn't working label Oct 18, 2023
@boyter boyter moved this to TODO in Scc Release 3.5.0 Jun 11, 2024
@boyter
Copy link
Owner

boyter commented Oct 2, 2024

#370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: DOING
Development

No branches or pull requests

2 participants