The quality gate for sustainable software architecture.
Sweet is a high-performance code health and architectural integrity analyzer. It is plug-and-play: it works immediately with zero configuration using intelligent defaults, while offering the flexibility to enforce stricter standards via .swtrc files.
By quantifying technical debt and identifying complex logic patterns, Sweet helps teams adhere to core engineering principles like SRP (Single Responsibility Principle) and DRY (Don't Repeat Yourself).
Most linters focus on syntax; Sweet focuses on maintainability. It acts as a surgical tool to prevent the "Big Ball of Mud" anti-pattern by monitoring the physical and logical weight of your components.
- Maintain Maintainability: Identify bloated files and excessive nesting that make code hard to reason about.
- Encourage Decoupling: Track dependency density to prevent tangled, hard-to-test modules.
- Prevent Logic Bloat: Detect deep nesting and cognitive complexity before they become technical debt.
- Eliminate Redundancy: Project-wide inspection to find duplicated logic across different files.
Sweet evaluates code health through four primary lenses of maintainability:
| Metric | Goal | Engineering Impact |
|---|---|---|
| Physical Weight | max_lines |
Prevents bloated files and encourages decomposition. |
| Control Flow | max_depth |
Flags excessive nesting to keep logic readable. |
| Coupling | max_imports |
Monitors dependency growth to prevent tangled architectures. |
| Repetition | max_repetition |
Identifies violations of the DRY principle. |
- Blazing Fast: Process thousands of files in seconds (scans the Linux Kernel in ~8.2s).
- Industrial-Grade Efficiency: Low RAM footprint via immediate buffer disposal and single-pass analysis.
- Zero-Copy Architecture: Byte-level scanner for maximum CPU cache efficiency.
- Hierarchical Config: Cascading
.swtrcfiles for directory-specific rule sets. - Global Awareness: (Optional) Detect duplicated logic across your entire project.
- Quality Guard: Native support for pre-push hooks to block "Bitter" code.
- Auto-Update: Built-in update system to keep your tool always sharp.
| Language | Status | Extension |
|---|---|---|
| Rust | β | .rs |
| Python | β | .py |
| JavaScript | β | .js, .mjs, .cjs, .jsx |
| TypeScript | β | .ts, .tsx |
| Java | β | .java |
| C# | β | .cs |
| GDScript | β | .gd |
| Lua | β | .lua |
| Go | β | .go |
| PHP | β | .php |
| C/C++ | β | .c, .cpp, .h, .hpp, .cc, .cxx |
Visit the Releases Page for native installers:
- Windows:
.msi - Linux:
.deb,.rpm
cargo install swtRun a standard health check:
swt [path]Find duplicated logic. By default, it checks within files; use --cross-file for project-wide analysis.
# Analyze repetition within each file
swt inspect [path]
# Analyze repetition across the entire project
swt inspect [path] --cross-fileAI Agents often generate verbose comments. Reclaim your logic:
swt uncomment <file> [--aggressive]Check or install new versions:
swt check-updates
swt updateSweet follows the Unix philosophy. It plays perfectly with the standard Rust toolbelt (fd, rg).
With fd:
Strip comments from every Rust file in your project at once.
fd -e rs -x swt uncommentWith ripgrep:
Target only the files that contain a specific "Bitter" pattern.
rg "TODO:" -l | xargs swt uncommentIf you are using GitHub Actions, you don't need to manually install Sweet. We've built Refinery-RS, a surgical quality gate and build pipeline for Rust projects.
Integrate Sweet with clippy and rustfmt in one single step:
jobs:
quality-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: sircesarium/refinery-rs/ci@main
with:
enable-sweet: true # Runs 'swt' maintainability analysis
enable-clippy: true # Runs standard Rust lints
enable-fmt: true # Ensures consistent formattingSweet resolves .swtrc files hierarchically.
{
"$schema": "https://raw.githubusercontent.com/SirCesarium/sweet/main/schema.json",
"cross_file_repetition": true,
"thresholds": {
"global": {
"max_lines": 400,
"max_depth": 5
},
"severities": {
"max-repetition": "warning"
}
}
}By default, all rule violations are treated as errors (causing a non-zero exit code). You can downgrade specific rules to warnings (informational only, exit code 0) in your .swtrc.
Disable specific checks via comments in the first 20 lines:
// @swt-disable max-lines max-repetition
Rules: max-lines, max-depth, max-imports, max-repetition.
To ignore a file entirely, use @sweetignore.
To demonstrate Sweet's performance, we benchmarked it against established tools on the entire Linux Kernel source tree (~64k files, 8.0 GB):
| Tool | Language | Primary Focus | Time (Linux Kernel) | Analysis Depth | Speed vs Sweet |
|---|---|---|---|---|---|
| Sweet (swt) | Rust | Arch. Health & Duplication | ~8.2s | Lines, Imports, Nesting, Duplication, Thresholds | N/A |
| Tokei | Rust | Raw Line Counting | ~2.1s | Lines, Comments, Blanks | 3.9x faster |
| cloc | Perl | Line Count (Industry Standard) | ~150s | Lines, Comments, Blanks, Language Breakdown | 18.3x slower |
| Lizard | Python | Cyclomatic Complexity | ~456s | Nesting Depth, Function Count | 55.6x slower |
Key Takeaways:
- Sweet provides high-fidelity architectural insights (nesting depth, import density, project-wide duplication) at speeds approaching raw data counters.
- The engine is designed to handle massive codebases in seconds, making it suitable for real-time quality gates in large-scale industrial environments.
See CONTRIBUTING.md for technical specifications and how to add new languages.
Licensed under the MIT License.
