diff --git a/src/main/scanLogic/scanGraphLogic.ts b/src/main/scanLogic/scanGraphLogic.ts index adc8db1d3..0e61cb3ac 100644 --- a/src/main/scanLogic/scanGraphLogic.ts +++ b/src/main/scanLogic/scanGraphLogic.ts @@ -23,7 +23,7 @@ export class GraphScanLogic { */ public async scan(graphRoot: RootNode, progress: XrayScanProgress, checkCanceled: () => void): Promise { let graphRequest: IGraphRequestModel = { - component_id: graphRoot.generalInfo.artifactId ?? graphRoot.dependencyId, + component_id: graphRoot.generalInfo.artifactId ?? graphRoot.xrayId, nodes: this.getFlattenRequestModelNodes(graphRoot, new Set()) } as IGraphRequestModel; if (!graphRequest.nodes || graphRequest.nodes.length === 0) { @@ -48,10 +48,10 @@ export class GraphScanLogic { public getFlattenRequestModelNodes(dependency: DependenciesTreeNode, components: Set): IGraphRequestModel[] | undefined { let nodes: IGraphRequestModel[] = []; for (let child of dependency.children) { - if (child.dependencyId && !components.has(child.dependencyId)) { - components.add(child.dependencyId); + if (child.xrayId && !components.has(child.xrayId)) { + components.add(child.xrayId); nodes.push({ - component_id: child.dependencyId + component_id: child.xrayId } as IGraphRequestModel); } let childNodes: IGraphRequestModel[] | undefined = this.getFlattenRequestModelNodes(child, components); diff --git a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/goTree.ts b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/goTree.ts index 966ff85dd..b5f3f3c48 100644 --- a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/goTree.ts +++ b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/goTree.ts @@ -153,8 +153,7 @@ export class GoTreeNode extends RootNode { private addComponentToScan(dependenciesTreeNode: DependenciesTreeNode) { let componentId: string = dependenciesTreeNode.generalInfo.artifactId + ':' + dependenciesTreeNode.generalInfo.version; - this.projectDetails.addDependency(GoTreeNode.COMPONENT_PREFIX + componentId); - dependenciesTreeNode.dependencyId = GoTreeNode.COMPONENT_PREFIX + componentId; + dependenciesTreeNode.xrayId = GoTreeNode.COMPONENT_PREFIX + componentId; } private getNameVersionTuple(value: string): string[] { diff --git a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/mavenTree.ts b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/mavenTree.ts index 162d8c129..9e4199ab3 100644 --- a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/mavenTree.ts +++ b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/mavenTree.ts @@ -66,9 +66,8 @@ export class MavenTreeNode extends RootNode { let child: DependenciesTreeNode = new DependenciesTreeNode(gavGeneralInfo, treeCollapsibleState, parent); child.label = group + ':' + name; let componentId: string = gavGeneralInfo.getComponentId(); - this.projectDetails.addDependency(MavenTreeNode.COMPONENT_PREFIX + componentId); - child.dependencyId = MavenTreeNode.COMPONENT_PREFIX + componentId; + child.xrayId = MavenTreeNode.COMPONENT_PREFIX + componentId; if (rawDependenciesPtr.index + 1 < rawDependenciesList.length) { while ( rawDependenciesPtr.index + 1 < rawDependenciesList.length && diff --git a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/npmTree.ts b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/npmTree.ts index 025dcca9d..82895c9f5 100644 --- a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/npmTree.ts +++ b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/npmTree.ts @@ -65,8 +65,7 @@ export class NpmTreeNode extends RootNode { : vscode.TreeItemCollapsibleState.None; let child: DependenciesTreeNode = new DependenciesTreeNode(generalInfo, treeCollapsibleState, dependenciesTreeNode); let componentId: string = key + ':' + version; - this.projectDetails.addDependency(NpmTreeNode.COMPONENT_PREFIX + componentId); - child.dependencyId = NpmTreeNode.COMPONENT_PREFIX + componentId; + child.xrayId = NpmTreeNode.COMPONENT_PREFIX + componentId; this.populateDependenciesTree(child, childDependencies); } } diff --git a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/nugetTree.ts b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/nugetTree.ts index 36eb7bc52..0af0daea0 100644 --- a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/nugetTree.ts +++ b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/nugetTree.ts @@ -37,8 +37,7 @@ export class NugetTreeNode extends RootNode { childDependencies.length > 0 ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None; let child: DependenciesTreeNode = new DependenciesTreeNode(generalInfo, treeCollapsibleState, dependenciesTreeNode, ''); let combined: string = id + ':' + version; - this.projectDetails.addDependency(NugetTreeNode.COMPONENT_PREFIX + combined); - child.dependencyId = NugetTreeNode.COMPONENT_PREFIX + combined; + child.xrayId = NugetTreeNode.COMPONENT_PREFIX + combined; this.populateDependenciesTree(child, childDependencies); } } diff --git a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/pypiTree.ts b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/pypiTree.ts index e02292ea3..97ef94d8d 100644 --- a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/pypiTree.ts +++ b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/pypiTree.ts @@ -40,8 +40,7 @@ export class PypiTreeNode extends RootNode { : vscode.TreeItemCollapsibleState.None; let child: DependenciesTreeNode = new DependenciesTreeNode(generalInfo, treeCollapsibleState, dependenciesTreeNode); let componentId: string = dependency.key + ':' + version; - this.projectDetails.addDependency(PypiTreeNode.COMPONENT_PREFIX + componentId); - child.dependencyId = PypiTreeNode.COMPONENT_PREFIX + componentId; + child.xrayId = PypiTreeNode.COMPONENT_PREFIX + componentId; this.populateDependenciesTree(child, childDependencies); } } diff --git a/src/main/treeDataProviders/dependenciesTree/dependenciesTreeNode.ts b/src/main/treeDataProviders/dependenciesTree/dependenciesTreeNode.ts index 596f05619..b6033879f 100644 --- a/src/main/treeDataProviders/dependenciesTree/dependenciesTreeNode.ts +++ b/src/main/treeDataProviders/dependenciesTree/dependenciesTreeNode.ts @@ -34,11 +34,11 @@ export class DependenciesTreeNode extends vscode.TreeItem { } } - public get dependencyId(): string { + public get xrayId(): string { return this._dependencyId; } - public set dependencyId(value: string) { + public set xrayId(value: string) { this._dependencyId = value; } diff --git a/src/main/types/projectDetails.ts b/src/main/types/projectDetails.ts index 1bbf3bf09..d6dc1e962 100644 --- a/src/main/types/projectDetails.ts +++ b/src/main/types/projectDetails.ts @@ -1,10 +1,7 @@ -import { ComponentDetails } from 'jfrog-client-js'; import * as path from 'path'; import { PackageType } from './projectType'; -import Set from 'typescript-collections/dist/lib/Set'; export class ProjectDetails { - private _dependencies: Set = new Set(); private _name: string; constructor(private _path: string, private _type: PackageType) { @@ -34,23 +31,4 @@ export class ProjectDetails { public set path(value: string) { this._path = value; } - - public get dependencies(): Set { - return this._dependencies; - } - - public set dependencies(value: Set) { - this._dependencies = value; - } - - /** - * @param dependencyId - component id of the dependency - */ - public addDependency(dependencyId: string) { - this._dependencies.add(new ComponentDetails(dependencyId)); - } - - public toArray(): ComponentDetails[] { - return this._dependencies.toArray(); - } } diff --git a/src/test/tests/goUtils.test.ts b/src/test/tests/goUtils.test.ts index ad622f084..ef1f96b04 100644 --- a/src/test/tests/goUtils.test.ts +++ b/src/test/tests/goUtils.test.ts @@ -97,14 +97,14 @@ describe('Go Utils Tests', async () => { let dependenciesTreeNode: DependenciesTreeNode = new DependenciesTreeNode( new GeneralInfo('github.com/jfrog/jfrog-cli-core', '1.9.1', [], '', PackageType.Go) ); - let dependencyPos: vscode.Range[] = GoUtils.getDependencyPosition(textDocument, dependenciesTreeNode.dependencyId, FocusType.Dependency); + let dependencyPos: vscode.Range[] = GoUtils.getDependencyPosition(textDocument, dependenciesTreeNode.xrayId, FocusType.Dependency); assert.deepEqual(dependencyPos[0].start, new vscode.Position(5, 1)); assert.deepEqual(dependencyPos[0].end, new vscode.Position(5, 39)); // Test 'resources/go/empty/go.mod' goMod = vscode.Uri.file(path.join(commonProjDir.fsPath, 'empty', 'go.mod')); textDocument = await vscode.workspace.openTextDocument(goMod); - dependencyPos = GoUtils.getDependencyPosition(textDocument, dependenciesTreeNode.dependencyId, FocusType.Dependency); + dependencyPos = GoUtils.getDependencyPosition(textDocument, dependenciesTreeNode.xrayId, FocusType.Dependency); assert.isEmpty(dependencyPos); }); diff --git a/src/test/tests/utils/treeNodeUtils.test.ts b/src/test/tests/utils/treeNodeUtils.test.ts index 1cace1ad2..be9dfdab1 100644 --- a/src/test/tests/utils/treeNodeUtils.test.ts +++ b/src/test/tests/utils/treeNodeUtils.test.ts @@ -59,7 +59,7 @@ export function createRootTestNode(pathOfWorkspace: string): IssuesRootTreeNode export function createDependency(artifactId: string, version: string, parent?: DependenciesTreeNode): DependenciesTreeNode { let dependenciesTreeNode: DependenciesTreeNode = new DependenciesTreeNode(new GeneralInfo(artifactId, version, [], '', PackageType.Unknown)); - dependenciesTreeNode.dependencyId = artifactId + ':' + version; + dependenciesTreeNode.xrayId = artifactId + ':' + version; parent?.addChild(dependenciesTreeNode); return dependenciesTreeNode; }