feat: 接入模板诊断人工审阅登记
This commit is contained in:
1 parent
f57e1b1336
commit
d2ce2d2a84
4 files changed
+113
-3
No files matched your search
@@ -372,3 +372,38 @@ export function diagnoseTemplate(manifest, source, file = "taro/index.tsx") {
|
||||
issues,
|
||||
};
|
||||
}
|
||||
|
||||
const REVIEW_KEY_FIELDS = ["file", "page", "target", "binding", "line", "message"];
|
||||
|
||||
function reviewKey(item) {
|
||||
return JSON.stringify(
|
||||
Object.fromEntries(REVIEW_KEY_FIELDS.map((key) => [key, item[key] ?? null])),
|
||||
);
|
||||
}
|
||||
|
||||
export function applyManualReview(reports, reviews, reviewScope) {
|
||||
if (reviewScope !== "人工映射审查,保留原诊断,不是自动豁免或全条件组合证明")
|
||||
throw new Error("Manual review registry has an unsupported scope");
|
||||
const byKey = new Map();
|
||||
for (const item of reviews) {
|
||||
if (item.severity !== "review" || item.reviewStatus !== "source-reviewed" || !item.decision)
|
||||
throw new Error("Manual review registry contains an invalid entry");
|
||||
byKey.set(reviewKey(item), item);
|
||||
}
|
||||
for (const report of reports) {
|
||||
let unresolved = 0;
|
||||
report.issues.forEach((issue) => {
|
||||
const reviewed = issue.severity === "review" && byKey.get(reviewKey(issue));
|
||||
if (reviewed) issue.reviewStatus = "source-reviewed";
|
||||
else unresolved++;
|
||||
});
|
||||
report.reviewedIssues = report.issues.length - unresolved;
|
||||
report.unresolvedIssues = unresolved;
|
||||
report.staticStatus = report.issues.some(
|
||||
(issue) => issue.severity === "blocker" || issue.reviewStatus !== "source-reviewed",
|
||||
)
|
||||
? "fail"
|
||||
: "pass";
|
||||
}
|
||||
return reports;
|
||||
}
|
||||
Reference in new issue
Block a user