swt 3.0.0

๐Ÿฌ Sweet: A blazing-fast code health and architecture analyzer.
Documentation

๐Ÿฌ Sweet (swt)

Crates.io License: MIT Build Status

Turn code maintainability into a measurable metric.

Sweet is a blazing-fast code health analyzer designed to keep project architectures lean and sustainable. It identifies technical debt, tangled dependencies, and complex logic patterns.


๐Ÿญ The Sweet Index

Sweet evaluates source files against configurable health thresholds.

Status Meaning Action
Sweet ๐Ÿญ Balanced, cohesive, and easy to maintain. Keep it up!
Bitter ๐Ÿ‹ Overly complex, high coupling, or high repetition. Refactor recommended.

โœจ Key Features

  • ๐Ÿš€ Blazing Fast: Process thousands of files in milliseconds (e.g., self-analysis in <10ms).
  • ๐Ÿ“ Hierarchical Config: Support for multiple .swtrc files to define specific rules for different subdirectories.
  • ๐Ÿ” Global Inspection: Detect code duplication across the entire project with detailed reporting.
  • ๐Ÿ›ก๏ธ Quality Guard: Built-in support for git hooks to prevent "Bitter" code from being pushed.
  • ๐Ÿงน Source Cleanup: Professional comment stripping and whitespace normalization.

๐Ÿ“Š Supported Languages

Language Extension Import Style Comment Style
Rust .rs use //, /* */
Python .py import, from #
JavaScript .js, .mjs, .cjs import, require //, /* */
TypeScript .ts, .tsx import //, /* */
Java .java import //, /* */
C# .cs using //, /* */

๐Ÿ› ๏ธ Installation

cargo install swt

๐Ÿ“– Usage

Analyze Project

swt .

Global Inspection

Show exact code fragments repeated across different files:

swt . --inspect

Strip Comments

swt --uncomment src/lib.rs --aggressive

โš™๏ธ Configuration

Sweet resolves .swtrc files hierarchically.

{
  "$schema": "https://raw.githubusercontent.com/SirCesarium/sweet/main/schema.json",
  "thresholds": {
    "global": { 
      "max_lines": 250, 
      "max_depth": 5, 
      "max_repetition": 10.0,
      "min_duplicate_lines": 4
    },
    "overrides": {
      "rust": { "max_imports": 15 }
    }
  }
}

๐Ÿค Contributing

Contributions are welcome! Whether it's adding support for a new language, fixing a bug, or improving the documentation, please check our Contributing Guide to get started.


๐Ÿ“œ License

Licensed under the MIT License.