code-complexity
code-complexity copied to clipboard
Add a way to compute complexity based on something else than sloc
What problem are you trying to solve?
We're currently measuring complexity based on sloc. It's nice but a long file doesn't always mean it's complex.
Describe the feature
We could add a --complexity-strategy=<sloc or cyclomatic or xyz> that would be used in the complexity processing.
The algorithm just counts lines of code and returns that as complexity then? Would be good to have that in the readme. Looks like it comes from here:
const result = await nodeSloc({ path: absolutePath });
Can open a PR for the README adjustment if you will confirm.
Added PR to cover the above: https://github.com/simonrenoult/code-complexity/pull/24
Seems fair. I changed the wording a bit and merged it, thanks :+1:
Candidates:
- https://www.npmjs.com/package/escomplex
- https://eslint.org/docs/rules/complexity and its source https://github.com/eslint/eslint/blob/master/lib/rules/complexity.js
Added PR to cover the requested functionality: #28
The PR covers adding the following complexity strategies:
- SLOC
- Cyclomatic
- Halstead
Code adapted from: https://github.com/anandundavia/ts-complex
Done in 4.3 :)