Skip to content

Measure the churn/complexity ratio. Higher values mean hotspots where refactorings should happen.

License

Notifications You must be signed in to change notification settings

davemcg3/code-complexity

 
 

Repository files navigation

code-complexity

Measure the churn/complexity score. Higher values mean hotspots where refactorings should happen.

Build Status Coverage Status Style Status NPM Version

Quoting Michael Feathers (source here):

Often when we refactor, we look at local areas of code. If we take a wider view, using information from our version control systems, we can get a better sense of the effects of our refactoring efforts.

Note: the current complexity implementation is based on source lines of code (using the node-sloc package). Better means are open to discussion in the repo Issues.

Usage

$ npx code-complexity <path-to-git-directory>

Help

 Usage: code-complexity <dir> [options] Measure the churn/complexity score. Higher values mean hotspots where refactorings should happen. Options: -V, --version output the version number --filter <strings> list of globs (comma separated) to filter -f, --format [format] format results using table or json -l, --limit [limit] limit the number of files to output -i, --since [since] limit the age of the commit analyzed -s, --sort [sort] sort results (allowed valued: score, churn, complexity or file) -h, --help display help for command Examples: $ code-complexity <dir> $ code-complexity <dir> --limit 3 $ code-complexity <dir> --sort score $ code-complexity <dir> --filter 'src/**,!src/front/**' $ code-complexity <dir> --limit 10 --sort score 

Output

$ npx code-complexity . --sort=score --limit=3 ┌──────────────────────────────┬────────────┬───────┬───────┐ │ file │ complexity │ churn │ score │ ├──────────────────────────────┼────────────┼───────┼───────┤ │ src/cli.ts │ 103 │ 8 │ 824 │ ├──────────────────────────────┼────────────┼───────┼───────┤ │ test/code-complexity.test.ts │ 107 │ 7 │ 749 │ ├──────────────────────────────┼────────────┼───────┼───────┤ │ .idea/workspace.xml │ 123 │ 6 │ 738 │ └──────────────────────────────┴────────────┴───────┴───────┘

Troubleshooting

  • Error: stdout maxBuffer exceeded: use the flag --since to limit the number of commits to analyze.

About

Measure the churn/complexity ratio. Higher values mean hotspots where refactorings should happen.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 96.6%
  • JavaScript 3.4%