{"id":50607282,"url":"https://github.com/yu-iskw/sqlfluff-complexity","last_synced_at":"2026-06-06T00:04:10.860Z","repository":{"id":355020531,"uuid":"1226363595","full_name":"yu-iskw/sqlfluff-complexity","owner":"yu-iskw","description":"A custom SQLFluff plugin to calculate SQL complexity","archived":false,"fork":false,"pushed_at":"2026-06-02T10:09:07.000Z","size":4403,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-02T12:10:23.135Z","etag":null,"topics":["agent-harness","dbt","harness-engineering","sql","sqlfluff"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/sqlfluff-complexity/","language":"Python","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/yu-iskw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-01T09:50:56.000Z","updated_at":"2026-06-02T10:09:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yu-iskw/sqlfluff-complexity","commit_stats":null,"previous_names":["yu-iskw/sqlfluff-complexity"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/yu-iskw/sqlfluff-complexity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yu-iskw%2Fsqlfluff-complexity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yu-iskw%2Fsqlfluff-complexity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yu-iskw%2Fsqlfluff-complexity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yu-iskw%2Fsqlfluff-complexity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yu-iskw","download_url":"https://codeload.github.com/yu-iskw/sqlfluff-complexity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yu-iskw%2Fsqlfluff-complexity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33964367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["agent-harness","dbt","harness-engineering","sql","sqlfluff"],"created_at":"2026-06-06T00:04:10.244Z","updated_at":"2026-06-06T00:04:10.853Z","avatar_url":"https://github.com/yu-iskw.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlfluff-complexity\n\nSQLFluff rules and reports for finding SQL and dbt models that are too complex to review safely.\n\n`sqlfluff-complexity` adds CPX rules to SQLFluff for CTE count, join count, nested\nsubquery depth, `CASE` expressions, nested `CASE` depth, boolean predicates, window functions,\nCTE dependency depth, set operations (`UNION` / `INTERSECT` / `EXCEPT`), inline derived tables, and\nan aggregate weighted complexity score. The same metric engine also powers a companion\n`sqlfluff-complexity report` command for non-blocking console, JSON, SARIF, and standalone\nHTML reports.\n\n## Who It Is For\n\n- Analytics engineers who want dbt models to stay small enough to review.\n- Data platform teams that already run SQLFluff in local development or CI.\n- Teams that want gradual complexity reporting before turning on strict lint failures.\n\n## Quick Start\n\n**Requires SQLFluff 4.x** in the same environment (`sqlfluff\u003e=4,\u003c5`). SQLFluff 3 is not supported as of `sqlfluff-complexity` 0.4.0; pin `sqlfluff-complexity\u003c0.4` if you cannot upgrade SQLFluff yet.\n\nInstall the custom SQLFluff plugin in the same Python environment where you run SQLFluff:\n\n```bash\npip install sqlfluff-complexity\n```\n\nIf your project uses `uv`:\n\n```bash\nuv add --dev sqlfluff-complexity\n```\n\nThen enable CPX rules in `.sqlfluff` and run SQLFluff:\n\n```ini\n[sqlfluff]\ndialect = postgres\nrules = CPX_C101,CPX_C102,CPX_C103,CPX_C104,CPX_C105,CPX_C106,CPX_C107,CPX_C108,CPX_C109,CPX_C110,CPX_C201\n```\n\n```bash\nsqlfluff lint models/\n```\n\nFor a complete walkthrough, see [docs/quickstart.md](docs/quickstart.md).\n\n**Migrating `complexity_weights`:** Use a JSON object in `[sqlfluff:rules:CPX_C201]` (not comma-separated `key:value` lists). See [Configuration: aggregate score](docs/configuration.md#aggregate-score) and [CHANGELOG](CHANGELOG.md).\n\n## Documentation\n\n- [Quick start](docs/quickstart.md): install, configure, and run the first lint.\n- [Configuration](docs/configuration.md): thresholds, aggregate weights, [SQLFluff nested config by path](docs/configuration.md#sqlfluff-nested-configuration-by-path), and `path_overrides`.\n- [Rules reference](docs/rules.md): CPX rule codes and what each metric counts.\n- [Reporting](docs/reporting.md): console, JSON, SARIF, and HTML report mode.\n- [Python API](docs/python-api.md): stable programmatic imports (today: `report` pipeline and related config helpers; more subcommands documented here as they ship).\n- [Adoption](docs/adoption.md): calibration, CI/SARIF examples, before/after SQL vignette.\n- [dbt usage](docs/dbt.md): SQLFluff dbt templater compatibility and v1 boundaries.\n- [Dialects](docs/dialects.md): tested dialects and dbt adapter mapping caveats.\n- [Docs index](docs/index.md): all user, contributor, and design documents.\n- [Internal import migration](docs/migration-internal.md): if you import `sqlfluff_complexity.core` submodules directly, update paths after subpackage refactors.\n\n## Large dbt projects\n\nThis plugin does **not** read dbt artifacts (`manifest.json`, `run_results.json`, `catalog.json`) or graph metadata. Complexity is measured from the SQLFluff parse tree only—which aligns well with [SQLFluff’s dbt templater](docs/dbt.md) so `ref()`, `source()`, and macros compile before linting.\n\nPractical adoption patterns:\n\n- Use the dbt templater when you need compiled SQL fidelity; keep `sqlfluff-complexity` focused on structural signals from parsed SQL.\n- Tune thresholds per rule and use [`path_overrides`](docs/configuration.md) on `CPX_C201` where staging vs marts need different budgets.\n- Prefer `sqlfluff lint` on changed models in CI and [`sqlfluff-complexity report`](docs/reporting.md) for broader visibility without failing builds.\n- For **CTE dependency depth**, see [docs/rules.md](docs/rules.md) (CPX_C107) and [docs/reporting.md](docs/reporting.md) (report vs per-`WITH` lint).\n\nSee also [dbt usage](docs/dbt.md) and [configuration](docs/configuration.md).\n\n## Project Status\n\n- Native SQLFluff plugin rules and the companion report CLI are available in the package.\n- v1 measures SQLFluff-parsed SQL; direct dbt `manifest.json` and DAG-level metrics are deferred.\n- Architecture decisions are recorded in [docs/adr/](docs/adr/).\n\n## Development\n\nContributor setup, Nox sessions, fixture authoring, ADR workflow, and verifier guidance live in\n[CONTRIBUTING.md](CONTRIBUTING.md). Agent-specific project instructions live in\n[AGENTS.md](AGENTS.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyu-iskw%2Fsqlfluff-complexity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyu-iskw%2Fsqlfluff-complexity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyu-iskw%2Fsqlfluff-complexity/lists"}