A tool to crudely calculate code complexity per file.
I'm calculating complexity assuming code features which result in code branches increase complexity by one point.
Features:
- if statements
- ternary conditions
- logical OR
- logical AND
- nullish coalescing
- switch cases
- optional chaining
-extensionsRegex "\\.jsx$"
- A regex which can be used to change what files you're including.
- Defaults to
"\\.(js|jsx|ts|jsx)$"
-directory ~/Code/Project/src
- Which directory to run the search on
- Defaults to
"./"
-exclusionsRegex __tests__
- Match on any files you don't want included
- Defaults to
"(__snapshots__|__tests__|test\\.(js|ts|jsx|tsx))"
-outputType json
- Specify
json
orcsv
as an output type - Defaults to
"csv"
[
{
"filepath": "TestFile.js",
"lineCount": 50,
"codeLines": 48,
"complexity": 7
}
]
file path,line count,code lines,complexity
TestFile.js,50,48,7