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] non-local-variables-should-be-uppercase Incorrectly Flags Variable Names That Are Themselves A Variable #1139

Open
bdepperman opened this issue Nov 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bdepperman
Copy link

What happened?

When dynamically calculating the names of global variables to set and passing those to Set Global Variable, the name of the variable that is passed to Set Global Variable is interpreted as the name that Set Global Variable is going to use, which is incorrect.

What command/code did you try to run?

robocop --include non-local-variables-should-be-uppercase my_file.robot

What is the full error message?

$ tail -2 my_file.robot
    ${name}=            "MY UPPERCASE VARIABLE NAME"
    Set Global Variable     ${${name}}      "My variable value"
$ robocop --include non-local-variables-should-be-uppercase my_file.robot
/my_path/my_file.robot:17:29 [W] 0310 Test, suite and global variables should be uppercase (non-local-variables-should-be-uppercase)
$

What did you expect to happen instead?

Robocop shouldn't flag this. It can't figure out the possible values of ${name} in the above example if $name} is an argument being passed in to a keyword with this Set Global Variable call, for example, so it should exclude any cases of variables being used as the variable name in the Set Global Variable call.

Operating System

No response

Robocop version

5.5.0

@bdepperman bdepperman added the bug Something isn't working label Nov 4, 2024
@bhirsz
Copy link
Member

bhirsz commented Nov 6, 2024

Thanks for report. I will take a look - the variable recognition is far from ideal but at least we should handle such cases.

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