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:
- Constrain memory on a large monorepo so the streaming pipeline auto-tunes worker count and spill thresholds rather than consuming all available RAM:
- If you need only a subset of the history, limit the commit range with
--sinceor--limitto keep the run bounded:
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'