diff --git a/src/main/java/com/cflint/plugins/core/UnusedLocalVarChecker.java b/src/main/java/com/cflint/plugins/core/UnusedLocalVarChecker.java index b5f4a0b77..b9c4ea9ba 100644 --- a/src/main/java/com/cflint/plugins/core/UnusedLocalVarChecker.java +++ b/src/main/java/com/cflint/plugins/core/UnusedLocalVarChecker.java @@ -53,7 +53,9 @@ public void expression(final CFExpression expression, final Context context, fin } else if (expression instanceof CFVarDeclExpression) { final String name = ((CFVarDeclExpression) expression).getName(); final int lineNo = expression.getLine() + context.startLine() - 1; - addLocalVariable(name, lineNo); + if(!scopes.isCFScoped(name)){ + addLocalVariable(name, lineNo); + } } else if (expression instanceof CFIdentifier) { final String name = ((CFIdentifier) expression).getName(); if(name != null){ diff --git a/src/test/resources/com/cflint/tests/UnusedVariable/local_339.cfc b/src/test/resources/com/cflint/tests/UnusedVariable/local_339.cfc new file mode 100644 index 000000000..84f28c596 --- /dev/null +++ b/src/test/resources/com/cflint/tests/UnusedVariable/local_339.cfc @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/com/cflint/tests/UnusedVariable/local_339.expected.txt b/src/test/resources/com/cflint/tests/UnusedVariable/local_339.expected.txt new file mode 100644 index 000000000..ff34de20d --- /dev/null +++ b/src/test/resources/com/cflint/tests/UnusedVariable/local_339.expected.txt @@ -0,0 +1,5 @@ +[ { + "totalfiles" : 0 +}, { + "totalsize" : 0 +} ] \ No newline at end of file