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] 0920 (unused-variable) false positive with nested for loops #1148

Open
Brownies opened this issue Dec 13, 2024 · 0 comments
Open

[Bug] 0920 (unused-variable) false positive with nested for loops #1148

Brownies opened this issue Dec 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Brownies
Copy link

Brownies commented Dec 13, 2024

What happened?

0920 has a false positive that is somehow related to nested for loops. Commenting out the inner loop in the below code results in no unused variables reported. 5.3.0 doesn't report it with the inner loop so this is probably related to #1093 / #1104

What command/code did you try to run?

sample.resource:

*** Keywords ***
Do Stuff With Events
    [Arguments]    ${initial_token}
    ...    ${retries}=5
    # don't want to mutate the original
    VAR    ${continuation_token}    ${initial_token}

    FOR    ${i}    IN RANGE    ${{ int($retries)+1 }}
        ${response} =    Get Events    ${continuation_token}
        FOR    ${_}    IN    @{response}[events]
            # Do stuff
            No Operation
        END

        IF    $i < int($retries)
            VAR    ${continuation_token}    ${response}[continuationToken]
        END
    END


Get Events
    [Arguments]    ${token}
    RETURN    ${{ {'continuationToken': int($token) + 1, 'events': []} }}

and then run robocop sample.resource

What is the full error message?

sample.resource:15:20 [I] 0920 Variable '${continuation_token}' is assigned but not used (unused-variable)

What did you expect to happen instead?

No unused variables reported

Operating System

Ubuntu 24.04

Robocop version

5.4.0, 5.5.0, 5.6.0

@Brownies Brownies added the bug Something isn't working label Dec 13, 2024
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

1 participant