Repository navigation
v0.32.0
Shell, PowerShell, Make and Dockerfiles are read, and the scripts a project runs are connected to what runs them. Asked who runs hack/make-rules/test.sh in kubernetes-sigs/kind, sct callers now answers with the three Makefile targets that do; asked who loads src/Pester.Utility.ps1 in Pester, it lists the four files that dot-source it. CSV, TSV and XML files get a structure that replaces head. Directories named like build output (packages/, bin/, build/) are read when git tracks them, which is where a JavaScript monorepo keeps all its code.
Scripts are connected to the scripts and build steps that run them
Bash (.sh, .bash), PowerShell (.ps1, .psm1, .psd1), Make (Makefile, GNUmakefile, .mk) and Dockerfiles (Dockerfile, Containerfile, suffixed variants) are new languages. In a shell the edges that tie a project together are rarely functions calling functions; they are one script reading another (source, dot-sourcing, Import-Module, a module manifest) and one file running another (./build.sh, bash x.sh, pwsh -File, a Makefile recipe, a Dockerfile RUN or ENTRYPOINT of a script it copied in). Those are import edges now, so they count toward a file's importers in sct callers <file>, used by and centrality.
Paths are resolved without evaluating the shell: the script's own directory ($(dirname "$0"), ${BASH_SOURCE%/*}, $PSScriptRoot, $(dir $(lastword $(MAKEFILE_LIST)))) gives an exact edge; a path under a variable root ("${BASH_IT}/lib/log.bash") gives one only when exactly one project file ends with that tail; anything else gives none rather than a guess.
<3 importers in 1 file> importers of hack/make-rules/test.sh
- Makefile:80 MODE=unit hack/make-rules/test.sh
- Makefile:83 MODE=integration hack/make-rules/test.sh
- Makefile:86 hack/make-rules/test.sh
The Make and Dockerfile handlers work around their grammars, measured on real files. The make grammar reads shell inside $(shell …) as make and can lose the rest of the file to one parse error; the handler blanks those spans before parsing (lines inside parse errors across 29 Makefiles: 4.0 % → 0.5 %). The Dockerfile grammar left 35 % of the lines of 58 real Dockerfiles in parse errors, so that handler reads lines instead.
Limits: files loaded in a loop (for f in enabled/*.bash, Get-ChildItem | . $_.FullName) cannot be followed statically, which is why bash-it shows 9 % of its files linked; .zsh is left out because the bash grammar fails on 45 % of the lines of oh-my-zsh.
Scripts without an extension are recognised by their #! line
rbenv and pyenv keep their whole command set as extension-less scripts in libexec/, Rails keeps bin/rails and bin/setup. A file without an extension is now matched by the interpreter its #! line names (bash, sh, python, ruby, node, php, pwsh, …). On rbenv, definitions found went from 13 to 41 and files linked from 0 to 16; on bats-core, definitions from 153 to 313.
Directories named like build output are read when git tracks them
packages/, bin/, build/, out/, release/ and target/ were always skipped, as build output. They are also where projects keep source: at the root of colinhacks/zod, 666 of 742 tracked files sit under packages/, and the code map saw 50 files. A directory under one of these names is now read when git tracks a file below it — build output is not committed. zod: 50 → 668 files; kind: 338 → 382. vendor/, node_modules/, dist/ and coverage/ stay skipped even when tracked: they hold other people's code or generated files. Outside a git repository nothing changes.
CSV, TSV and XML get a structure
A CSV or TSV file shows its delimiter, one row per column with a type and an example value, and the row count (exact when it can be known from bytes, else an upper bound: ≤1,733,816 against 1,732,085 real records for a 95 MB file, in 26 ms). Only a 64 KiB prefix is parsed. The answer is 0.4–0.7 × the size of head -20 on the files measured.
An XML file shows its element outline, elements named by id/name/key/Include, to depth 6. References that are part of the format are edges: Maven <module> and <relativePath>, MSBuild <Import> and <ProjectReference>, .slnx projects, XSD import/include, XSLT and XInclude. Measured share that names a file in its tree: Maven modules 624 of 693, MSBuild project references 58 of 60, .slnx 32 of 32.
There are no edges from code to the data files it reads (pd.read_csv("x.csv")): an earlier measurement found that edges of that kind added no finding a search did not, at a 30 % noise cost, and this has not been measured again.
Every language is measured on real code
scripts/language_depth.py runs the same analysis the tools run on one pinned public project per language and reports how much of it is connected. The first run found handlers that passed every test on their samples and still dropped edges on real code; all are fixed:
C++ (fmt) 1,603 calls without their caller → 0; definitions per file 49.4 → 74.7
C (jq) 600 → 0
Rust (ripgrep) 73 → 0
Go (cobra) files linked 0 % → 69 %
PHP (Slim) files linked 0 % → 76 %
C++ definitions inside macro-wrapped namespaces, behind a failed include guard or returning a pointer were not extracted; Rust functions nested in functions lost their calls; Go never resolved an import of the module's root package and read import blocks inside string literals; PHP ignored composer.json's PSR-4 prefixes. CONTRIBUTING.md now asks a new language to decide what an edge is before code is written, and to bring its row from a public corpus.
Project config read for import resolution (tsconfig.json, go.mod, composer.json) is looked up in one place and never above the repository the file is in, so another project's config around this one does not apply. TypeScript now finds a tsconfig.json beside a scanned src/.
Contract changes, named
- New languages add golden snapshots and hook-matrix rows; no existing language's output changed except C: the C sample's nested
struct AddressinsidePoolis now a structure, and the C feature goldens target it. sct callers <path> --ref Rtreats a path without an extension as a file when the ref holds one, as on disk.