Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 4d02e27

Browse files
GideonKoenigGideonKoeniglars-reimann
authored
fix(gui): resolve bug of missing parameter statistics (#950)
* feat: added addUnusedParametes function * style: apply automatic fixes of linters * refactor(gui): loop over parameters in API instead of parameters in usage store * refactor(gui): remove useless code Co-authored-by: GideonKoenig <[email protected]> Co-authored-by: GideonKoenig <[email protected]> Co-authored-by: Lars Reimann <[email protected]>
1 parent 1012130 commit 4d02e27

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

api-editor/gui/src/features/usages/model/UsageCountStore.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,9 @@ export class UsageCountStore {
127127
* its default value, that usage of a value is not part of the UsageStore, so we need to add it.
128128
*
129129
* @param api Description of the API
130-
* @private
131130
*/
132131
private addImplicitUsagesOfDefaultValues(api: PythonPackage) {
133-
for (const [parameterId, parameterUsageCount] of this.parameterUsages.entries()) {
134-
const parameter = api.getDeclarationById(parameterId);
135-
if (!(parameter instanceof PythonParameter)) {
136-
continue;
137-
}
138-
132+
for (const parameter of api.getParameters()) {
139133
const defaultValue = parameter.defaultValue;
140134
if (defaultValue === undefined || defaultValue === null) {
141135
// defaultValue could be an empty string
@@ -147,21 +141,19 @@ export class UsageCountStore {
147141
continue;
148142
}
149143

150-
const functionUsageCount = this.functionUsages.get(containingFunction.id) ?? 0;
144+
const parameterUsageCount = this.getUsageCount(parameter);
145+
const functionUsageCount = this.getUsageCount(containingFunction);
151146
const nImplicitUsages = functionUsageCount - parameterUsageCount;
152147
if (nImplicitUsages === 0) {
153148
continue;
154149
}
155150

156-
const nExplicitUsage = this.valueUsages.get(parameterId)?.get(defaultValue) ?? 0;
151+
const nExplicitUsages = this.valueUsages.get(parameter.id)?.get(defaultValue) ?? 0;
157152

158-
if (!this.valueUsages.has(parameterId)) {
159-
this.valueUsages.set(parameterId, new Map());
160-
}
161-
if (!this.valueUsages.get(parameterId)!.has(defaultValue)) {
162-
this.valueUsages.get(parameterId)!.set(defaultValue, 0);
153+
if (!this.valueUsages.has(parameter.id)) {
154+
this.valueUsages.set(parameter.id, new Map());
163155
}
164-
this.valueUsages.get(parameterId)!.set(defaultValue, nImplicitUsages + nExplicitUsage);
156+
this.valueUsages.get(parameter.id)!.set(defaultValue, nImplicitUsages + nExplicitUsages);
165157
}
166158
}
167159

0 commit comments

Comments
 (0)