Skip to main content

Software entropy measurement tool for Python projects

Project description

swent - Software Entropy Measurement Tool

PyPI version Python 3.8+ License: MIT Downloads Code style: black

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swent-0.1.0.tar.gz (59.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swent-0.1.0-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

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

Hashes for swent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3917772dc67e797f94b6e3b6c9a94f63442569848ff3450e65edb1935832e6b4
MD5 203cb4f58d5be2e532bc0b4fc41fd48d
BLAKE2b-256 fbf2c55045e0e41abc9f291596383d46c4819800d03692f9039dd45aa77959e5

See more details on using hashes here.

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

Hashes for swent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba01ab1ef7ebd378957ed8bcae39672ee3df15f717ee9694f44d5e484f07827c
MD5 bab1cf0591bb4622d8fbcea890764496
BLAKE2b-256 b0585813c75b89861b77df20885386841122bacaa38f7d90d1d571fbb04ff9f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page