How kornysietsma/polyglot-code-scanner works
Project Type and Purpose
• This is a stand-alone, command-line application written in Rust.
• It scans a source-code directory (and optional Git history) to compute code metrics and emits a JSON report for downstream visualization in the Polyglot Code Explorer.
High-Level Components
Based on your file tree and README, the main components are:
a. Input Sources
• File system (source code files, .polyglot_code_scanner_ignore, .gitignore)
• Git repositories (optional, controlled by --no-git / --years flags)
b. CLI & Configuration
• main.rs – argument parsing, entry point
• Global config (.gitignore logic, custom ignore files, flags)
c. Core Library (in src/lib.rs + submodules)
• FileWalker (file_walker.rs): enumerates files, applies ignore rules
• FileStats (file_stats.rs), CodeLineData (code_line_data.rs), LOC (loc.rs), Indentation (indentation.rs): per-file metrics
• Coupling (coupling.rs) and Toxicity (toxicity_indicator_calculator.rs): cross-file and indicator analysis
• Git integration (git.rs, git_file_history.rs, etc.): harvests commit data, renames, merges
• Flare exporter (flare.rs / postprocessing.rs): transforms raw metrics into the “flare” JSON format
d. Output
• JSON file (or stdout) conforming to the Explorer’s schema
e. Testing & CI
• test_shared crate + tests/ folder: unit + integration tests with sample data
• GitHub Actions workflows (.github/workflows/*.yml): cross-platform build, test, release
Architectural Patterns & Principles
• Layered Architecture:
• Presentation/CLI layer (main.rs)
• Application Core (modular library for scanning, parsing, metrics)
• Infrastructure: file system, Git CLI or library, JSON writer
• Single-binary deployment: all modules are compiled into one Rust executable
• Configuration by convention: reuse .gitignore parsing logic, add custom ignore files