Bounded language scan over a directory tree.
Walks the tree with Files/walkFileTree, skipping common
non-source subdirectories (.git, node_modules, target, ...)
via FileVisitResult/SKIP_SUBTREE. Counts files and bytes per
language using a small extension-to-language map.
The walk has TWO hard guards: a max-file count and a wall-time
deadline. Either one stops the walk via TERMINATE. Callers get
a possibly-partial result; on a small repo the result is exact.
No third-party deps. Reflection-clean.
Bounded language scan over a directory tree. Walks the tree with `Files/walkFileTree`, skipping common non-source subdirectories (`.git`, `node_modules`, `target`, ...) via `FileVisitResult/SKIP_SUBTREE`. Counts files and bytes per language using a small extension-to-language map. The walk has TWO hard guards: a max-file count and a wall-time deadline. Either one stops the walk via `TERMINATE`. Callers get a possibly-partial result; on a small repo the result is exact. No third-party deps. Reflection-clean.
(scan root)(scan root
{:keys [max-files deadline-ms]
:or {max-files default-max-files deadline-ms default-deadline-ms}})Walk root (a java.io.File or java.nio.file.Path), counting
files and bytes per language. Returns a map:
{:total-files N :total-bytes N :truncated? bool ;; true when max-files or deadline tripped :elapsed-ms N :primary "clojure" ;; nil when no source detected :languages [{:language :files :bytes :files-pct :bytes-pct} ...]}
Languages are sorted by total bytes descending. :primary is the
first entry's :language (max-bytes wins).
Options: :max-files soft cap on visited files (default 10000). :deadline-ms wall-time cap in ms (default 1000).
Walk `root` (a `java.io.File` or `java.nio.file.Path`), counting
files and bytes per language. Returns a map:
{:total-files N
:total-bytes N
:truncated? bool ;; true when max-files or deadline tripped
:elapsed-ms N
:primary "clojure" ;; nil when no source detected
:languages [{:language :files :bytes :files-pct :bytes-pct} ...]}
Languages are sorted by total bytes descending. `:primary` is the
first entry's `:language` (max-bytes wins).
Options:
:max-files soft cap on visited files (default 10000).
:deadline-ms wall-time cap in ms (default 1000).cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |