Metadata-Version: 2.4
Name: semantic-complexity
Version: 0.0.3
Summary: Multi-dimensional code complexity analyzer
Project-URL: Homepage, https://github.com/yscha88/semantic-complexity
Project-URL: Repository, https://github.com/yscha88/semantic-complexity
Project-URL: Issues, https://github.com/yscha88/semantic-complexity/issues
Author-email: yscha88 <clmfkilu@gmail.com>
License: MIT
Keywords: code-analysis,cognitive,complexity,cyclomatic,metrics
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# semantic-complexity (Python)

Multi-dimensional code complexity analyzer for Python.

## Installation

```bash
pip install semantic-complexity
```

## Usage

### CLI

```bash
# Analyze a file
semantic-complexity path/to/file.py

# Analyze a directory
semantic-complexity path/to/project/

# Output as Markdown report
semantic-complexity path/to/project/ -f markdown -o report.md

# Filter by threshold
semantic-complexity path/to/project/ --threshold 20
```

### Python API

```python
from semantic_complexity import analyze_source, analyze_functions

# Analyze source code
result = analyze_source("""
def complex_function(x):
    if x > 0:
        for i in range(x):
            if i % 2 == 0:
                print(i)
""")

print(f"Weighted complexity: {result.weighted}")
print(f"Control (1D): {result.control}")
print(f"Nesting (2D): {result.nesting}")
print(f"Contributions: {result.contributions}")

# Analyze functions individually
functions = analyze_functions(source)
for fn in functions:
    print(f"{fn.name}: McCabe={fn.cyclomatic}, Dimensional={fn.dimensional.weighted}")
```

## Dimensions

| Dimension | Weight | Description |
|-----------|--------|-------------|
| 1D Control | 1.0 | Cyclomatic complexity (branches, loops) |
| 2D Nesting | 1.5 | Depth penalty |
| 3D State | 2.0 | State mutations and transitions |
| 4D Async | 2.5 | Async/await, coroutines |
| 5D Coupling | 3.0 | Hidden dependencies, side effects |

## License

MIT
