Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignoredWorkspaceFolders setting #3617

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Add `codeQL.runningQueries.ignoredWorkspaceFolders` setting. [#3617](https://github.com/github/vscode-codeql/pull/3617)

## 1.13.1 - 29 May 2024

- Fix a bug when re-importing test databases that erroneously showed old source code. [#3616](https://github.com/github/vscode-codeql/pull/3616)
Expand Down
5 changes: 5 additions & 0 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@
"maximum": 1024,
"description": "Number of threads for running queries."
},
"codeQL.runningQueries.ignoredWorkspaceFolders": {
"type": "array",
"default": [],
"description": "Workspace folders to ignore."
},
"codeQL.runningQueries.saveCache": {
"type": "boolean",
"default": false,
Expand Down
16 changes: 15 additions & 1 deletion extensions/ql-vscode/src/common/vscode/workspace-folders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { dirname, join } from "path";
import type { WorkspaceFolder } from "vscode";
import { workspace } from "vscode";
import { IGNORED_WORKSPACE_FOLDERS_SETTING } from "../../config";

/** Returns true if the specified workspace folder is on the file system. */
export function isWorkspaceFolderOnDisk(
Expand All @@ -9,10 +10,23 @@ export function isWorkspaceFolderOnDisk(
return workspaceFolder.uri.scheme === "file";
}

export function isWorkspaceFolderIgnored(
workspaceFolder: WorkspaceFolder,
): boolean {
const ignoredFolders =
IGNORED_WORKSPACE_FOLDERS_SETTING.getValue() as string[];
return ignoredFolders.some((ignoredFolder) =>
workspaceFolder.uri.fsPath.startsWith(ignoredFolder),
);
}

/** Gets all active workspace folders that are on the filesystem. */
export function getOnDiskWorkspaceFoldersObjects() {
const workspaceFolders = workspace.workspaceFolders ?? [];
return workspaceFolders.filter(isWorkspaceFolderOnDisk);
return workspaceFolders.filter(
(f: WorkspaceFolder) =>
isWorkspaceFolderOnDisk(f) && !isWorkspaceFolderIgnored(f),
);
}

/** Gets all active workspace folders that are on the filesystem. */
Expand Down
4 changes: 4 additions & 0 deletions extensions/ql-vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ const TIMEOUT_SETTING = new Setting("timeout", RUNNING_QUERIES_SETTING);
const MEMORY_SETTING = new Setting("memory", RUNNING_QUERIES_SETTING);
const DEBUG_SETTING = new Setting("debug", RUNNING_QUERIES_SETTING);
const MAX_PATHS = new Setting("maxPaths", RUNNING_QUERIES_SETTING);
export const IGNORED_WORKSPACE_FOLDERS_SETTING = new Setting(
"ignoredWorkspaceFolders",
RUNNING_QUERIES_SETTING,
);
const RUNNING_TESTS_SETTING = new Setting("runningTests", ROOT_SETTING);
const RESULTS_DISPLAY_SETTING = new Setting("resultsDisplay", ROOT_SETTING);
const USE_EXTENSION_PACKS = new Setting(
Expand Down