From 19b73b2fb490f99fa7164fc0649e90cf91537581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A2=E3=83=AC=E3=82=AF=E3=82=B5=E3=83=B3=E3=83=80?= =?UTF-8?q?=E3=83=BC=2Eeth?= Date: Wed, 9 Oct 2024 07:54:09 +0900 Subject: [PATCH] chore: annotations --- .github/empty-string-checker.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/empty-string-checker.ts b/.github/empty-string-checker.ts index bfe5dbf..e41ddac 100644 --- a/.github/empty-string-checker.ts +++ b/.github/empty-string-checker.ts @@ -80,19 +80,16 @@ function parseDiffForEmptyStrings(diff: string) { } async function createReview(violations: Array<{ file: string; line: number; content: string }>) { - const reviewComments = violations.map((v) => ({ - path: v.file, - line: v.line, - body: `> [!WARNING]\n> Empty string found, consider another approach. [Read more](https://www.github.com/ubiquity/ts-template/issues/31).`, - })); + const annotationsBody = violations + .map((v) => `${v.file}#L${v.line}\n\`\`\`suggestion\n${v.content.trim().replace('""', "/* TODO: Replace empty string */")}\n\`\`\``) + .join("\n\n"); await octokit.pulls.createReview({ owner, repo, pull_number: parseInt(pullNumber), event: "COMMENT", - comments: reviewComments, - body: "> [!WARNING]\n> Empty strings detected in the code. Please review.", + body: `> [!WARNING]\n> ${violations.length} empty string${violations.length > 1 ? "s" : ""} detected in the code.\n\n${annotationsBody}\n\n[Read more about empty string issues](https://www.github.com/ubiquity/ts-template/issues/31).`, }); }