{"id":13672452,"url":"https://github.com/thoughtbot/complexity","last_synced_at":"2025-04-04T21:07:12.899Z","repository":{"id":43372713,"uuid":"320453899","full_name":"thoughtbot/complexity","owner":"thoughtbot","description":"A command line tool to identify complex code","archived":false,"fork":false,"pushed_at":"2024-12-27T03:58:23.000Z","size":67,"stargazers_count":166,"open_issues_count":4,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-28T20:07:53.417Z","etag":null,"topics":["cli","code-analysis","complexity","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/thoughtbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"thoughtbot"}},"created_at":"2020-12-11T03:14:06.000Z","updated_at":"2025-03-26T08:24:32.000Z","dependencies_parsed_at":"2024-08-16T19:55:40.979Z","dependency_job_id":"2f50d684-4fd3-4bca-b7d3-df96c7d33877","html_url":"https://github.com/thoughtbot/complexity","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtbot%2Fcomplexity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtbot%2Fcomplexity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtbot%2Fcomplexity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtbot%2Fcomplexity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoughtbot","download_url":"https://codeload.github.com/thoughtbot/complexity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249524,"owners_count":20908212,"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":["cli","code-analysis","complexity","rust"],"created_at":"2024-08-02T09:01:35.964Z","updated_at":"2025-04-04T21:07:12.873Z","avatar_url":"https://github.com/thoughtbot.png","language":"Rust","readme":"# `complexity`\n\nCalculate an approximation of code complexity per file in a language-agnostic way.\n\n## Motivation\n\nIf you're new to a codebase, it's helpful to understand at a glance what files\nmay be particularly complex. With that guidance, developers can more quickly\nread through the code to understand hotspots.\n\nAt thoughtbot, we work in codebases of all shapes and languages, including\nRuby, Elixir, Python, Scala, TypeScript/JavaScript, Go, Elm, Swift, and Java.\nThis CLI tool aims to highlight complexity across any of these codebases by\nassigning simple heuristics to increases in indentation.\n\nThis concept has been discussed in [this paper]; `complexity` does not intend\nto mimic approaches in this paper directly, although the motivations discussed\nin the paper – especially avoiding calculating cyclomatic complexity ([McCabe])\ngiven requirements of AST parsing and analysis due to time and language\nrequirements – are of considerable overlap.\n\n[this paper]: https://doi.org/10.1016/j.scico.2009.02.005\n[McCabe]: https://en.wikipedia.org/wiki/Cyclomatic_complexity\n\n## Installation\n\n### MacOS with Homebrew\n\n```sh\nbrew tap thoughtbot/formulae\nbrew install complexity\n```\n\n## Configuration\n\n`complexity` has configuration options to ignore certain file extensions or\nsubstrings with paths.\n\nTo install this default configuration, run:\n\n```sh\ncomplexity install-configuration\n```\n\nThis creates/overwrites a yaml configuration at\n`$HOME/.config/complexity/complexity.yml`.\n\nBy default, extensions including `lock`, `toml`, `json`, and `md` are ignored.\n\n`complexity` will automatically honor `.gitignore` settings.\n\n## Usage\n\n### Basic\n\nLet's grab the 20 most complex files:\n\n```sh\ncomplexity | sort -n --reverse | head -n 20\n```\n\nWithin the [Discourse codebase], for example, here's what the output might look like:\n\n```\n  487.96 ./spec/components/guardian_spec.rb\n  465.19 ./spec/requests/users_controller_spec.rb\n  363.09 ./spec/requests/topics_controller_spec.rb\n  311.10 ./spec/models/topic_spec.rb\n  273.57 ./lib/javascripts/messageformat.js\n  266.61 ./spec/models/user_spec.rb\n  248.28 ./app/assets/javascripts/discourse/app/controllers/topic.js\n  238.81 ./app/assets/javascripts/discourse/tests/fixtures/discovery-fixtures.js\n  219.06 ./script/import_scripts/socialcast/test/test_data.rb\n  207.01 ./app/controllers/users_controller.rb\n  205.86 ./app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js\n  202.18 ./app/assets/javascripts/discourse/tests/fixtures/topic.js\n  200.17 ./lib/search.rb\n  193.05 ./app/assets/javascripts/discourse/app/controllers/composer.js\n  191.63 ./app/models/user.rb\n  187.97 ./app/models/topic.rb\n  186.10 ./spec/components/pretty_text_spec.rb\n  179.25 ./spec/requests/session_controller_spec.rb\n  174.89 ./spec/requests/groups_controller_spec.rb\n  173.44 ./app/assets/javascripts/discourse/tests/integration/widgets/post-test.js\n```\n\n[Discourse codebase]: https://github.com/discourse/discourse\n\n### Advanced\n\n`complexity` supports alternative formatting options, like JSON and CSV.\nAdditionally, you can limit results by substring with the `--only` flag, or\nmodify paths to ignore with `--ignore`.\n\n```sh\n// This filters the .rs files inside all directories and outputs scores in a json format\ncomplexity --format json --only .rs\n\n// This filters the .rs and .md files inside all directories\ncomplexity --only .rs,.md\n\n// This filters all the files inside src/scoring directory\ncomplexity --only src/scoring\n```\n\nYou can view the full suite of options by running `complexity help`.\n\n## License\n\nCopyright 2020 Josh Clayton and thoughtbot, inc. See the [LICENSE](LICENSE).\n","funding_links":["https://github.com/sponsors/thoughtbot"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoughtbot%2Fcomplexity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoughtbot%2Fcomplexity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoughtbot%2Fcomplexity/lists"}