{"id":19490541,"url":"https://github.com/simonrenoult/code-complexity","last_synced_at":"2025-04-12T22:34:48.132Z","repository":{"id":30998826,"uuid":"126602063","full_name":"simonrenoult/code-complexity","owner":"simonrenoult","description":"Measure the churn/complexity ratio. Higher values mean hotspots where refactorings should happen.","archived":false,"fork":false,"pushed_at":"2024-03-20T12:52:59.000Z","size":280,"stargazers_count":274,"open_issues_count":17,"forks_count":27,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-14T10:48:07.721Z","etag":null,"topics":["churn","complexity","quality","sloc"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonrenoult.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-24T13:30:05.000Z","updated_at":"2024-06-19T09:30:56.045Z","dependencies_parsed_at":"2024-06-19T09:30:45.467Z","dependency_job_id":null,"html_url":"https://github.com/simonrenoult/code-complexity","commit_stats":{"total_commits":149,"total_committers":10,"mean_commits":14.9,"dds":"0.40268456375838924","last_synced_commit":"4e2ff689f567e2c96e4962de8333202d5d36deee"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrenoult%2Fcode-complexity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrenoult%2Fcode-complexity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrenoult%2Fcode-complexity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrenoult%2Fcode-complexity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonrenoult","download_url":"https://codeload.github.com/simonrenoult/code-complexity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248642308,"owners_count":21138350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["churn","complexity","quality","sloc"],"created_at":"2024-11-10T21:13:29.346Z","updated_at":"2025-04-12T22:34:48.109Z","avatar_url":"https://github.com/simonrenoult.png","language":"TypeScript","readme":"# code-complexity\n\n\u003e Measure the churn/complexity score. Higher scores reveal hotspots where\n\u003e refactorings should happen.\n\n[![Build Status][travis-image]][travis-url]\n[![Coverage Status][coverage-image]][coverage-url]\n[![Style Status][style-image]][style-url]\n[![NPM Version][npm-image]][npm-url]\n\nQuoting Michael Feathers (source [here][michael-feathers-source]):\n\n*Often when we refactor, we look at local areas of code. If we take a wider\nview, using information from our version control systems, we can get a better\nsense of the effects of our refactoring efforts.*\n\n\nNote: `code-complexity` currently measures complexity using either:\n- lines of code count (all languages)\n- cyclomatic complexity (JavaScript/TypeScript)\n- halstead complexity (JavaScript/TypeScript)\n\n## Usage\n\n```sh\n$ npx code-complexity \u003cpath-to-git-directory or URL\u003e [options]\n```\n\n## Help\n\n```text\n    Usage: code-complexity \u003ctarget\u003e [options]\n\n    Measure the churn/complexity score. Higher values mean hotspots where refactorings should happen.\n\n    Options:\n      -V, --version                         output the version number\n      --filter \u003cstrings\u003e                    list of globs (comma separated) to filter\n      -cs, --complexity-strategy [strategy] choose the complexity strategy to analyze your codebase with (allowed values: sloc, cyclomatic, halstead).\n      -f, --format [format]                 format results using table, json or csv\n      -l, --limit [limit]                   limit the number of files to output\n      -i, --since [since]                   limit analysis to commits more recent in age than date\n      -u, --until [until]                   limit analysis to commits older in age than date\n      -s, --sort [sort]                     sort results (allowed valued: score, churn, complexity or file)\n      -d, --directories                     display values for directories instead of files\n      -h, --help                            display help for command\n\n    Examples:\n\n    $ code-complexity .\n    $ code-complexity https://github.com/simonrenoult/code-complexity\n    $ code-complexity foo --limit 3\n    $ code-complexity ../foo --sort score\n    $ code-complexity /foo/bar --filter 'src/**,!src/front/**'\n    $ code-complexity . --limit 10 --sort score\n    $ code-complexity . --limit 10 --directories \n    $ code-complexity . --limit 10 --sort score -cs halstead\n    $ code-complexity . --since=2021-06-01 --limit 100\n    $ code-complexity . --since=2021-04-01 --until=2021-07-01\n```\n\n## Output\n\n```sh\n$ npx code-complexity https://github.com/simonrenoult/code-complexity --sort=score --limit=3\n\n┌──────────────────────────────┬────────────┬───────┬───────┐\n│ file                         │ complexity │ churn │ score │\n├──────────────────────────────┼────────────┼───────┼───────┤\n│ src/cli.ts                   │ 103        │ 8     │ 824   │\n├──────────────────────────────┼────────────┼───────┼───────┤\n│ test/code-complexity.test.ts │ 107        │ 7     │ 749   │\n├──────────────────────────────┼────────────┼───────┼───────┤\n│ .idea/workspace.xml          │ 123        │ 6     │ 738   │\n└──────────────────────────────┴────────────┴───────┴───────┘\n```\n\n## Special thanks\n\nA special thanks to a few contributors that helped me make `code-complexity` better.\n\n- Alexander Dormann (alexdo) for fixing the `ENOBUFS` (and apologies for stealing your code).\n- Scott Brooks (scottamplitude) for initiating the work on complexity strategies\n\n[michael-feathers-source]:https://www.stickyminds.com/article/getting-empirical-about-refactoring\n[travis-image]:https://img.shields.io/travis/simonrenoult/code-complexity/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/simonrenoult/code-complexity\n[style-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\n[style-url]: https://prettier.io/\n[coverage-image]: https://img.shields.io/codecov/c/github/simonrenoult/code-complexity.svg?style=flat-square\n[coverage-url]: https://codecov.io/gh/simonrenoult/code-complexity/branch/master\n[npm-image]: https://img.shields.io/npm/v/code-complexity.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/code-complexity\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonrenoult%2Fcode-complexity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonrenoult%2Fcode-complexity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonrenoult%2Fcode-complexity/lists"}