Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] unused-variable not detected within IF block #1093

Open
niallmcgee opened this issue Jun 14, 2024 · 1 comment
Open

[Bug] unused-variable not detected within IF block #1093

niallmcgee opened this issue Jun 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@niallmcgee
Copy link

What happened?

robocop doesn't report unused-variable errors if the variable is set within a IF block. It seems to catch those in other control blocks (eg FOR) OK.

What command/code did you try to run?

*** Test Cases ***
TC1
  ${U1}  Set Variable  UNUSED1

  IF  True
    ${U2}  Set Variable  UNUSED2
  END

  FOR  ${_}  IN RANGE  1
    ${U3}  Set Variable  UNUSED3
  END

What is the full error message?

$ robocop -e missing-doc* foo.robot
/tmp/pyvenv/foo.robot:3:3 [I] 0920 Variable '${U1}' is assigned but not used (unused-variable)
/tmp/pyvenv/foo.robot:8:5 [I] 0920 Variable '${U3}' is assigned but not used (unused-variable)

What did you expect to happen instead?

I expected ${U2} to be reported as an unused variable as well as ${U1} and ${U3}

Operating System

Linux

Robocop version

5.2.0

@niallmcgee niallmcgee added the bug Something isn't working label Jun 14, 2024
@bhirsz
Copy link
Member

bhirsz commented Jun 14, 2024

It is most likely outcome of the logic where we try to find variables defined only for given scope (we don't always want to check if given variable is used if it's defined in specific place). I will look into it how it can be mitigated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants