From 2c44bb68598fce0fa10f6eb504f718e61d161e02 Mon Sep 17 00:00:00 2001 From: le king fu Date: Sun, 25 Oct 2026 19:26:55 -0400 Subject: [PATCH] chore(review): stop counting a removed network call as high adds_network_call now reads only the new side of each hunk (context and added lines): removing a fetch, a base URL constant or a config field no longer makes a PR high. The Haut table only names an added call or a change to what an existing call sends; the script was stricter. Calibration replayed on #14-#161: same level for every PR. Refs #143 Co-Authored-By: Claude Opus 5.5 --- REVIEW.md | 2 +- scripts/review-levels.py | 42 +++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/REVIEW.md b/REVIEW.md index e723cca..d78e342 100644 --- a/REVIEW.md +++ b/REVIEW.md @@ -63,7 +63,7 @@ Tout le reste : écrans et composants de l'app et du site, traductions (`src/i18 Rejouée le 2026-10-19 (#140) sur les 47 PR mergées de #14 à #138, avec `scripts/review-levels.py` (API Forgejo, lecture seule) ; `python3 scripts/review-levels.py --check` vérifie, sans réseau, que ses motifs sont ceux du tableau Haut, chacun dans sa classe (« toujours » ou sous condition). -Rejouée le 2026-10-25 (#143) sur les mêmes PR, après la lecture des `fetch(` sur deux lignes et du classement par condition : niveau identique PR par PR, aucun écart. De #139 à #161 (11 PR mergées), aucun écart non plus entre le script d'avant et celui-ci. +Rejouée le 2026-10-25 (#143) sur les mêmes PR, après la lecture des `fetch(` sur deux lignes, du classement par condition, et sans plus compter le retrait d'un appel réseau (décision de Max du 2026-10-25, `/pr-brief` de la PR #163) : niveau identique PR par PR, aucun écart. De #139 à #161 (11 PR mergées), aucun écart non plus entre le script d'avant et celui-ci. | Ensemble | Bas | Normal | Haut | |---|---|---|---| diff --git a/scripts/review-levels.py b/scripts/review-levels.py index d8a9344..ce8a980 100755 --- a/scripts/review-levels.py +++ b/scripts/review-levels.py @@ -25,8 +25,9 @@ a new version), all read as JSON at the merge base and at the merge commit; network calls (fetch to an absolute URL, or a base URL held by a constant or a config field, in shipped code). A fetch( split over two lines counts when either line is changed, the other one being changed or context (#143); a -blank or comment line between the two breaks the pair. Removed lines count -like added ones. +blank or comment line between the two breaks the pair. Only the new side of +the diff is read: removing a call does not make a PR high (decision of Max, +2026-10-25, /pr-brief of PR #163). """ import itertools import json @@ -212,34 +213,31 @@ def app_json_beyond_version(merge_base, merged_sha): FETCH_RE = re.compile(r"fetch\(\s*[`'\"]https?://") -BASE_URL_RE = re.compile(r"(?:\b(?:const|let|var)\s+\w+\s*=|^[+-]\s*\w+\s*:)\s*[`'\"]https?://") +BASE_URL_RE = re.compile(r"(?:\b(?:const|let|var)\s+\w+\s*=|^\+\s*\w+\s*:)\s*[`'\"]https?://") def adds_network_call(path, block): if not match(SHIPPED, path) or re.search(r"test", path): return False for hunk in re.split(r"(?m)^(?=@@)", block)[1:]: - lines = [l for l in hunk.split("\n")[1:] if l[:1] in " +-"] - # each side of the hunk: the new file (context and added lines), then - # the old one (context and removed lines) - for mark in "+-": - side = [l for l in lines if l[:1] in (" ", mark)] - for i, l in enumerate(side): - if l[:1] != mark or not meaningful(l[1:]): + # the new side of the hunk: context and added lines + side = [l for l in hunk.split("\n")[1:] if l[:1] in " +"] + for i, l in enumerate(side): + if l[:1] != "+" or not meaningful(l[1:]): + continue + # fetch to an absolute URL, or a base URL held by a constant or a + # config field (a link in markup, href=..., does not count). The + # base URL regex reads the raw line, its prefix anchors the field. + if FETCH_RE.search(l[1:]) or BASE_URL_RE.search(l): + return True + # a fetch( split over two lines: the neighbour, added or context, + # must not match on its own + for a, b in ((side[i - 1] if i else None, l), (l, side[i + 1] if i + 1 < len(side) else None)): + if a is None or b is None: continue - # fetch to an absolute URL, or a base URL held by a constant or a - # config field (a link in markup, href=..., does not count). The - # base URL regex reads the raw line, its prefix anchors the field. - if FETCH_RE.search(l[1:]) or BASE_URL_RE.search(l): + other = b if a is l else a + if FETCH_RE.search(a[1:].strip() + " " + b[1:].strip()) and not FETCH_RE.search(other[1:]): return True - # a fetch( split over two lines: the neighbour, changed or - # context, must not match on its own - for a, b in ((side[i - 1] if i else None, l), (l, side[i + 1] if i + 1 < len(side) else None)): - if a is None or b is None: - continue - other = b if a is l else a - if FETCH_RE.search(a[1:].strip() + " " + b[1:].strip()) and not FETCH_RE.search(other[1:]): - return True return False