GithubHelp home page GithubHelp logo

billymaulana / code-complexity Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simonrenoult/code-complexity

1.0 1.0 0.0 1.16 MB

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

License: MIT License

JavaScript 0.45% TypeScript 99.55%

code-complexity's Introduction

code-complexity

Measure the churn/complexity score. Higher scores reveal 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: code-complexity currently measures complexity using either:

  • lines of code count (all languages)
  • cyclomatic complexity (JavaScript/TypeScript)
  • halstead complexity (JavaScript/TypeScript)

Usage

$ npx code-complexity <path-to-git-directory or URL> [options]

Help

    Usage: code-complexity <target> [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
      -cs, --complexity-strategy [strategy] choose the complexity strategy to analyze your codebase with (allowed values: sloc, cyclomatic, halstead).
      -f, --format [format]                 format results using table, json or csv
      -l, --limit [limit]                   limit the number of files to output
      -i, --since [since]                   limit analysis to commits more recent in age than date
      -u, --until [until]                   limit analysis to commits older in age than date
      -s, --sort [sort]                     sort results (allowed valued: score, churn, complexity or file)
      -d, --directories                     display values for directories instead of files
      -h, --help                            display help for command

    Examples:

    $ code-complexity .
    $ code-complexity https://github.com/simonrenoult/code-complexity
    $ code-complexity foo --limit 3
    $ code-complexity ../foo --sort score
    $ code-complexity /foo/bar --filter 'src/**,!src/front/**'
    $ code-complexity . --limit 10 --sort score
    $ code-complexity . --limit 10 --directories 
    $ code-complexity . --limit 10 --sort score -cs halstead
    $ code-complexity . --since=2021-06-01 --limit 100
    $ code-complexity . --since=2021-04-01 --until=2021-07-01

Output

$ npx code-complexity https://github.com/simonrenoult/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   │
└──────────────────────────────┴────────────┴───────┴───────┘

Special thanks

A special thanks to a few contributors that helped me make code-complexity better.

  • Alexander Dormann (alexdo) for fixing the ENOBUFS (and apologies for stealing your code).
  • Scott Brooks (scottamplitude) for initiating the work on complexity strategies

code-complexity's People

Contributors

simonrenoult avatar dependabot[bot] avatar rluvaton avatar scottamplitude avatar pmcelhaney avatar davemcg3 avatar nicoespeon avatar bolatovumar avatar

Stargazers

Roman avatar Billy Maulana avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.