How to analyze a monorepo¶
Goal¶
Run Codefang against a single large repository that holds many languages and services, and get a clean per-service report without drowning in vendored or generated noise.
Prerequisites¶
codefanganduastinstalled. See Installation.- A monorepo checked out locally, with full Git history (history analyzers need every commit, not a shallow clone).
jqif you want to post-process the JSON output.
Steps¶
- Run static analysis across the whole tree first. By default Codefang already excludes vendored dependencies (
vendor/,node_modules/,third_party/,testdata/) and generated files, so the report covers your own code only:
- Narrow a noisy polyglot repo to the languages you care about. The
--languagesfilter applies to both the static and history phases and skips non-matching files before they are parsed:
- Scope a run to a single service directory instead of the whole repo by passing its path (or
--path):
- Add extra exclusion prefixes for tooling directories that Linguist's heuristics do not catch, such as a Python virtualenv or a Rust target dir:
- Bound the history window on a large monorepo — there is no memory or worker knob; a history run costs what its commit window costs. Limit the range with
--sinceor--limit, skip merge side branches with--first-parent, and drop mass-change commits (vendoring dumps, generated-code regenerations) with--max-changes-per-commit:
- If you need only a period of the history, select it with
--since:
Result¶
You have a JSON report scoped to your own source code (vendored and generated files excluded) and, when you narrow by --languages or path, scoped to the service you care about. Confirm the scope by inspecting the report — for example, count the files Codefang actually analyzed:
codefang run -a 'static/complexity' --languages go --format json . | jq '.["static/complexity"] | length'