Merge pull request #3089 from github/koesie10/eslint-curly
Enable ESLint `curly` rule
This commit is contained in:
@@ -50,6 +50,7 @@ const baseConfig = {
|
||||
"@typescript-eslint/no-throw-literal": "error",
|
||||
"no-useless-escape": 0,
|
||||
camelcase: "off",
|
||||
curly: ["error", "all"],
|
||||
"escompat/no-regexp-lookbehind": "off",
|
||||
"etc/no-implicit-any-catch": "error",
|
||||
"filenames/match-regex": "off",
|
||||
|
||||
@@ -635,9 +635,10 @@ export class CodeQLCliServer implements Disposable {
|
||||
} = {},
|
||||
): Promise<OutputType> {
|
||||
let args: string[] = [];
|
||||
if (addFormat)
|
||||
if (addFormat) {
|
||||
// Add format argument first, in case commandArgs contains positional parameters.
|
||||
args = args.concat(["--format", "json"]);
|
||||
}
|
||||
args = args.concat(commandArgs);
|
||||
const result = await this.runCodeQlCliCommand(command, args, description, {
|
||||
progressReporter,
|
||||
@@ -939,8 +940,12 @@ export class CodeQLCliServer implements Disposable {
|
||||
name?: string,
|
||||
): Promise<string> {
|
||||
const subcommandArgs = [];
|
||||
if (target) subcommandArgs.push("--target", target);
|
||||
if (name) subcommandArgs.push("--name", name);
|
||||
if (target) {
|
||||
subcommandArgs.push("--target", target);
|
||||
}
|
||||
if (name) {
|
||||
subcommandArgs.push("--name", name);
|
||||
}
|
||||
subcommandArgs.push(archivePath);
|
||||
|
||||
return await this.runCodeQlCliCommand(
|
||||
@@ -961,7 +966,9 @@ export class CodeQLCliServer implements Disposable {
|
||||
outputDirectory?: string,
|
||||
): Promise<string> {
|
||||
const subcommandArgs = ["--format=markdown"];
|
||||
if (outputDirectory) subcommandArgs.push("--output", outputDirectory);
|
||||
if (outputDirectory) {
|
||||
subcommandArgs.push("--output", outputDirectory);
|
||||
}
|
||||
subcommandArgs.push(pathToQhelp);
|
||||
|
||||
return await this.runCodeQlCliCommand(
|
||||
@@ -1609,16 +1616,19 @@ export function spawnServer(
|
||||
});
|
||||
// Set up event listeners.
|
||||
child.on("close", async (code, signal) => {
|
||||
if (code !== null)
|
||||
if (code !== null) {
|
||||
void logger.log(`Child process exited with code ${code}`);
|
||||
if (signal)
|
||||
}
|
||||
if (signal) {
|
||||
void logger.log(
|
||||
`Child process exited due to receipt of signal ${signal}`,
|
||||
);
|
||||
}
|
||||
// If the process exited abnormally, log the last stdout message,
|
||||
// It may be from the jvm.
|
||||
if (code !== 0 && lastStdout !== undefined)
|
||||
if (code !== 0 && lastStdout !== undefined) {
|
||||
void logger.log(`Last stdout was "${lastStdout.toString()}"`);
|
||||
}
|
||||
});
|
||||
child.stderr!.on("data", stderrListener);
|
||||
if (stdoutListener !== undefined) {
|
||||
|
||||
@@ -107,11 +107,15 @@ export function parseSarifLocation(
|
||||
sourceLocationPrefix: string,
|
||||
): ParsedSarifLocation {
|
||||
const physicalLocation = loc.physicalLocation;
|
||||
if (physicalLocation === undefined) return { hint: "no physical location" };
|
||||
if (physicalLocation.artifactLocation === undefined)
|
||||
if (physicalLocation === undefined) {
|
||||
return { hint: "no physical location" };
|
||||
}
|
||||
if (physicalLocation.artifactLocation === undefined) {
|
||||
return { hint: "no artifact location" };
|
||||
if (physicalLocation.artifactLocation.uri === undefined)
|
||||
}
|
||||
if (physicalLocation.artifactLocation.uri === undefined) {
|
||||
return { hint: "artifact location has no uri" };
|
||||
}
|
||||
if (isEmptyPath(physicalLocation.artifactLocation.uri)) {
|
||||
return { hint: "artifact location has empty uri" };
|
||||
}
|
||||
|
||||
@@ -130,11 +130,14 @@ export function decodeSourceArchiveUri(uri: vscode.Uri): ZipFileReference {
|
||||
};
|
||||
}
|
||||
const match = sourceArchiveUriAuthorityPattern.exec(uri.authority);
|
||||
if (match === null) throw new InvalidSourceArchiveUriError(uri);
|
||||
if (match === null) {
|
||||
throw new InvalidSourceArchiveUriError(uri);
|
||||
}
|
||||
const zipPathStartIndex = parseInt(match[1]);
|
||||
const zipPathEndIndex = parseInt(match[2]);
|
||||
if (isNaN(zipPathStartIndex) || isNaN(zipPathEndIndex))
|
||||
if (isNaN(zipPathStartIndex) || isNaN(zipPathEndIndex)) {
|
||||
throw new InvalidSourceArchiveUriError(uri);
|
||||
}
|
||||
return {
|
||||
pathWithinSourceArchive: uri.path.substring(zipPathEndIndex) || "/",
|
||||
sourceArchiveZipPath: uri.path.substring(
|
||||
@@ -179,8 +182,9 @@ type Archive = {
|
||||
};
|
||||
|
||||
async function parse_zip(zipPath: string): Promise<Archive> {
|
||||
if (!(await pathExists(zipPath)))
|
||||
if (!(await pathExists(zipPath))) {
|
||||
throw vscode.FileSystemError.FileNotFound(zipPath);
|
||||
}
|
||||
const archive: Archive = {
|
||||
unzipped: await unzipper.Open.file(zipPath),
|
||||
dirMap: new Map(),
|
||||
|
||||
@@ -9,11 +9,15 @@ export function getSelectedDbItem(dbItems: DbItem[]): DbItem | undefined {
|
||||
) {
|
||||
for (const child of dbItem.children) {
|
||||
const selectedItem = extractSelected(child);
|
||||
if (selectedItem) return selectedItem;
|
||||
if (selectedItem) {
|
||||
return selectedItem;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const selectedItem = extractSelected(dbItem);
|
||||
if (selectedItem) return selectedItem;
|
||||
if (selectedItem) {
|
||||
return selectedItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
||||
@@ -197,7 +197,9 @@ export class DatabaseItemImpl implements DatabaseItem {
|
||||
* Holds if `uri` belongs to this database's source archive.
|
||||
*/
|
||||
public belongsToSourceArchiveExplorerUri(uri: vscode.Uri): boolean {
|
||||
if (this.sourceArchive === undefined) return false;
|
||||
if (this.sourceArchive === undefined) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
uri.scheme === zipArchiveScheme &&
|
||||
decodeSourceArchiveUri(uri).sourceArchiveZipPath ===
|
||||
|
||||
@@ -655,8 +655,9 @@ export class ResultsView extends AbstractWebview<
|
||||
const schema = resultSetSchemas.find(
|
||||
(resultSet) => resultSet.name === selectedTable,
|
||||
)!;
|
||||
if (schema === undefined)
|
||||
if (schema === undefined) {
|
||||
throw new Error(`Query result set '${selectedTable}' not found.`);
|
||||
}
|
||||
|
||||
const pageSize = PAGE_SIZE.getValue<number>();
|
||||
const chunk = await this.cliServer.bqrsDecode(
|
||||
@@ -771,7 +772,9 @@ export class ResultsView extends AbstractWebview<
|
||||
);
|
||||
}
|
||||
|
||||
if (interp.data.t !== "SarifInterpretationData") return interp;
|
||||
if (interp.data.t !== "SarifInterpretationData") {
|
||||
return interp;
|
||||
}
|
||||
|
||||
if (interp.data.runs.length !== 1) {
|
||||
void this.logger.log(
|
||||
@@ -887,7 +890,9 @@ export class ResultsView extends AbstractWebview<
|
||||
): Promise<void> {
|
||||
const { data, sourceLocationPrefix } = interpretation;
|
||||
|
||||
if (data.t !== "SarifInterpretationData") return;
|
||||
if (data.t !== "SarifInterpretationData") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.runs || !data.runs[0].results) {
|
||||
void this.logger.log(
|
||||
|
||||
@@ -556,7 +556,9 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
item,
|
||||
)}. Are you sure?`,
|
||||
);
|
||||
if (!response) return;
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.treeDataProvider.remove(item);
|
||||
@@ -579,7 +581,9 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
|
||||
void showInformationMessageWithAction(message, "Go to workflow run").then(
|
||||
async (shouldOpenWorkflowRun) => {
|
||||
if (!shouldOpenWorkflowRun) return;
|
||||
if (!shouldOpenWorkflowRun) {
|
||||
return;
|
||||
}
|
||||
await env.openExternal(Uri.parse(workflowRunUrl));
|
||||
},
|
||||
);
|
||||
|
||||
@@ -10,6 +10,8 @@ interface Props {
|
||||
* Designed to fit in with the other types of location components.
|
||||
*/
|
||||
export function NonClickableLocation({ msg, locationHint }: Props) {
|
||||
if (msg === undefined) return null;
|
||||
if (msg === undefined) {
|
||||
return null;
|
||||
}
|
||||
return <span title={locationHint}>{msg}</span>;
|
||||
}
|
||||
|
||||
@@ -54,13 +54,19 @@ export function getPath(
|
||||
key: Path | PathNode,
|
||||
): sarif.ThreadFlow | undefined {
|
||||
const result = getResult(sarif, key);
|
||||
if (result === undefined) return undefined;
|
||||
if (result === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
let index = -1;
|
||||
if (result.codeFlows === undefined) return undefined;
|
||||
if (result.codeFlows === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
for (const codeFlows of result.codeFlows) {
|
||||
for (const threadFlow of codeFlows.threadFlows) {
|
||||
++index;
|
||||
if (index === key.pathIndex) return threadFlow;
|
||||
if (index === key.pathIndex) {
|
||||
return threadFlow;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
@@ -74,7 +80,9 @@ export function getPathNode(
|
||||
key: PathNode,
|
||||
): sarif.Location | undefined {
|
||||
const path = getPath(sarif, key);
|
||||
if (path === undefined) return undefined;
|
||||
if (path === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return path.locations[key.pathNodeIndex]?.location;
|
||||
}
|
||||
|
||||
@@ -85,7 +93,9 @@ export function equalsNotUndefined(
|
||||
key1: Partial<PathNode> | undefined,
|
||||
key2: Partial<PathNode> | undefined,
|
||||
): boolean {
|
||||
if (key1 === undefined || key2 === undefined) return false;
|
||||
if (key1 === undefined || key2 === undefined) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
key1.resultIndex === key2.resultIndex &&
|
||||
key1.pathIndex === key2.pathIndex &&
|
||||
@@ -99,7 +109,9 @@ export function equalsNotUndefined(
|
||||
* Path nodes indices are relative to this flattened list.
|
||||
*/
|
||||
export function getAllPaths(result: sarif.Result): sarif.ThreadFlow[] {
|
||||
if (result.codeFlows === undefined) return [];
|
||||
if (result.codeFlows === undefined) {
|
||||
return [];
|
||||
}
|
||||
const paths = [];
|
||||
for (const codeFlow of result.codeFlows) {
|
||||
for (const threadFlow of codeFlow.threadFlows) {
|
||||
|
||||
@@ -85,8 +85,9 @@ describe("commands declared in package.json", () => {
|
||||
});
|
||||
|
||||
menus.commandPalette.forEach((commandDecl: CmdDecl) => {
|
||||
if (commandDecl.when === "false")
|
||||
if (commandDecl.when === "false") {
|
||||
disabledInPalette.add(commandDecl.command);
|
||||
}
|
||||
});
|
||||
|
||||
it("should have commands appropriately prefixed", () => {
|
||||
|
||||
@@ -144,7 +144,9 @@ function mockRequestError(status: number, body: any): RequestError {
|
||||
// Copied from https://github.com/octokit/request.js/blob/c67f902350384846f88d91196e7066daadc08357/src/fetch-wrapper.ts#L166 to have a
|
||||
// somewhat realistic error message
|
||||
function toErrorMessage(data: any) {
|
||||
if (typeof data === "string") return data;
|
||||
if (typeof data === "string") {
|
||||
return data;
|
||||
}
|
||||
|
||||
if ("message" in data) {
|
||||
if (Array.isArray(data.errors)) {
|
||||
|
||||
@@ -140,10 +140,11 @@ export async function ensureCli(useCli: boolean) {
|
||||
*/
|
||||
function getCliDownloadUrl(assetName: string) {
|
||||
if (CLI_VERSION === "nightly") {
|
||||
if (!process.env.NIGHTLY_URL)
|
||||
if (!process.env.NIGHTLY_URL) {
|
||||
throw new Error(
|
||||
"Nightly CLI was specified but no URL to download it from was given!",
|
||||
);
|
||||
}
|
||||
return `${process.env.NIGHTLY_URL}/${assetName}`;
|
||||
}
|
||||
return `https://github.com/github/codeql-cli-binaries/releases/download/${CLI_VERSION}/${assetName}`;
|
||||
|
||||
Reference in New Issue
Block a user