Skip to content

Commit

Permalink
fix: line targeting
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Oct 8, 2024
1 parent 61261e4 commit e4a3ef1
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions .github/empty-string-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,26 @@ function parseDiffForEmptyStrings(diff: string) {
let lineNumber = 0;

diffLines.forEach((line) => {
if (line.startsWith("+++ b/")) {
currentFile = line.replace("+++ b/", "");
if (line.startsWith("--- ") || line.startsWith("+++ ")) {
// Reset line number for new file headers
lineNumber = 0;
} else if (line.startsWith("+") && !line.startsWith("+++")) {
++lineNumber;
if (line.includes('""')) {
} else if (line.startsWith("+++ b/")) {
currentFile = line.replace("+++ b/", "");
} else if (line.startsWith("@@ ")) {
// Update line number based on hunk header
const match = line.match(/@@ -\d+,\d+ \+(\d+),/);
if (match) {
lineNumber = parseInt(match[1]) - 1;
}
} else if (line.startsWith("+")) {
lineNumber++;
if (line.includes('""') && !line.includes('"""')) {
violations.push({
file: currentFile,
line: ++lineNumber,
line: lineNumber,
content: line.substring(1),
});
}
} else if (!line.startsWith("-")) {
lineNumber++;
}
});

Expand Down

0 comments on commit e4a3ef1

Please sign in to comment.