{"id":47928246,"url":"https://github.com/strangedaystech/arborist-cli","last_synced_at":"2026-04-04T07:02:09.962Z","repository":{"id":349061164,"uuid":"1199962850","full_name":"StrangeDaysTech/arborist-cli","owner":"StrangeDaysTech","description":"CLI for arborist-metrics — code complexity analysis from the command line","archived":false,"fork":false,"pushed_at":"2026-04-04T01:59:20.000Z","size":356,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T03:26:18.534Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StrangeDaysTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-02T22:25:25.000Z","updated_at":"2026-04-04T01:59:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/StrangeDaysTech/arborist-cli","commit_stats":null,"previous_names":["strangedaystech/arborist-cli"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/StrangeDaysTech/arborist-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrangeDaysTech%2Farborist-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrangeDaysTech%2Farborist-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrangeDaysTech%2Farborist-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrangeDaysTech%2Farborist-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StrangeDaysTech","download_url":"https://codeload.github.com/StrangeDaysTech/arborist-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StrangeDaysTech%2Farborist-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31390695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-04-04T07:02:09.077Z","updated_at":"2026-04-04T07:02:09.916Z","avatar_url":"https://github.com/StrangeDaysTech.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# arborist-cli\n\nCode complexity metrics for your codebase, powered by [arborist-metrics](https://crates.io/crates/arborist-metrics).\n\n`arborist-cli` analyzes source files and reports **cognitive complexity**, **cyclomatic complexity**, and **SLOC** per function. It works with single files, entire directories, or piped stdin. Output is available as a human-readable table, JSON, or CSV.\n\n## Installation\n\n### Pre-built binaries (recommended)\n\nDownload the latest release for your platform — no Rust toolchain required.\n\n**Linux / macOS:**\n\n```bash\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/StrangeDaysTech/arborist-cli/releases/latest/download/arborist-cli-installer.sh | sh\n```\n\n**Windows (PowerShell):**\n\n```powershell\npowershell -ExecutionPolicy ByPass -c \"irm https://github.com/StrangeDaysTech/arborist-cli/releases/latest/download/arborist-cli-installer.ps1 | iex\"\n```\n\n### cargo binstall (pre-compiled, no build)\n\nIf you have [cargo-binstall](https://github.com/cargo-bins/cargo-binstall) installed:\n\n```bash\ncargo binstall arborist-cli\n```\n\n### cargo install (from source)\n\nRequires Rust 1.85+ (Edition 2024):\n\n```bash\ncargo install arborist-cli\n```\n\n### From source\n\n```bash\ngit clone https://github.com/StrangeDaysTech/arborist-cli.git\ncd arborist-cli\ncargo build --release\n# Binary at ./target/release/arborist-cli\n```\n\n## Updating\n\nThe update method depends on how you installed:\n\n| Installed via | Update command |\n|---------------|----------------|\n| Shell/PowerShell installer | `arborist update` |\n| Direct binary download | `arborist update` |\n| cargo binstall | `cargo binstall arborist-cli` |\n| cargo install | `cargo install arborist-cli` |\n\nCheck for updates without installing:\n\n```bash\narborist update --check\n```\n\n## Quick start\n\n```bash\n# Analyze a single file\narborist src/main.rs\n\n# Analyze an entire directory\narborist src/\n\n# Find the 5 most complex functions\narborist src/ --sort cognitive --top 5\n\n# Fail CI if any function exceeds cognitive complexity 15\narborist src/ --threshold 15\n```\n\n## Usage\n\n```\narborist [OPTIONS] [PATHS]... [COMMAND]\n```\n\n### Commands\n\n| Command | Description |\n|---------|-------------|\n| `update` | Check for updates and install the latest version |\n| `update --check` | Check for available updates without installing |\n\n### Arguments\n\n| Argument | Description |\n|----------|-------------|\n| `PATHS` | Files or directories to analyze. Omit to read from stdin. |\n\n### Options\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `--format \u003ctable\\|json\\|csv\u003e` | `table` | Output format |\n| `--threshold \u003cN\u003e` | — | Cognitive complexity threshold. Functions exceeding it are flagged with `!`. Exit code becomes `1`. |\n| `--exceeds-only` | — | Show only functions that exceed `--threshold` |\n| `--sort \u003ccognitive\\|cyclomatic\\|sloc\\|name\u003e` | — | Sort results (flat list). Numeric sorts are descending; `name` is ascending. |\n| `--top \u003cN\u003e` | — | Show only the top N results (implies flat list) |\n| `--languages \u003clang,...\u003e` | — | Filter directory traversal by language (e.g. `rust,python`) |\n| `--gitignore` | — | Respect `.gitignore` patterns during directory traversal |\n| `--no-methods` | — | Exclude method-level analysis |\n| `--language \u003clang\u003e` | — | Language hint for stdin input (required when piping) |\n\n### Exit codes\n\n| Code | Meaning |\n|------|---------|\n| `0` | Success |\n| `1` | Threshold exceeded (at least one function above `--threshold`) |\n| `2` | Error (file not found, unrecognized language, I/O failure) |\n\nError (code 2) takes precedence over threshold (code 1).\n\n## Output formats\n\n### Table (default)\n\n```\ntests/fixtures/complex.rs (Rust) — 3 functions, 42 SLOC\n Function           Lines  Cognitive  Cyclomatic  SLOC\n simple_function    1-3    0          1           3\n complex_function   5-32   27         11          28\n moderate_function  34-44  4          3           11\n```\n\nWith `--threshold 5`, functions exceeding the threshold are marked:\n\n```\n complex_function   5-32   27 !       11          28\n```\n\n### JSON\n\n```bash\narborist src/main.rs --format json\n```\n\n```json\n[\n  {\n    \"path\": \"src/main.rs\",\n    \"language\": \"Rust\",\n    \"functions\": [\n      {\n        \"name\": \"main\",\n        \"start_line\": 1,\n        \"end_line\": 17,\n        \"cognitive\": 3,\n        \"cyclomatic\": 3,\n        \"sloc\": 15\n      }\n    ],\n    \"file_cognitive\": 3,\n    \"file_cyclomatic\": 3,\n    \"file_sloc\": 15\n  }\n]\n```\n\n### CSV\n\n```bash\narborist src/lib.rs --format csv\n```\n\n```\nfile,language,function,line_start,line_end,cognitive,cyclomatic,sloc\nsrc/lib.rs,Rust,hello,1,3,0,1,3\nsrc/lib.rs,Rust,add,5,7,0,1,3\n```\n\n## Supported languages\n\nRust, Python, JavaScript, TypeScript, TSX, JSX, Java, Go, C, C++, C#, Ruby, Swift, Kotlin, PHP.\n\n## Use with AI agents\n\n`arborist-cli` is designed to integrate into automated workflows. AI agents can use it to assess code quality before or after generating changes.\n\n### Recommended patterns\n\n**Gate a PR on complexity** (CI/CD):\n\n```bash\narborist src/ --threshold 15 --format json\n# Exit code 1 if any function exceeds threshold\n# JSON output is machine-parseable for further processing\n```\n\n**Identify refactoring targets**:\n\n```bash\narborist src/ --sort cognitive --top 10 --format json\n```\n\n**Analyze generated code from stdin**:\n\n```bash\necho \"$GENERATED_CODE\" | arborist --language rust --format json\n```\n\n**Filter by language in a polyglot repo**:\n\n```bash\narborist . --languages rust,python --gitignore --format csv\n```\n\n**Check only threshold violations** (minimal output):\n\n```bash\narborist src/ --threshold 10 --exceeds-only --format csv\n```\n\n### Machine-readable output\n\n- `--format json` returns an array of `FileReport` objects. Each contains `path`, `language`, `functions[]` (with per-function metrics), and file-level aggregates (`file_cognitive`, `file_cyclomatic`, `file_sloc`).\n- `--format csv` returns RFC 4180 CSV with header: `file,language,function,line_start,line_end,cognitive,cyclomatic,sloc`.\n- Exit code `1` reliably signals threshold violations without parsing output.\n\n---\n\n## For developers\n\n### Project structure\n\n```\nsrc/\n  main.rs           Entry point — parses args, dispatches to analyze or update\n  lib.rs            Orchestration — stdin detection, path analysis, output dispatch\n  cli.rs            CLI argument definitions (clap derive) with optional subcommands\n  analysis.rs       arborist-metrics wrapper, threshold filtering, sorting\n  traversal.rs      Directory walking (ignore crate), language detection by extension\n  error.rs          Error types (thiserror), ExitReport with exit code logic\n  update.rs         Self-update from GitHub Releases (self_update crate)\n  output/\n    mod.rs          Format dispatcher (grouped vs. flat mode)\n    table.rs        Human-readable table output (comfy-table)\n    json.rs         JSON serialization (serde_json)\n    csv_output.rs   CSV output (csv crate)\ntests/\n  cli/              Integration tests organized by feature area\n  fixtures/         Test input files (Rust, Python, multi-file projects)\n```\n\n### Building\n\n```bash\ncargo build            # Debug\ncargo build --release  # Optimized\n```\n\nRequires **Rust 1.85+** (Edition 2024).\n\n### Running tests\n\n```bash\ncargo test\n```\n\nTests are integration tests that invoke the compiled binary via `assert_cmd`. They cover all input modes, output formats, filtering options, and exit code semantics.\n\n### Linting\n\n```bash\ncargo fmt --check\ncargo clippy -- -D warnings\n```\n\nThe project enforces `clippy::all = \"deny\"` in `Cargo.toml`.\n\n### Releasing\n\nSee [RELEASING.md](RELEASING.md) for the full release procedure. In short:\n\n1. Bump version in `Cargo.toml`\n2. `git tag v0.2.0 \u0026\u0026 git push origin main --tags`\n3. CI builds binaries for all platforms and creates the GitHub Release\n\n### Reporting issues\n\nFile bugs and feature requests at [GitHub Issues](https://github.com/StrangeDaysTech/arborist-cli/issues). See [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n### Contributing\n\nWe welcome patches! Please read [CONTRIBUTING.md](CONTRIBUTING.md) before submitting a PR. All contributors must sign the **Contributor License Agreement (CLA)** — the CLA bot will guide you on your first pull request.\n\n## License\n\nLicensed under either of\n\n- [MIT License](LICENSE-MIT)\n- [Apache License, Version 2.0](LICENSE-APACHE)\n\nat your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrangedaystech%2Farborist-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrangedaystech%2Farborist-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrangedaystech%2Farborist-cli/lists"}