swt 2.0.1

๐Ÿฌ 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 
    },
    "overrides": {
      "rust": { "max_imports": 15 }
    }
  },
  "ui": {
    "lemon_threshold": 200,
    "bitter_threshold": 400
  }
}

๐Ÿ“œ License

Licensed under the MIT License.