Metadata-Version: 2.4
Name: semantic-complexity
Version: 0.0.24
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
Requires-Dist: click>=8.0
Requires-Dist: mcp>=1.25
Requires-Dist: rich>=13.0
Provides-Extra: all
Requires-Dist: numpy>=1.24; extra == 'all'
Requires-Dist: pyyaml>=6.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: numpy>=1.24; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: pyyaml>=6.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: numpy
Requires-Dist: numpy>=1.24; extra == 'numpy'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
Description-Content-Type: text/markdown

# semantic-complexity (Python)

Multi-dimensional code complexity analyzer for Python.

## Installation

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

### uv를 통한 설치

```bash
# 글로벌 도구로 설치
uv tool install semantic-complexity

# 또는 일회성 실행
uvx semantic-complexity path/to/file.py
```

## MCP 서버 설치

Claude Code에서 MCP 서버로 사용하려면:

```bash
# MCP 서버 추가 (Python 버전)
claude mcp add sc-py "uvx --from semantic-complexity semantic-complexity-py-mcp"
```

### 기존 MCP 업데이트/재설치

```bash
# 1. 기존 MCP 삭제
claude mcp remove sc-py

# 2. 캐시 정리 (최신 버전 반영)
uv cache clean semantic-complexity --force

# 3. 재설치
claude mcp add sc-py "uvx --from semantic-complexity semantic-complexity-py-mcp"

# 설치 확인
claude mcp list
```

## 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: {result.control}")
print(f"Nesting: {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}")
```

## Domains

| Domain | Weight | Description |
|--------|--------|-------------|
| Control (C) | 1.0 | Cyclomatic complexity (branches, loops) |
| Nesting (N) | 1.5 | Depth penalty |
| State (S) | 2.0 | State mutations and transitions |
| Async (A) | 2.5 | Async/await, coroutines |
| Coupling (Λ) | 3.0 | Hidden dependencies, side effects |

## License

MIT
