Fix new linter errors

This commit is contained in:
Henry Mercer
2024-08-05 19:22:26 +01:00
parent acb243eabd
commit ecb9ccfcb1
33 changed files with 41 additions and 33 deletions

View File

@@ -14,7 +14,7 @@ import {
ConfigurationError,
} from "./util";
// eslint-disable-next-line import/no-commonjs
// eslint-disable-next-line import/no-commonjs, @typescript-eslint/no-require-imports
const pkg = require("../package.json") as JSONSchemaForNPMPackageJsonFiles;
/**
@@ -83,7 +83,7 @@ export const getCommitOid = async function (
},
).exec();
return commitOid.trim();
} catch (e) {
} catch {
if (stderr.includes("not a git repository")) {
core.info(
"Could not determine current commit SHA using git. Continuing with data from user input or environment. " +
@@ -154,7 +154,7 @@ export const determineMergeBaseCommitOid = async function (
return baseOid;
}
return undefined;
} catch (e) {
} catch {
if (stderr.includes("not a git repository")) {
core.info(
"The checkout path provided to the action does not appear to be a git repository. " +

View File

@@ -60,6 +60,7 @@ test("analyze action with RAM & threads from environment variables", async (t) =
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
const runQueriesStub = sinon.stub(analyze, "runQueries");
// eslint-disable-next-line @typescript-eslint/no-require-imports
const analyzeAction = require("./analyze-action");
// When analyze-action.ts loads, it runs an async function from the top

View File

@@ -60,6 +60,7 @@ test("analyze action with RAM & threads from action inputs", async (t) => {
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
const runQueriesStub = sinon.stub(analyze, "runQueries");
// eslint-disable-next-line @typescript-eslint/no-require-imports
const analyzeAction = require("./analyze-action");
// When analyze-action.ts loads, it runs an async function from the top

View File

@@ -190,7 +190,7 @@ export function dbIsFinalized(
fs.readFileSync(path.resolve(dbPath, "codeql-database.yml"), "utf8"),
) as { inProgress?: boolean };
return !("inProgress" in dbInfo);
} catch (e) {
} catch {
logger.warning(
`Could not check whether database for ${language} was finalized. Assuming it is not.`,
);

View File

@@ -538,7 +538,7 @@ export async function getCodeQLForCmd(
const output = await runTool(cmd, ["version", "--format=json"]);
try {
result = JSON.parse(output) as VersionInfo;
} catch (err) {
} catch {
throw Error(
`Invalid JSON output from \`version --format=json\`: ${output}`,
);

View File

@@ -770,7 +770,7 @@ export function parsePacksSpecification(packStr: string): Pack {
if (version) {
try {
new semver.Range(version);
} catch (e) {
} catch {
// The range string is invalid. OK to ignore the caught error
throw new ConfigurationError(getPacksStrInvalid(packStr));
}
@@ -874,7 +874,7 @@ function parseRegistries(
return registriesInput
? (yaml.load(registriesInput) as RegistryConfigWithCredentials[])
: undefined;
} catch (e) {
} catch {
throw new ConfigurationError(
"Invalid registries input. Must be a YAML string.",
);

View File

@@ -39,7 +39,7 @@ export async function uploadDebugArtifacts(
JSON.parse(matrix) as any[][],
).sort())
suffix += `-${matrixVal}`;
} catch (e) {
} catch {
core.info(
"Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input.",
);

View File

@@ -206,7 +206,7 @@ export function resolveUriToFile(
let uri: string;
try {
uri = decodeURIComponent(location.uri as string);
} catch (e: any) {
} catch {
logger.debug(`Ignoring location as URI "${location.uri}" is invalid`);
return undefined;
}

View File

@@ -155,6 +155,7 @@ async function runWrapper() {
await util.delay(1000);
}
if (subprocessError) {
// eslint-disable-next-line @typescript-eslint/only-throw-error
throw subprocessError;
}
core.info(`Proxy started on ${host}:${port}`);

View File

@@ -443,6 +443,7 @@ export function validateSarifFileSchema(sarifFilePath: string, logger: Logger) {
`Invalid SARIF. JSON syntax error: ${wrapError(e).message}`,
);
}
// eslint-disable-next-line @typescript-eslint/no-require-imports
const schema = require("../src/sarif-schema-2.1.0.json") as jsonschema.Schema;
const result = new jsonschema.Validator().validate(sarif, schema);

View File

@@ -516,7 +516,7 @@ export function parseGitHubUrl(inputUrl: string): string {
let url: URL;
try {
url = new URL(inputUrl);
} catch (e) {
} catch {
throw new ConfigurationError(`"${originalUrl}" is not a valid URL`);
}
@@ -753,7 +753,7 @@ export function doesDirectoryExist(dirPath: string): boolean {
try {
const stats = fs.lstatSync(dirPath);
return stats.isDirectory();
} catch (e) {
} catch {
return false;
}
}