From 57d42e35c2e65bf66b734589a48892756c8cd6ba Mon Sep 17 00:00:00 2001 From: Ezequiel Date: Fri, 17 Nov 2023 04:48:04 -0300 Subject: [PATCH] fix: cache variable detector missing instances --- src/issues/GAS/cacheVariable.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/issues/GAS/cacheVariable.ts b/src/issues/GAS/cacheVariable.ts index 1d41279..9c70a4a 100644 --- a/src/issues/GAS/cacheVariable.ts +++ b/src/issues/GAS/cacheVariable.ts @@ -75,9 +75,10 @@ const issue: ASTIssue = { } } /** Check that there is more than 2 reads */ - const occurences = identifiers.filter(r => r.name === variableName); - if (isStorage && occurences?.length > 1) { - instances.push(instanceFromSRC(file, occurences[1].src)); + const occurrences = identifiers.filter(r => r.name === variableName); + if (isStorage && occurrences?.length > 1) { + for (let i = 1; i < occurrences.length; i++) + instances.push(instanceFromSRC(file, occurrences[i].src)); } } }