Software entropy measurement tool for Python projects
Project description
swent - Software Entropy Measurement Tool
swent analyzes Python projects to measure software entropy - a metric that quantifies code complexity, technical debt, and maintenance burden. Like other development tools (pytest, black, flake8), swent integrates into your development workflow to provide actionable feedback on code health.
Features
-
๐ Comprehensive Metrics: Analyzes multiple aspects of code quality
- Cyclomatic complexity
- Code duplication
- File and function sizes
- Dependency coupling
- Documentation coverage
- Test coverage integration
- Code churn and change frequency
-
๐ฏ Single Entropy Score: Combines all metrics into one actionable number
-
๐ฆ CI/CD Integration: Fail builds when entropy exceeds thresholds
-
๐ Trend Analysis: Track entropy changes over time
-
๐จ Rich CLI Output: Beautiful, informative terminal displays
Installation
pip install swent
For development:
git clone https://github.com/yourusername/swent.git
cd swent
pip install -e ".[dev]"
Quick Start
# Analyze current directory
swent .
# Analyze with detailed metrics
swent --verbose /path/to/project
# Generate comprehensive report
swent --report /path/to/project
# Set custom threshold
swent --threshold 0.7 .
# Output as JSON for CI/CD pipelines
swent --json . > entropy.json
# Exclude patterns
swent --exclude "**/tests/*" --exclude "**/docs/*" .
# Generate configuration file
swent --init
Understanding Software Entropy
Software entropy measures how "disordered" or difficult to maintain your code has become. A lower score is better:
- 0.0 - 0.3: โ Excellent - Clean, maintainable code
- 0.3 - 0.6: โ ๏ธ Warning - Consider refactoring problem areas
- 0.6 - 1.0: โ Poor - High technical debt, needs attention
Example Output
โญโ Software Entropy Analysis โโโฎ
โ Total Entropy: 0.423 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Summary Metrics
โโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโ
โ Metric โ Value โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ Total Files โ 127 โ
โ Total Lines โ 15423 โ
โ Average Complexity โ 3.42 โ
โ Code Duplication โ 2.3% โ
โ Test Coverage โ 87.5% โ
โ Documentation โ 64.2% โ
โ Technical Debt โ 18.5h โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโ
โ Entropy (0.423) is within threshold (0.600)
Configuration
swent automatically excludes common Python build artifacts (build/, dist/, *.egg-info/, etc.). You can customize behavior with a configuration file:
# Generate default configuration
swent --init
# Creates .swentrc.toml with all options
Example .swentrc.toml:
extend_default_excludes = true
exclude_patterns = ["vendor/", "legacy/"]
[entropy_thresholds]
good = 0.3
warning = 0.6
[weights]
complexity = 0.25
duplication = 0.20
# ... etc
See Configuration Guide for details.
CI/CD Integration
GitHub Actions
- name: Check Software Entropy
run: |
pip install swent
swent --threshold 0.6 .
Pre-commit Hook
repos:
- repo: https://github.com/yourusername/swent
rev: v0.1.0
hooks:
- id: swent
args: ['--threshold', '0.6']
Roadmap
- Language support beyond Python (JavaScript, Go, Rust)
- Historical entropy tracking and visualization
- IDE integrations (VS Code, PyCharm)
- Custom metric plugins
- Entropy prediction based on changes
Contributing
Contributions are welcome! Please see our Contributing Guide for details.
Credits
swent was developed with the assistance of Claude (Anthropic) and builds upon excellent open source libraries. See CREDITS.md for full acknowledgments.
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swent-0.1.0.tar.gz.
File metadata
- Download URL: swent-0.1.0.tar.gz
- Upload date:
- Size: 59.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3917772dc67e797f94b6e3b6c9a94f63442569848ff3450e65edb1935832e6b4
|
|
| MD5 |
203cb4f58d5be2e532bc0b4fc41fd48d
|
|
| BLAKE2b-256 |
fbf2c55045e0e41abc9f291596383d46c4819800d03692f9039dd45aa77959e5
|
File details
Details for the file swent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: swent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 39.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba01ab1ef7ebd378957ed8bcae39672ee3df15f717ee9694f44d5e484f07827c
|
|
| MD5 |
bab1cf0591bb4622d8fbcea890764496
|
|
| BLAKE2b-256 |
b0585813c75b89861b77df20885386841122bacaa38f7d90d1d571fbb04ff9f0
|