Skip to content

Commit 5144432

Browse files
authored
Update README.md
1 parent f3974d6 commit 5144432

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,18 @@ Because some languages don't have loops and instead use recursion they can have
363363

364364
Generally though the complexity there is to help estimate between projects written in the same language, or for finding the most complex file in a project `scc --by-file -s complexity` which can be useful when you are estimating on how hard something is to maintain, or when looking for those files that should probably be refactored.
365365

366+
As for how it works.
367+
368+
It's my own definition, but tries to be an approximation of cyclomatic complexity https://en.wikipedia.org/wiki/Cyclomatic_complexity although done only on a file level.
369+
370+
The reason it's an approximation is that it's calculated almost for free from a CPU point of view (since its a cheap lookup when counting), whereas a real cyclomatic complexity count would need to parse the code. It gives a reasonable guess in practice though even if it fails to identify recursive methods. The goal was never for it to be exact sorry.
371+
372+
In short when scc is looking through what it has identified as code if it notices what are usually branch conditions it will increment a counter.
373+
374+
The conditions it looks for are compiled into the code and you can get an idea for them by looking at the JSON inside the repository. See https://github.com/boyter/scc/blob/master/languages.json#L3524 for an example of what it's looking at for a file that's Java.
375+
376+
The increment happens for each of the matching conditions and produces the number you see.
377+
366378
### COCOMO
367379

368380
The COCOMO statistics displayed at the bottom of any command line run can be configured as needed.

0 commit comments

Comments
 (0)