Skip to content
winlogon edited this page Nov 5, 2025 · 4 revisions

Welcome! This is the quick, practical landing page for the clocscan wiki.

If you already read the README, consider this a compact reference you can use while digging into the code or contributing.

What clocscan is (tl;dr)

clocscan is a fast, asynchronous lines-of-code counter written in Rust. It traverses a directory tree, filters files by extension, skips configured ignores, and counts SLOC (non-empty, non-comment lines). It tries to be much faster than cloc by using async traversal and non-blocking file IO.

Quick start

Build (and run):

# build a release binary
cargo build --release
# or use cargo run for quick runs
cargo run --release -- /path/to/project

Full usage is in the README; this wiki focuses on internal structure, notes for contributors, and setting up clocscan (configuration).

How it works (high level overview)

  1. CLI parsing: clap parses arguments.
  2. Logging: A logger is initialized according to -v verbosity count.
  3. Load config: clocscan tries to read ./config.json (if it's not found or somehow unaccessible, it falls back to a default config).
  4. Choose extensions: CLI -e overrides config; otherwise extensions from the JSON are used.
  5. Build file regex: a regex like .*\.(rs|py|c)$ is created to match code files.
  6. Directory walk: the specified folder is walked, yielding entries asynchronously.
  7. Ignore checks: each path is checked against the configuration to ensure it's not ignored.
  8. File processing: matching files are opened, read line-by-line, and the contents are passed through a filter to ignore comments/empty lines.
  9. Accumulate stats: Per-extension counts are collected; and a pretty table showing the results is printed.

NOTE: Docs for the code are published as rustdoc pages at https://walker84837.github.io/clocscan/.

Where to go next in this Wiki

Clone this wiki locally