Commands
bca offers a range of commands to analyze and extract information from source code. Each command may include parameters specific to the task it performs. Below, we describe the core types of commands available in bca.
Metrics
Metrics provide quantitative measures about source code, which can help in:
- Compare different programming languages
- Provide information on the quality of a code
- Tell developers where their code is more tough to handle
- Discovering potential issues early in the development process
big-code-analysis calculates the metrics starting from the source code of a program. These kind of metrics are called static metrics.
Nodes
To represent the structure of program code, bca builds an Abstract Syntax Tree (AST). A node is an element of this tree and denotes any syntactic construct present in a language.
Nodes can be used to:
- Create the syntactic structure of a source file
- Discover if a construct of a language is present in the analyzed code
- Count the number of constructs of a certain kind
- Detect errors in the source code
REST API
bca-web runs a server offering a REST API. This allows users to
send source code via HTTP and receive corresponding metrics in JSON
format.
Skipping generated code
Generated bindings (protobuf stubs, OpenAPI clients, lex/yacc output,
build-system plumbing) inflate metrics for code no human will refactor.
By default, bca scans the first ~50 lines / 5 KiB of
each file for a generated-code marker and skips matches before parsing,
so the skipped file pays no tree-sitter parse cost.
Recognized markers (case-insensitive):
@generated— Facebook / Meta convention; also emitted by buck2, rustfmt, prettier, and many code generators.DO NOT EDIT— Go's// Code generated by … DO NOT EDIT.is the canonical form; the bare phrase is also widely copied (Bazel, protoc, OpenAPI clients).GENERATED CODE— Lizard's marker, recognized for compatibility.
A marker phrase that appears only deep in the file body (past the scan window) does not trigger the skip — the detector deliberately looks only at the file header.
The skip applies uniformly to bca metrics, bca report, and the
threshold engine.
Flags
--no-skip-generated— disable the auto-skip and restore the previous behavior (every file is parsed).--report-skipped— logskipped (generated): <path>to stderr for each file the detector excludes, so you can audit the exclusions and add an explicit include if a file was wrongly tagged.
Respecting .gitignore
When a directory is passed to --paths, bca walks
it with .gitignore awareness by default. Files matched by any of the
following are skipped before parsing:
.gitignorefiles inside the walked tree..ignorefiles (the ripgrep /fdconvention)..git/info/exclude.- The global gitignore (
~/.config/git/ignore, or whatevercore.excludesFilepoints at). .gitignorefiles in ancestor directories of the seed (sobca --paths src/from a project root picks up the project's top-level.gitignore).
The walker honors .gitignore even outside a checked-in git
repository, so an extracted source tarball with a .gitignore file
gets the same treatment as a fresh git clone.
Hidden files (those whose basename starts with .) are filtered
during the walk, matching the previous behavior.
Explicit paths bypass the filter
Files passed by name — via --paths or --paths-from — are always
analyzed, even when they would be excluded by .gitignore. This makes
it safe to do bca metrics --paths-from - from git diff --name-only-style pipelines without losing files that happen to be
covered by a wildcard ignore rule.
Path discovery flags
--no-ignore— disable.gitignore/.ignore/ global-gitignore awareness when expanding directory seeds.--paths-from <FILE>— read newline-separated input paths from<FILE>, or from stdin when<FILE>is-. Combined as a union with any--pathsvalues;-I/-Xglobs still apply. Blank lines are skipped;#is treated as a path character (not a comment). To pass a file literally named-, write./-.--exclude-from <FILE>— read newline-separated--excludeglob patterns from<FILE>, or from stdin when<FILE>is-. Patterns are unioned with any inline--exclude/-Xvalues into a single deny-set; order does not matter..gitignore-style: blank lines and lines whose first non-whitespace character is#are skipped, and a leading UTF-8 BOM is stripped. Convention is a.bcaignoreat the repo root, mirroring.gitignore/.dockerignore. To pass a file literally named-, write./-.