Skip to content

Commit

Permalink
chore: annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Oct 8, 2024
1 parent 5813aef commit 19b73b2
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions .github/empty-string-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).`,
});
}

Expand Down

0 comments on commit 19b73b2

Please sign in to comment.