robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
177 stars 14 forks source link

[BUG] "Argument not used" warning, when argument used in WHILE loop limit #295

Closed gohierf closed 3 weeks ago

gohierf commented 1 month ago

Describe the bug robotcode.diagnostics(VariableNotUsed) is raised when the argument is actually used in the limit argument of WHILE loops.

To Reproduce Steps to reproduce the behavior:

  1. Use a keyword argument to configure While loop max number of iteration
  2. See robotcode show argument not used.

If possible add some example source code like:

My Keyword
    [Documentation]    Showing argument not used but should not
    [Arguments]    ${retries}
    WHILE    ${True}    limit=${retries}
        No Operation
    END

Expected behavior Robotcode should recognize the argument is being used.

Screenshots/ Videos image

Logs NA

Desktop (please complete the following information): VS Code Version 1.92.2 RobotCode Version 0.85.0 OS: Windows Python Version 3.11 RobotFramework Version 7.0 robocop 5.4.0 robotidy 4.11.0

Additional context NA

gohierf commented 1 month ago

On the same line as this bug and #289, the warning is also raised when the variable is used in a python evaluation

Escape Libdoc Table Char
    [Documentation]    Escape pipe from input string:
    ...    - if surunded by spaces
    ...    - if it is the ending character
    [Arguments]    ${val}
    VAR    ${output}    ${{ re.sub(r' \|$', ' \|', $val) }}
    VAR    ${output}    ${{ re.sub(r' \| ', ' \| ', $output) }}
    RETURN    ${output}

image

gohierf commented 3 weeks ago

To elaborate on the first point: it is not only arguments that are not seen as used in WHILE parameterS, local and suite variable as well.

image


*** Variables ***
${MY_SUITE_VAR}     foo

*** Test Cases ***
My Tes
    My Keyword    10

*** Keywords ***
My Keyword
    [Documentation]    Showing argument not used but should not
    [Arguments]    ${retries}
    VAR    ${on_limit}    FAIL
    WHILE    True    limit=${retries}
    ...    on_limit=${on_limit}
    ...    on_limit_message=${MY_SUITE_VAR}
        No Operation
    END
gohierf commented 3 weeks ago

Moreover, WHILE settings limit, on_limit and on_limit_message lack the autocompletion of variable name, which works on the WHILE condition.