Skip to content
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
1 change: 1 addition & 0 deletions src/features/lightspeed/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
context,
settingsManager,
);
this.statusBarProvider.updateLightSpeedStatusbar();

Check failure on line 92 in src/features/lightspeed/base.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this asynchronous operation outside of the constructor.

See more on https://sonarcloud.io/project/issues?id=AutoCodeRoverSG_vscode-ansible-test-instance&issues=AZ6kw_RE4GsbWVQpqY0t&open=AZ6kw_RE4GsbWVQpqY0t&pullRequest=4

Check failure on line 92 in src/features/lightspeed/base.ts

View check run for this annotation

SonarQube Cloud - dev7 / SonarCloud Code Analysis

Refactor this asynchronous operation outside of the constructor.

See more on https://dev7.sc-dev7.io/project/issues?id=AutoCodeRoverSG_vscode-ansible&issues=AZ-xizY3hOZFoKAWOkJE&open=AZ-xizY3hOZFoKAWOkJE&pullRequest=4

this.lightspeedExplorerProvider = new LightspeedExplorerWebviewViewProvider(
context.extensionUri,
Expand Down
4 changes: 2 additions & 2 deletions src/features/lightspeed/feedbackWebviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class LightspeedFeedbackWebviewProvider {
return getWebviewContent(webview, extensionUri);
}

private async _setWebviewMessageListener(webview: Webview) {
await setWebviewMessageListener(webview, this._disposables);
private _setWebviewMessageListener(webview: Webview) {
setWebviewMessageListener(webview, this._disposables);
}
}
1 change: 0 additions & 1 deletion src/features/lightspeed/statusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class LightspeedStatusBar {
this.settingsManager = settingsManager;
// create a new project lightspeed status bar item that we can manage
this.statusBar = this.initialiseStatusBar();
this.updateLightSpeedStatusbar();
}

private initialiseStatusBar(): vscode.StatusBarItem {
Expand Down
38 changes: 22 additions & 16 deletions src/features/lightspeed/utils/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ export class CollectionFinder {
return j;
}

private async readCollectionsFromNamespace(
namespaceDirectory: string,
): Promise<(AnsibleCollection | null)[]> {
const collectionDirectories = await readdir(namespaceDirectory, {
withFileTypes: true,
});
const collectionPromises = collectionDirectories
.filter((entry) => entry.isDirectory())
.map((entry) =>
this.readCollectionMetaInformation(
path.join(entry.parentPath, entry.name),
),
);
return Promise.all(collectionPromises);
}

async searchNestedCollections() {
const collectionsPath = path.join(
this.workspacePaths[0],
Expand All @@ -79,35 +95,25 @@ export class CollectionFinder {
return namespaceDirectories
.filter((namespaceEntry) => namespaceEntry.isDirectory())
.map((namespaceEntry) => {
const namespaceName = namespaceEntry.name;
const namespaceDirectory = path.join(
namespaceEntry.parentPath,
namespaceName,
);
return readdir(namespaceDirectory, { withFileTypes: true }).then(
(collectionDirectories: Dirent[]) => {
return collectionDirectories
.filter((entry) => entry.isDirectory())
.map((entry) =>
this.readCollectionMetaInformation(
path.join(entry.parentPath, entry.name),
),
);
},
namespaceEntry.name,
);
return this.readCollectionsFromNamespace(namespaceDirectory);
});
})
.catch((e) => {
console.debug(`Cannot open directory ${collectionsPath}: ${e}`);
return [];
});
const r: AnsibleCollection[] = [];
for (let i = 0; i < a.length; i++) {
(await Promise.all(await a[i])).forEach((entry) => {
for (const namespacePromise of a) {
const entries = await namespacePromise;
for (const entry of entries) {
if (entry instanceof AnsibleCollection) {
r.push(entry);
}
});
}
}
return r;
}
Expand Down
4 changes: 2 additions & 2 deletions test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { LIGHTSPEED_ME_AUTH_URL } from "../src/definitions/lightspeed";
import { getInlineSuggestionItems } from "../src/features/lightspeed/inlineSuggestions";
import { rmSync } from "fs";

export let doc: vscode.TextDocument;
export let editor: vscode.TextEditor;
let doc: vscode.TextDocument;
let editor: vscode.TextEditor;

export const FIXTURES_BASE_PATH = path.join("test", "testFixtures");
export const ANSIBLE_COLLECTIONS_FIXTURES_BASE_PATH = path.resolve(
Expand Down