From 70bac87fed2ec5570ccc657bff417225962a10c5 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 24 Jul 2021 13:54:52 +0200 Subject: [PATCH] Fix (most) LGTM warnings Most of the warnings we don't really care about, and those are simply white-listed using inline comments; however two cases prompted actual code changes: - In `src/display/pattern_helper.js` the branch in question is indeed unreachable, and should thus be safe to remove. (This code originated in PR 4192, which is now over seven years ago.) - In `test/test.js`, the function in question indeed doesn't accept any arguments. (The patch also re-formats a string just above, which didn't seem worthy of a separated patch.) This now leaves only *one* warning in the LGTM report, however that one is a false positive that we'll need to report upstream. --- src/core/file_spec.js | 2 +- src/display/pattern_helper.js | 2 -- test/integration/scripting_spec.js | 2 +- test/test.js | 6 ++---- test/webserver.js | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/core/file_spec.js b/src/core/file_spec.js index 151a48e7a..cf06d66a3 100644 --- a/src/core/file_spec.js +++ b/src/core/file_spec.js @@ -67,7 +67,7 @@ class FileSpec { if (!this._filename && this.root) { const filename = pickPlatformItem(this.root) || "unnamed"; this._filename = stringToPDFString(filename) - .replace(/\\\\/g, "\\") + .replace(/\\\\/g, "\\") // lgtm [js/double-escaping] .replace(/\\\//g, "/") .replace(/\\/g, "/"); } diff --git a/src/display/pattern_helper.js b/src/display/pattern_helper.js index c4d4308bf..72103d377 100644 --- a/src/display/pattern_helper.js +++ b/src/display/pattern_helper.js @@ -192,8 +192,6 @@ function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) { let k; if (y < y1) { k = 0; - } else if (y1 === y2) { - k = 1; } else { k = (y1 - y) / (y1 - y2); } diff --git a/test/integration/scripting_spec.js b/test/integration/scripting_spec.js index 31ff21010..8532cc7ac 100644 --- a/test/integration/scripting_spec.js +++ b/test/integration/scripting_spec.js @@ -22,7 +22,7 @@ describe("Interaction", () => { } await action(); await page.waitForFunction( - `document.querySelector("${selector.replace("\\", "\\\\")}").value !== ""` + `document.querySelector("${selector.replace("\\", "\\\\")}").value !== ""` // lgtm [js/incomplete-sanitization] ); return page.$eval(selector, el => el.value); } diff --git a/test/test.js b/test/test.js index d4014c09c..5d854914c 100644 --- a/test/test.js +++ b/test/test.js @@ -262,11 +262,9 @@ function startRefTest(masterMode, showRefImages) { } else if (showRefImages && numEqFailures > 0) { console.log(); console.log( - "Starting reftest harness to examine " + - numEqFailures + - " eq test failures." + `Starting reftest harness to examine ${numEqFailures} eq test failures.` ); - examineRefImages(numEqFailures); + examineRefImages(); } } diff --git a/test/webserver.js b/test/webserver.js index c2d5b96de..ccf384716 100644 --- a/test/webserver.js +++ b/test/webserver.js @@ -153,7 +153,7 @@ WebServer.prototype = { fileSize = stats.size; var isDir = stats.isDirectory(); if (isDir && !/\/$/.test(pathPart)) { - res.setHeader("Location", pathPart + "/" + urlParts[2]); + res.setHeader("Location", pathPart + "/" + urlParts[2]); // lgtm [js/server-side-unvalidated-url-redirection] res.writeHead(301); res.end("Redirected", "utf8"); return;