Findings
findings
Audit finding ingestion + canonical-filename computation.
Wraps audit_project to surface FILE_NAMING / PYRAMID_LEVEL findings
normalised as list[dict] with absolute paths, and exposes the
per-test canonical-filename machinery (func_canonical,
per_unit_canonical, _class_needs_flatten) that consumes the
audit's own _shared helpers.
collect_unfixable lives here too: it re-audits post-pipeline to
report NO_PACKAGE_SYMBOL leftovers + pathological FILE_NAMING SPLIT
victims the proto can't auto-fix.
check_by_rule(project_path, rule_id)
Run the test_quality audit and return findings for rule_id.
The returned dicts have their path / test_file / files
entries rewritten as absolute paths anchored at project_path so
downstream planners can compare them with their own Path objects.
Source code in packages/axm-audit/src/axm_audit/core/fix/findings.py
class_needs_flatten(cls, tree, *, tier, pkg_prefixes, scripts, single_binary)
True iff this class's methods have ≥2 distinct canonical filenames.
Source code in packages/axm-audit/src/axm_audit/core/fix/findings.py
collect_unfixable(project_path)
Re-audit and return NO_PACKAGE_SYMBOL + pathological FILE_NAMING findings.
Defensive: post-apply, axm-audit's internal AST cache may hold stale paths if files were renamed in-flight. Swallow that exception — the caller (proto reporter) treats absence as "no unfixable findings".
Pathological FILE_NAMING cases: a Test* class with divergent
canonicals AND a feature (self.<x>, custom base, __init__)
that blocks deterministic flattening. Surfaced as unfixable so the
user invokes /scenario-rename or rewrites by hand instead of
silently leaving the SPLIT finding unresolved.
Source code in packages/axm-audit/src/axm_audit/core/fix/findings.py
func_canonical(func, tree, *, tier, pkg_prefixes, scripts, single_binary)
Canonical filename a single test function would land in.
Source code in packages/axm-audit/src/axm_audit/core/fix/findings.py
get_pkg_prefixes(pkg_root)
Return top-level package directory names under <pkg_root>/src.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkg_root
|
Path
|
Repository root expected to follow the |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Set of directory names directly under |
set[str]
|
entries. Empty when |
Source code in packages/axm-audit/src/axm_audit/core/rules/test_quality/_shared.py
normalize_findings(check)
Normalise a CheckResult's findings into a list[dict].
Source code in packages/axm-audit/src/axm_audit/core/fix/findings.py
per_unit_canonical(source, tier, project_path)
For each movable unit, compute its canonical filename.
A movable unit is
- a top-level test_* function (anvil moves it directly), OR
- a Test* class whose methods all share the same tuple (anvil moves the class as a block).
Test* classes with divergent method tuples are NOT a single unit — the caller should flatten them first (Stage 0) and re-run.
Returns {canonical_name: [unit_names]}.