# ๐ฌ Sweet (swt)
[](https://crates.io/crates/swt)
[](https://opensource.org/licenses/MIT)
[](https://github.com/SirCesarium/sweet/actions)
**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.
| **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
| **Rust** | `.rs` | `use` | `//`, `/* */` |
| **Python** | `.py` | `import`, `from` | `#` |
| **JavaScript** | `.js`, `.mjs`, `.cjs` | `import`, `require` | `//`, `/* */` |
| **TypeScript** | `.ts`, `.tsx` | `import` | `//`, `/* */` |
| **Java** | `.java` | `import` | `//`, `/* */` |
| **C#** | `.cs` | `using` | `//`, `/* */` |
---
## ๐ ๏ธ Installation
```bash
cargo install swt
```
---
## ๐ Usage
### Analyze Project
```bash
swt .
```
### Global Inspection
Show exact code fragments repeated across different files:
```bash
swt . --inspect
```
### Strip Comments
```bash
swt --uncomment src/lib.rs --aggressive
```
---
## โ๏ธ Configuration
`Sweet` resolves `.swtrc` files hierarchically.
```json
{
"$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](./LICENSE).