Skip to content

Commit 9910a12

Browse files
committed
find unused loop and except variables
1 parent 6089413 commit 9910a12

File tree

1 file changed

+5
-1
lines changed
  • robotcode/language_server/robotframework/diagnostics

1 file changed

+5
-1
lines changed

robotcode/language_server/robotframework/diagnostics/analyzer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ async def visit(self, node: ast.AST) -> None:
149149
KeywordCall,
150150
Template,
151151
TestTemplate,
152+
Variable,
152153
)
153154
from robot.variables.search import contains_variable
154155

@@ -167,7 +168,9 @@ async def visit(self, node: ast.AST) -> None:
167168
for token1 in (
168169
t
169170
for t in node.tokens
170-
if t.type != RobotToken.VARIABLE and t.error is None and contains_variable(t.value, "$@&%")
171+
if not (isinstance(node, Variable) and t.type == RobotToken.VARIABLE)
172+
and t.error is None
173+
and contains_variable(t.value, "$@&%")
171174
):
172175
async for token in self.yield_argument_name_and_rest(node, token1):
173176
if isinstance(node, Arguments) and token.value == "@{}":
@@ -199,6 +202,7 @@ async def visit(self, node: ast.AST) -> None:
199202
elif var not in self._variable_references and token1.type in [
200203
RobotToken.ASSIGN,
201204
RobotToken.ARGUMENT,
205+
RobotToken.VARIABLE,
202206
]:
203207
self._variable_references[var] = set()
204208

0 commit comments

Comments
 (0)