Answer architecture round 1: make cognitive complexity a pure recursion, share a tied top-k cut evenly, count unresolved places, skip a run whose commit is gone, fail on a file that does not parse, link the history's format and its reader both ways, reword item 85's order, and record the worse ruling
This commit is contained in:
@@ -15,7 +15,9 @@ medians. Places that name no Python function or method, such as a section of a m
|
||||
counted as unmeasured.
|
||||
|
||||
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the
|
||||
history cannot be read, a run's commit is missing, or no scoring run names a measured unit.
|
||||
history cannot be read, a measured file does not parse, or no scoring run names a measured unit. A
|
||||
run whose commit the checkout lacks, such as a deleted branch's, is skipped and named below the
|
||||
table.
|
||||
"""
|
||||
import pathlib
|
||||
import subprocess
|
||||
@@ -23,7 +25,7 @@ import sys
|
||||
|
||||
from metric_bench.bench import bench, co_changed, medians, METRICS, RunScores, Score
|
||||
from failure import Failure
|
||||
from metric_bench.python_units import measured, python_units
|
||||
from metric_bench.python_units import measured, python_units, Unit
|
||||
from metric_bench.places import resolved, scoring_runs, ScoringRun
|
||||
|
||||
|
||||
@@ -45,15 +47,20 @@ def main(argv: list[str]) -> int:
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return failed(Failure(f"could not read {history}: {failure}"))
|
||||
rows = []
|
||||
gone = []
|
||||
for run in scoring_runs(text):
|
||||
if isinstance(git(["cat-file", "-e", f"{run.commit}^{{commit}}"], top), Failure):
|
||||
gone.append(run.heading)
|
||||
continue
|
||||
scores = run_scores(run, top)
|
||||
if isinstance(scores, Failure):
|
||||
return failed(scores)
|
||||
if scores:
|
||||
rows.append((run.heading, scores))
|
||||
skipped = "".join(f"\nSkipped, its commit is not in {top}: {heading}" for heading in gone)
|
||||
if not rows:
|
||||
return failed(Failure(f"no scoring run in {history} names a Python function or method the bench measures"))
|
||||
print(table(rows))
|
||||
return failed(Failure(f"no scoring run in {history} names a Python function or method the bench measures; its format: ~/.claude/skills/larv-review/SKILL.md → \"History\"{skipped}"))
|
||||
print(table(rows) + ("\n" + skipped if skipped else ""))
|
||||
return 0
|
||||
|
||||
|
||||
@@ -62,16 +69,20 @@ def run_scores(run: ScoringRun, top: str) -> RunScores | None | Failure:
|
||||
if isinstance(listed, Failure):
|
||||
return listed
|
||||
tracked = listed.split("\n")
|
||||
units = []
|
||||
units: list[Unit] = []
|
||||
for path in filter(measured, tracked):
|
||||
source = git(["show", f"{run.commit}:{path}"], top)
|
||||
if isinstance(source, Failure):
|
||||
return source
|
||||
units += python_units(path, source)
|
||||
found = python_units(path, source)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
units += found
|
||||
log = git(["log", "--no-merges", "--format=format:@@", "--name-only", run.commit], top)
|
||||
if isinstance(log, Failure):
|
||||
return log
|
||||
return bench(units, resolved(run.places, tracked), co_changed(log))
|
||||
places = resolved(run.places, tracked)
|
||||
return bench(units, places, len(run.places) - len(places), co_changed(log))
|
||||
|
||||
|
||||
def table(rows: list[tuple[str, RunScores]]) -> str:
|
||||
|
||||
Reference in New Issue
Block a user