loc-rs-0.1.7 is not a library.
loc — Advanced Lines of Code Counter
A fast, feature-rich LOC tool written in Rust.
Author: kelexine
Features
- Minimalist Dashboard: Clean, borderless summary of all project metrics
- Code/Comment/Blank split: Distinguishes between actual code, comments, and blank lines across dozens of languages
- Optional Tree view: Recursive directory tree with per-file metrics (now opt-in via
--tree) - Parallel scanning via Rayon — uses all CPU cores
- Function extraction for 10 languages including Rust, Python, JS, Go, PHP, Swift, Ruby, and Nim
- Cyclomatic complexity estimates per function
- Git integration — respects
.gitignoreand.locignore, optionalgit logdates - Interactive HTML Dashboard — beautiful visual reports (
loc -e report.html) - Multi-format export — JSON, JSONL, CSV, HTML
- Global Configuration via
~/.config/loc-rs/config.toml - GitHub Action wrapper included for CI/CD integration
- 35+ languages supported with aliases
- Size warnings for oversized files
- BOM-aware binary detection for UTF-16/32 text files
Installation
From cargo
From source (requires Rust ≥ 1.9.0)
# Binary at: ./target/release/loc
# Install globally
Usage
loc [OPTIONS] [DIRECTORY]
Examples
All Flags
| Flag | Short | Description |
|---|---|---|
--detailed |
-d |
Per-extension breakdown (Code, Comment, Blank) |
--tree |
Show recursive directory tree (hidden by default) | |
--binary |
-b |
Show binary files in tree |
--functions |
-f |
Extract functions, methods, classes |
--func-analysis |
Full analysis report (auto-enables -f) |
|
--type LANG... |
-t |
Filter by language(s) |
--export FILE |
-e |
Export results (.json / .jsonl / .csv / .html) |
--warn-size N |
Warn for files exceeding N lines | |
--git-dates |
Use git log for last-modified dates |
|
--include-hidden |
-H |
Include hidden files and directories |
--no-parallel |
Disable Rayon parallelism |
Configuration
You can persist your default arguments globally in ~/.config/loc-rs/config.toml (or your OS's equivalent standard config directory).
= 500
= ["rust", "python"]
= true
GitHub Action Integration
Drop loc-rs into your CI/CD pipelines to monitor complexity and line counts.
steps:
- uses: actions/checkout@v4
- uses: kelexine/loc-rs/.github/actions/loc-rs@main
with:
target_dir: .
warn_size: 500
functions: true
Supported Languages
| Name | Extensions |
|---|---|
rust |
.rs |
python |
.py .pyw .pyi |
javascript |
.js .mjs .cjs |
typescript |
.ts .tsx .mts |
go |
.go |
java |
.java |
kotlin |
.kt .kts |
c |
.c .h |
cpp |
.cpp .cc .cxx .hpp |
csharp |
.cs |
swift |
.swift |
ruby |
.rb |
php |
.php |
html |
.html .htm |
css |
.css .scss .sass .less |
shell |
.sh .bash .zsh .fish |
markdown |
.md .markdown .mdx |
json |
.json .jsonl |
yaml |
.yml .yaml |
toml |
.toml |
xml |
.xml |
vue |
.vue |
svelte |
.svelte |
scala |
.scala .sc |
haskell |
.hs .lhs |
elixir |
.ex .exs |
lua |
.lua |
dart |
.dart |
zig |
.zig |
nim |
.nim .nims |
Language aliases are supported: py, js, ts, rs, rb, sh, md, yml, c++, etc.
Function Extraction Support
| Language | Functions | Methods | Classes/Structs | Async | Decorators | Docstrings |
|---|---|---|---|---|---|---|
| Rust | ✓ | ✓ | ✓ (struct/impl) | ✓ | pub flag | — |
| Python | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| JavaScript/TS | ✓ | ✓ | ✓ | ✓ | — | — |
| Go | ✓ | ✓ | — | — | — | — |
| C/C++ | ✓ | — | — | — | — | — |
| Java/Kotlin/C# | ✓ | ✓ | — | — | — | — |
| PHP | ✓ | ✓ | ✓ | — | — | — |
| Swift | ✓ | ✓ | ✓ | ✓ | — | — |
| Ruby | ✓ | ✓ | ✓ | — | — | — |
| Nim | ✓ | ✓ | — | — | public(*) flag | — |
License
MIT © kelexine