Metadata-Version: 2.4
Name: agentic-crap-py
Version: 1.0.0
Summary: Function-level CRAP analysis for Python using LCOV coverage.
Author: Retkmin
License: MIT License
        
        Copyright (c) 2026 Retkmin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/Retkmin/agentic-crap-py
Project-URL: Repository, https://github.com/Retkmin/agentic-crap-py
Project-URL: Issues, https://github.com/Retkmin/agentic-crap-py/issues
Keywords: crap,complexity,coverage,lcov,python
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# agentic-crap-py

Analyze function-level CRAP scores for Python using LCOV line coverage.

## Quick start

```sh
python -m pip install agentic-crap-py
agentic-crap-py --source src --lcov coverage/lcov.info --threshold 10
```

For a local checkout, run `python -m pip install .` and then `agentic-crap-py --source src --lcov coverage/lcov.info`.

## Coverage generation

Pass coverage generation as a JSON argv array. It is executed directly without a shell, so shell syntax, pipelines, and interpolation are intentionally not supported.

```sh
agentic-crap-py --source src --coverage-command '["python","-m","coverage","lcov","-o","coverage/lcov.info"]' --lcov coverage/lcov.info --json
```

An existing LCOV file is removed before this command runs. The command must create the requested LCOV file or analysis fails, preventing stale coverage from being accepted.

## Output and exit codes

Use `--json` for deterministic compact JSON, sorted by file, line, and function.

| Exit code | Meaning |
| --- | --- |
| `0` | Every selected function has coverage and is within the threshold. |
| `1` | A CRAP score exceeds the threshold. |
| `2` | Coverage is missing, malformed, unmapped, or analysis cannot run. |

## Score

For cyclomatic complexity `CC` and line coverage ratio `C`, the score is:

```text
CRAP = CC^2 * (1 - C)^3 + CC
```

Nested function bodies are excluded from an enclosing function's coverage and complexity calculation. A function with no mapped LCOV lines is reported as `N/A` and fails rather than passing.

## Development

```sh
python -m unittest discover -s tests -v
```

Python 3.10 or newer is required. The runtime uses only the Python standard library; generate LCOV using the coverage tooling already used by your project.
