From 287b62197bb70cf18031b68f4e87b238250e6835 Mon Sep 17 00:00:00 2001 From: Dimitri Stallenberg <33372913+dstallenberg@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:34:41 +0100 Subject: [PATCH] fix: remove duplicates from arrow function params (#213) --- libraries/analysis-javascript/lib/RootContext.ts | 10 ---------- .../lib/testcase/sampling/JavaScriptRandomSampler.ts | 7 ++++++- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/libraries/analysis-javascript/lib/RootContext.ts b/libraries/analysis-javascript/lib/RootContext.ts index 865883d9..e7fe704f 100644 --- a/libraries/analysis-javascript/lib/RootContext.ts +++ b/libraries/analysis-javascript/lib/RootContext.ts @@ -66,19 +66,9 @@ export class RootContext extends FrameworkRootContext { protected _targetFiles: Set; protected _analysisFiles: Set; - // filePath -> id -> element - protected _elementMap: Map>; - // filePath -> id -> relation - protected _relationMap: Map>; - // filePath -> id -> object - protected _objectMap: Map>; - protected _typeModel: TypeModel; protected _typePool: TypePool; - // Mapping: filePath -> target name -> Exports - protected _exportMap: Map; - get targetFiles() { return this._targetFiles; } diff --git a/libraries/search-javascript/lib/testcase/sampling/JavaScriptRandomSampler.ts b/libraries/search-javascript/lib/testcase/sampling/JavaScriptRandomSampler.ts index 5f178778..8f49a4ae 100644 --- a/libraries/search-javascript/lib/testcase/sampling/JavaScriptRandomSampler.ts +++ b/libraries/search-javascript/lib/testcase/sampling/JavaScriptRandomSampler.ts @@ -750,7 +750,7 @@ export class JavaScriptRandomSampler extends JavaScriptTestCaseSampler { .getTypeModel() .getObjectDescription(typeId); - const parameters: string[] = []; + let parameters: string[] = []; for (const [index, name] of typeObject.parameterNames.entries()) { parameters[index] = name; @@ -763,6 +763,11 @@ export class JavaScriptRandomSampler extends JavaScriptTestCaseSampler { } } + // filter duplicates + parameters = parameters.filter( + (item, index) => parameters.indexOf(item) === index + ); + if (typeObject.return.size === 0) { return new ArrowFunctionStatement( id,