Skip to content

Commit 6504e46

Browse files
Invert condition to reduce nesting
1 parent ce6a21c commit 6504e46

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

extensions/ql-vscode/src/queries-panel/query-discovery.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,27 @@ export class QueryDiscovery
6262
const queriesInRoot = this.paths.filter((query) =>
6363
containsPath(workspaceFolder.uri.fsPath, query.path),
6464
);
65-
if (queriesInRoot.length > 0) {
66-
const root = new FileTreeDirectory<string>(
67-
workspaceFolder.uri.fsPath,
68-
workspaceFolder.name,
69-
this.env,
65+
if (queriesInRoot.length === 0) {
66+
continue;
67+
}
68+
const root = new FileTreeDirectory<string>(
69+
workspaceFolder.uri.fsPath,
70+
workspaceFolder.name,
71+
this.env,
72+
);
73+
for (const query of queriesInRoot) {
74+
const dirName = dirname(normalize(relative(root.path, query.path)));
75+
const parentDirectory = root.createDirectory(dirName);
76+
parentDirectory.addChild(
77+
new FileTreeLeaf<string>(
78+
query.path,
79+
basename(query.path),
80+
query.language,
81+
),
7082
);
71-
for (const query of queriesInRoot) {
72-
const dirName = dirname(normalize(relative(root.path, query.path)));
73-
const parentDirectory = root.createDirectory(dirName);
74-
parentDirectory.addChild(
75-
new FileTreeLeaf<string>(
76-
query.path,
77-
basename(query.path),
78-
query.language,
79-
),
80-
);
81-
}
82-
root.finish();
83-
roots.push(root);
8483
}
84+
root.finish();
85+
roots.push(root);
8586
}
8687
return roots;
8788
}

0 commit comments

Comments
 (0)