























@@ -520,6 +520,8 @@ def validate_report(report: dict[str, Any], repo: Path, changed_paths: set[str],
520520if not number_in_range(report.get("overall_confidence")):
521521raise SystemExit("review JSON overall_confidence must be numeric")
522522finding_text = ""
523+kept_findings: list[dict[str, Any]] = []
524+ignored_findings: list[tuple[int, dict[str, Any], str, int]] = []
523525for index, finding in enumerate(report["findings"]):
524526if not isinstance(finding, dict):
525527raise SystemExit(f"finding {index} must be an object")
@@ -554,8 +556,24 @@ def validate_report(report: dict[str, Any], repo: Path, changed_paths: set[str],
554556if Path(rel).is_absolute() or ".." in Path(rel).parts:
555557raise SystemExit(f"finding {index} uses invalid file path: {rel}")
556558if rel not in changed_paths:
557-raise SystemExit(f"finding {index} points to a file outside the reviewed change: {rel}")
559+ignored_findings.append((index, finding, rel, line))
560+continue
561+kept_findings.append(finding)
558562finding_text += "\n" + json.dumps(finding, sort_keys=True)
563+if ignored_findings:
564+for index, finding, rel, line in ignored_findings:
565+title = finding.get("title", "<untitled>")
566+print(
567+f"autoreview ignored out-of-scope finding {index}: {title} ({rel}:{line})",
568+file=sys.stderr,
569+ )
570+print(bounded_field(str(finding.get("body", "")), 500), file=sys.stderr)
571+report["findings"] = kept_findings
572+if not kept_findings and report["overall_correctness"] == "patch is incorrect":
573+note = f"Ignored {len(ignored_findings)} out-of-scope finding(s) outside the reviewed change."
574+explanation = report["overall_explanation"].rstrip()
575+report["overall_correctness"] = "patch is correct"
576+report["overall_explanation"] = bounded_field(f"{explanation}\n\n{note}", 3000)
559577haystack = finding_text.lower()
560578for needle in required:
561579if needle.lower() not in haystack:
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。