{"id":13991736,"url":"https://github.com/philbooth/complexity-report","last_synced_at":"2025-07-22T14:31:56.909Z","repository":{"id":4866598,"uuid":"6021496","full_name":"philbooth/complexity-report","owner":"philbooth","description":"[UNMAINTAINED] Software complexity analysis for JavaScript projects","archived":true,"fork":false,"pushed_at":"2015-09-09T11:58:07.000Z","size":1022,"stargazers_count":464,"open_issues_count":3,"forks_count":65,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-08-10T14:06:22.817Z","etag":null,"topics":["unmaintained"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"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/philbooth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-30T19:27:22.000Z","updated_at":"2024-08-01T22:19:02.000Z","dependencies_parsed_at":"2022-09-01T15:21:09.187Z","dependency_job_id":null,"html_url":"https://github.com/philbooth/complexity-report","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philbooth%2Fcomplexity-report","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philbooth%2Fcomplexity-report/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philbooth%2Fcomplexity-report/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philbooth%2Fcomplexity-report/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philbooth","download_url":"https://codeload.github.com/philbooth/complexity-report/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227123941,"owners_count":17734229,"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":["unmaintained"],"created_at":"2024-08-09T14:01:33.632Z","updated_at":"2024-11-29T12:30:39.767Z","avatar_url":"https://github.com/philbooth.png","language":"JavaScript","readme":"# complexity-report\n\n:exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation:\n\n**NOTE: This fork is no longer maintained. Use [Jared's fork](https://github.com/jared-stilwell/complexity-report) instead.**\n\n:exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation: :anguished: :exclamation:\n\nSoftware complexity analysis for JavaScript projects.\nCommand-line front-end for [escomplex].\nLess attractive elder brother of [JSComplexity.org][jscomplexity].\n\n* [Software complexity analysis](#software-complexity-analysis)\n* [How it works](#how-it-works)\n* [Complexity metrics](#complexity-metrics)\n* [What not to do with the results](#what-not-to-do-with-the-results)\n* [What to do with the results](#what-to-do-with-the-results)\n* [Installation](#installation)\n* [Usage](#usage)\n    * [Command-line options](#command-line-options)\n    * [Output formats](#output-formats)\n* [License](#license)\n\n## Software complexity analysis\n\nComplexity is the quality of\nconsisting of many interrelated parts.\nWhen software consists of many interrelated parts,\nit becomes more difficult to reason about.\nSoftware that is difficult to reason about\nis a more fertile breeding ground for bugs\nthan software that is simple.\n\nEvery problem space contains some level of inherent complexity,\nwhich is shared by all possible solutions.\nHowever, as programmers,\nwe can reduce the complexity of our chosen solutions\nby limiting the interrelatedness of their constituent components.\nThis is commonly referred to as favouring cohesion over coupling,\nand forms the bedrock on which axioms\nsuch as the single responsibility principle are built.\n\nIn codebases that are large and/or unfamiliar,\nit can be difficult to know\nwhether regions of complexity exist\nand where they might be.\nBy defining metrics of complexity,\nthe search for offending components can be automated\nand brought into the existing build process\nalongside other forms of static analysis\nand unit tests.\n\n## How it works\n\ncomplexity-report is just\na [node.js][node]-based\ncommand-line wrapper around [escomplex],\nwhich is the library\nthat performs the actual analysis work.\nCode is passed to escomplex\nin the form of syntax trees\nthat have been generated\nwith [esprima],\nthe popular JavaScript parser.\n\n[Here is an example report][eg].\n\n## Complexity metrics\n\nThe readme for escomplex contains\na [brief overview of the metrics][metrics]\nit produces.\n\n## What not to do with the results\n\nThe numbers returned by this tool\nshould not be interpreted\nas definitive indicators\nof whether a piece of software\nis \"too complex\",\nwhatever that might mean.\n\nSoftware development is a varied field\nand every project is subject\nto a unique set of environmental factors.\nAttempts to set generic hard limits\nfor these complexity metrics\nmust essentially be arbitrary\nand fail to consider\nthe specific requirements\nof a given project.\nFurther, complexity itself\nis such an amorphous, multi-dimensional continuum,\nthat attempting to pigeon-hole chunks of code\nat discrete points along a single axis\nis an intrinsically crude approach.\n\n## What to do with the results\n\nIt is better to use this tool\nas a fuzzy, high-level mechanism,\nwhich can identify regions of interest\nor concern\nand from which\nyour own programming- and domain-expertise\ncan take over\nfor a more comprehensive analysis.\n\nAlthough the metrics themselves are not perfect,\nthey can help to identify areas of code\nthat warrant closer inspection.\nThey can also be tracked over time,\nas an indicator of the direction\nthat overall code quality may be moving in.\n\nThe tool can be configured to fail\nwhen complexity metrics pass a specified threshold,\nto aid its usefulness in automated environments / CI.\nThere are also options\nfor controlling how metrics are calculated\nand the format of the report output.\n\n## Installation\n\nYou must have [node.js installed][nodeinstall].\n\nThen, for a project-based install:\n\n```\nnpm install complexity-report\n```\n\nOr globally for all projects:\n\n```\nsudo npm install -g complexity-report\n```\n\n## Usage\n\n```\ncr [options] \u003cpath\u003e\n```\n\nThe tool will recursively read files\nfrom any directories that it encounters\nautomatically.\n\n### Command-line options\n\n```\n-h, --help                            output usage information\n-c, --config \u003cpath\u003e                   specify a configuration JSON file\n-o, --output \u003cpath\u003e                   specify an output file for the report\n-f, --format \u003cformat\u003e                 specify the output format of the report\n-e, --ignoreerrors                    ignore parser errors\n-a, --allfiles                        include hidden files in the report\n-p, --filepattern \u003cpattern\u003e           specify the files to process using a regular expression to match against file names\n-P, --dirpattern \u003cpattern\u003e            specify the directories to process using a regular expression to match against directory names\n-x, --excludepattern \u003cpattern\u003e        specify the the directories to exclude using a regular expression to match against directory names\n-m, --maxfiles \u003cnumber\u003e               specify the maximum number of files to have open at any point\n-F, --maxfod \u003cfirst-order density\u003e    specify the per-project first-order density threshold\n-O, --maxcost \u003cchange cost\u003e           specify the per-project change cost threshold\n-S, --maxsize \u003ccore size\u003e             specify the per-project core size threshold\n-M, --minmi \u003cmaintainability index\u003e   specify the per-module maintainability index threshold\n-C, --maxcyc \u003ccyclomatic complexity\u003e  specify the per-function cyclomatic complexity threshold\n-Y, --maxcycden \u003ccyclomatic density\u003e  specify the per-function cyclomatic complexity density threshold\n-D, --maxhd \u003chalstead difficulty\u003e     specify the per-function Halstead difficulty threshold\n-V, --maxhv \u003chalstead volume\u003e         specify the per-function Halstead volume threshold\n-E, --maxhe \u003chalstead effort\u003e         specify the per-function Halstead effort threshold\n-s, --silent                          don't write any output to the console\n-l, --logicalor                       disregard operator || as source of cyclomatic complexity\n-w, --switchcase                      disregard switch statements as source of cyclomatic complexity\n-i, --forin                           treat for...in statements as source of cyclomatic complexity\n-t, --trycatch                        treat catch clauses as source of cyclomatic complexity\n-n, --newmi                           use the Microsoft-variant maintainability index (scale of 0 to 100)\n-T, --coffeescript                    include coffee-script files\n```\n\n### Configuration files\n\nBy default,\ncomplexity-report will attempt\nto read configuration options\nfrom a JSON file\ncalled `.complexrc`\nin the current working directory.\nThis file should contain\na JSON object\nwith property names\nmatching the long-form\noption names\nfrom the command line\n(the ones that follow `--`).\nOptions set in this file\nwill be over-ridden\nby options specified\non the command line.\n\nSee an [example configuration file][egconfig].\n\nYou can also specify\nan alternative path\nto this file\nusing the `-c`\ncommand-line option.\n\n### Output formats\n\nCurrently there are five output formats supported:\n`plain`,\n`markdown`,\n`minimal`,\n`json`,\nand `xml`.\nThese are loaded\nfrom the `src/formats` subdirectory.\nIf the format file is not found\nin that directory,\na second attempt will be made to load the module\nwithout the subdirectory prefix,\nmore easily enabling the use of\ncustom formats if so desired.\n\nAdding new formats is simple;\neach one must be a CommonJS module,\nwhich exports a function named `format`.\nThe `format` function\nshould take a report object,\nas [defined by escomplex][format],\nand return its string\nrepresentation of the report.\n\nSee [the plain formatter][plain]\nfor an example.\n\n## Development\n\nSee the [contribution guidelines][contributions].\n\n## License\n\n[MIT][license]\n\n[escomplex]: https://github.com/philbooth/escomplex\n[jscomplexity]: http://jscomplexity.org/\n[node]: http://nodejs.org/\n[esprima]: http://esprima.org/\n[eg]: https://github.com/philbooth/complexity-report/blob/master/EXAMPLE.md\n[metrics]: https://github.com/philbooth/escomplex/blob/master/README.md#metrics\n[nodeinstall]: http://nodejs.org/download\n[egconfig]: https://github.com/philbooth/complexity-report/blob/master/.complexrc.example\n[format]: https://github.com/philbooth/escomplex/blob/master/README.md#result\n[plain]: https://github.com/philbooth/complexity-report/blob/master/src/formats/plain.js\n[contributions]: https://github.com/philbooth/complexity-report/blob/master/CONTRIBUTING.md\n[license]: https://github.com/philbooth/complexity-report/blob/master/COPYING\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilbooth%2Fcomplexity-report","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilbooth%2Fcomplexity-report","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilbooth%2Fcomplexity-report/lists"}