fix: reduce board audit noise
This commit is contained in:
+56
-3
@@ -1279,10 +1279,60 @@ function extractIssueNumbers(text: string): number[] {
|
||||
return numbers;
|
||||
}
|
||||
|
||||
function cellHasMeaningfulValue(value: string | undefined): boolean {
|
||||
function primaryBoardIssueNumberFromIssueCell(issueCell: string | undefined): number | null {
|
||||
if (issueCell === undefined) return null;
|
||||
const markdownLinkPattern = /\[[^\]]*]\(([^)]*)\)/g;
|
||||
let match = markdownLinkPattern.exec(issueCell);
|
||||
while (match !== null) {
|
||||
const issueNumber = /\/issues\/(\d+)/u.exec(match[1] ?? "")?.[1];
|
||||
if (issueNumber !== undefined) {
|
||||
const value = Number(issueNumber);
|
||||
if (Number.isInteger(value) && value > 0) return value;
|
||||
}
|
||||
match = markdownLinkPattern.exec(issueCell);
|
||||
}
|
||||
const leadingIssueReference = /^\s*#(\d+)\b/u.exec(issueCell)?.[1];
|
||||
if (leadingIssueReference !== undefined) {
|
||||
const value = Number(leadingIssueReference);
|
||||
if (Number.isInteger(value) && value > 0) return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function normalizedBoardCellPlaceholder(value: string): { spaced: string; compact: string } {
|
||||
const spaced = stripMarkdownInline(value).toLowerCase().replace(/\s+/g, " ").trim();
|
||||
return { spaced, compact: spaced.replace(/\s+/g, "") };
|
||||
}
|
||||
|
||||
function isRelatedTaskNoTaskPlaceholder(value: string): boolean {
|
||||
const normalized = normalizedBoardCellPlaceholder(value);
|
||||
return [
|
||||
"-",
|
||||
"—",
|
||||
"–",
|
||||
"n/a",
|
||||
"na",
|
||||
"none",
|
||||
"no task",
|
||||
"no-task",
|
||||
"no code queue task",
|
||||
"not applicable",
|
||||
].includes(normalized.spaced) || [
|
||||
"无",
|
||||
"无任务",
|
||||
"无关联任务",
|
||||
"无相关任务",
|
||||
"无codequeue任务",
|
||||
"无codequeuetask",
|
||||
"不适用",
|
||||
].includes(normalized.compact);
|
||||
}
|
||||
|
||||
function cellHasMeaningfulValue(value: string | undefined, column: BoardRequiredColumn): boolean {
|
||||
if (value === undefined) return false;
|
||||
const stripped = stripMarkdownInline(value);
|
||||
if (stripped.length === 0) return false;
|
||||
if (column === "relatedTask" && isRelatedTaskNoTaskPlaceholder(value)) return true;
|
||||
return !["-", "—", "n/a", "na", "todo", "tbd", "待补", "未填", "无"].includes(stripped.toLowerCase());
|
||||
}
|
||||
|
||||
@@ -1318,7 +1368,10 @@ function parseBoardTables(body: string): { sections: BoardTableSection[]; warnin
|
||||
if (!isMarkdownTableSeparator(lines[rowIndex])) {
|
||||
const cells = markdownCells(lines[rowIndex]);
|
||||
const issueCell = issueColumnIndex === null ? undefined : cells[issueColumnIndex];
|
||||
const issueNumbers = issueColumnIndex === null ? extractIssueNumbers(lines[rowIndex]) : extractIssueNumbers(issueCell ?? "");
|
||||
const primaryIssueNumber = issueColumnIndex === null ? null : primaryBoardIssueNumberFromIssueCell(issueCell);
|
||||
const issueNumbers = issueColumnIndex === null
|
||||
? extractIssueNumbers(lines[rowIndex])
|
||||
: (primaryIssueNumber === null ? extractIssueNumbers(issueCell ?? "") : [primaryIssueNumber]);
|
||||
const columns: Partial<Record<BoardRequiredColumn, string>> = {};
|
||||
for (const column of BOARD_AUDIT_REQUIRED_COLUMNS) {
|
||||
const cellIndex = columnMap.get(column);
|
||||
@@ -1359,7 +1412,7 @@ function parseBoardTables(body: string): { sections: BoardTableSection[]; warnin
|
||||
rowPreview: preview(row.raw),
|
||||
});
|
||||
}
|
||||
const missingColumns = BOARD_AUDIT_REQUIRED_COLUMNS.filter((column) => !cellHasMeaningfulValue(columns[column]));
|
||||
const missingColumns = BOARD_AUDIT_REQUIRED_COLUMNS.filter((column) => !cellHasMeaningfulValue(columns[column], column));
|
||||
if (missingColumns.length > 0) {
|
||||
warnings.push({
|
||||
issueNumber: row.issueNumber,
|
||||
|
||||
Reference in New Issue
Block a user