mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 17:39:50 +00:00
Enable no-unsafe-return rule
This commit is contained in:
@@ -141,7 +141,7 @@ export async function getWorkflowRelativePath(): Promise<string> {
|
||||
|
||||
const workflowResponse = await apiClient.request(`GET ${workflowUrl}`);
|
||||
|
||||
return workflowResponse.data.path;
|
||||
return workflowResponse.data.path as string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1017,7 +1017,10 @@ export function stubToolRunnerConstructor(
|
||||
stderr?: string,
|
||||
): sinon.SinonStub<any[], toolrunner.ToolRunner> {
|
||||
const runnerObjectStub = sinon.createStubInstance(toolrunner.ToolRunner);
|
||||
const runnerConstructorStub = sinon.stub(toolrunner, "ToolRunner");
|
||||
const runnerConstructorStub = sinon.stub(
|
||||
toolrunner,
|
||||
"ToolRunner",
|
||||
) as sinon.SinonStub<any[], toolrunner.ToolRunner>;
|
||||
let stderrListener: ((data: Buffer) => void) | undefined = undefined;
|
||||
runnerConstructorStub.callsFake((_cmd, _args, options: ExecOptions) => {
|
||||
stderrListener = options.listeners?.stderr;
|
||||
|
||||
@@ -422,9 +422,9 @@ function resolveFunction<T>(
|
||||
const dummyMethod = () => {
|
||||
throw new Error(`CodeQL ${methodName} method not correctly defined`);
|
||||
};
|
||||
return dummyMethod as any;
|
||||
return dummyMethod as T;
|
||||
}
|
||||
return partialCodeql[methodName];
|
||||
return partialCodeql[methodName] as T;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -740,7 +740,7 @@ export async function getCodeQLForCmd(
|
||||
const output = await runTool(cmd, codeqlArgs);
|
||||
|
||||
try {
|
||||
return JSON.parse(output);
|
||||
return JSON.parse(output) as ResolveLanguagesOutput;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Unexpected output from codeql resolve languages: ${e}`,
|
||||
@@ -759,7 +759,7 @@ export async function getCodeQLForCmd(
|
||||
const output = await runTool(cmd, codeqlArgs);
|
||||
|
||||
try {
|
||||
return JSON.parse(output);
|
||||
return JSON.parse(output) as BetterResolveLanguagesOutput;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Unexpected output from codeql resolve languages with --format=betterjson: ${e}`,
|
||||
@@ -783,7 +783,7 @@ export async function getCodeQLForCmd(
|
||||
const output = await runTool(cmd, codeqlArgs);
|
||||
|
||||
try {
|
||||
return JSON.parse(output);
|
||||
return JSON.parse(output) as ResolveQueriesOutput;
|
||||
} catch (e) {
|
||||
throw new Error(`Unexpected output from codeql resolve queries: ${e}`);
|
||||
}
|
||||
@@ -805,7 +805,7 @@ export async function getCodeQLForCmd(
|
||||
const output = await runTool(cmd, codeqlArgs);
|
||||
|
||||
try {
|
||||
return JSON.parse(output);
|
||||
return JSON.parse(output) as ResolveBuildEnvironmentOutput;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Unexpected output from codeql resolve build-environment: ${e} in\n${output}`,
|
||||
@@ -1093,7 +1093,7 @@ export async function getCodeQLForCmd(
|
||||
},
|
||||
},
|
||||
).exec();
|
||||
return JSON.parse(extractorPath);
|
||||
return JSON.parse(extractorPath) as string;
|
||||
},
|
||||
async mergeResults(
|
||||
sarifFiles: string[],
|
||||
@@ -1347,7 +1347,7 @@ async function generateCodeScanningConfig(
|
||||
}
|
||||
|
||||
function cloneObject<T>(obj: T): T {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
return JSON.parse(JSON.stringify(obj)) as T;
|
||||
}
|
||||
|
||||
// This constant sets the size of each TRAP cache in megabytes.
|
||||
|
||||
@@ -976,7 +976,7 @@ export async function getConfig(
|
||||
const configString = fs.readFileSync(configFile, "utf8");
|
||||
logger.debug("Loaded config:");
|
||||
logger.debug(configString);
|
||||
return JSON.parse(configString);
|
||||
return JSON.parse(configString) as Config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -435,7 +435,9 @@ class GitHubFeatureFlags {
|
||||
this.logger.debug(
|
||||
`Loading feature flags from ${this.featureFlagsFile}`,
|
||||
);
|
||||
return JSON.parse(fs.readFileSync(this.featureFlagsFile, "utf8"));
|
||||
return JSON.parse(
|
||||
fs.readFileSync(this.featureFlagsFile, "utf8"),
|
||||
) as GitHubFeatureFlagsApiResponse;
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.warning(
|
||||
|
||||
@@ -309,7 +309,7 @@ async function uploadPayload(
|
||||
payload: any,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
logger: Logger,
|
||||
) {
|
||||
): Promise<string> {
|
||||
logger.info("Uploading results");
|
||||
|
||||
// If in test mode we don't want to upload the results
|
||||
@@ -323,7 +323,7 @@ async function uploadPayload(
|
||||
);
|
||||
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
|
||||
fs.writeFileSync(payloadSaveFile, JSON.stringify(payload, null, 2));
|
||||
return;
|
||||
return "test-mode-sarif-id";
|
||||
}
|
||||
|
||||
const client = api.getApiClient();
|
||||
@@ -340,7 +340,7 @@ async function uploadPayload(
|
||||
|
||||
logger.debug(`response status: ${response.status}`);
|
||||
logger.info("Successfully uploaded results");
|
||||
return response.data.id;
|
||||
return response.data.id as string;
|
||||
} catch (e) {
|
||||
if (util.isHTTPError(e)) {
|
||||
switch (e.status) {
|
||||
|
||||
@@ -120,7 +120,7 @@ export function getExtraOptionsEnvParam(): object {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
return JSON.parse(raw);
|
||||
return JSON.parse(raw) as object;
|
||||
} catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
throw new ConfigurationError(
|
||||
@@ -888,7 +888,7 @@ export function parseMatrixInput(
|
||||
if (matrixInput === undefined || matrixInput === "null") {
|
||||
return undefined;
|
||||
}
|
||||
return JSON.parse(matrixInput);
|
||||
return JSON.parse(matrixInput) as { [key: string]: string };
|
||||
}
|
||||
|
||||
function removeDuplicateLocations(locations: SarifLocation[]): SarifLocation[] {
|
||||
|
||||
Reference in New Issue
Block a user