Metadata-Version: 2.4
Name: wayward-eagle
Version: 0.4.0
Summary: Lower the cognitive complexity of C function bodies, keeping what they do, and census C readability defects
Author: Josh Bailey
License: Apache-2.0
Project-URL: Repository, https://github.com/anarkiwi/wayward-eagle
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: POSIX :: Linux
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: clang-format==23.1.5
Requires-Dist: clang-tidy==23.1.4
Requires-Dist: orjson==3.13.0
Requires-Dist: pycparser==3.12
Requires-Dist: pyyaml==6.0.3
Requires-Dist: tqdm>=4
Requires-Dist: ziglang==0.17.1
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-xdist; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: pylint; extra == "dev"
Dynamic: license-file

# wayward-eagle

Lowers the cognitive complexity (SonarSource's metric, as clang-tidy's
`readability-function-cognitive-complexity` counts it) of C functions, as pycparser `c_ast`
or as statement trees, keeping what each function does. Each rewrite is made only where it
lowers the cost. `wayward-eagle reduce FILE.c [-o OUT.c] [-I DIR]` reduces every function of
a C file.

```python
from wayward_eagle import Function, reduced

pieces, sections, temps = reduced(body, "f", Function(params=["a"], local={"v1", "v2"}, void=True))
for piece in pieces:
    ...  # print each function: piece.name, piece.args, piece.items, piece.ret
```

- [C layer](docs/c.md): `wayward_eagle.c.load` reads C through a pinned clang into `c_ast`
  with clang's types, implicit casts, declarations and source ranges; queries, rendering
  and `reduce_function`.
- [Statement trees](docs/trees.md): the tuple input and output of `reduced`.
- [Rewrites](docs/rewrites.md): what each rewrite does and when it applies.
- [Census](docs/census.md): `wayward-eagle census FILE.c... [-I DIR] [--json]` lists C's
  readability defects by class (clang-tidy's checks and checks over clang's AST, keyed to a
  decompiler-fidelity taxonomy), and the `wayward-census` virtuous-cycles adapter ratchets them.

Install: `pip install wayward-eagle`. Development: `pip install -e .[dev]`, then
`pytest -n auto --cov=wayward_eagle`.
