diff --git a/src/code_path_audit.py b/src/code_path_audit.py index 9b69ed50..40475ced 100644 --- a/src/code_path_audit.py +++ b/src/code_path_audit.py @@ -735,36 +735,6 @@ def find_enclosing_function( return None return max(candidates, key=lambda r: r.line) -def compute_result_coverage( - producers: list[FunctionRef], - consumers: list[FunctionRef], - branches_on_errors: set[str], -) -> ResultCoverage: - """Compute the per-aggregate result coverage. - - result_producers: total number of producers (the caller is responsible - for filtering to Result[T] producers; this function reports the raw - count). - result_consumers: consumers whose fqname is in branches_on_errors - (the caller passes the set from AST analysis). - """ - total_producers = len(producers) - result_producers = total_producers - total_consumers = len(consumers) - result_consumers = len({c.fqname for c in consumers if c.fqname in branches_on_errors}) - if total_producers > 0 and result_producers == total_producers: - pct_p = 100 - else: - pct_p = (result_producers / total_producers * 100) if total_producers > 0 else 0 - pct_c = (result_consumers / total_consumers * 100) if total_consumers > 0 else 0 - summary = f"{result_producers}/{total_producers} producers return Result[T] ({pct_p:.0f}%); {result_consumers}/{total_consumers} consumers branch on .errors ({pct_c:.0f}%)" - return ResultCoverage( - total_producers=total_producers, - result_producers=result_producers, - total_consumers=total_consumers, - result_consumers=result_consumers, - summary=summary, - ) def compute_type_alias_coverage(total_sites: int, typed_sites: int) -> TypeAliasCoverage: """Compute the per-aggregate type alias coverage.""" diff --git a/tests/test_code_path_audit_phase78.py b/tests/test_code_path_audit_phase78.py index 7fdde391..daf93df0 100644 --- a/tests/test_code_path_audit_phase78.py +++ b/tests/test_code_path_audit_phase78.py @@ -63,7 +63,6 @@ from src.code_path_audit import ( read_input_json, INPUT_JSON_CONTRACTS, find_enclosing_function, - compute_result_coverage, compute_type_alias_coverage, aggregate_cross_audit_findings, run_all_cross_audit_reads, @@ -123,28 +122,7 @@ def test_find_enclosing_function_no_match() -> None: result = find_enclosing_function(file="src/y.py", line=15, function_refs=refs) assert result is None -def test_compute_result_coverage_no_producers() -> None: - """compute_result_coverage returns 0/0 when there are no producers.""" - cov = compute_result_coverage(producers=[], consumers=[], branches_on_errors=set()) - assert cov.total_producers == 0 - assert cov.result_producers == 0 - assert cov.total_consumers == 0 - assert cov.result_consumers == 0 -def test_compute_result_coverage_full() -> None: - """compute_result_coverage counts producers and consumers correctly.""" - f1 = FunctionRef(fqname="src.a", file="src/a.py", line=1, role="producer") - f2 = FunctionRef(fqname="src.b", file="src/b.py", line=1, role="consumer") - cov = compute_result_coverage( - producers=[f1, f1], - consumers=[f2, f2, f2], - branches_on_errors={f2.fqname}, - ) - assert cov.total_producers == 2 - assert cov.result_producers == 2 - assert cov.total_consumers == 3 - assert cov.result_consumers == 1 - assert "100%" in cov.summary def test_compute_type_alias_coverage_no_sites() -> None: """compute_type_alias_coverage returns 0/0/0 when there are no sites."""