-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Inline If with assign variables raising argument/variable overwri…
…tten before usage
- Loading branch information
Showing
8 changed files
with
85 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Inline If with assign variables handling variables in invalid order (#987) | ||
--------------------------------------------------------------------------- | ||
|
||
Inline If did not properly recognized that variables were used inside if loop before assigning return value. | ||
Following code:: | ||
|
||
*** Keywords *** | ||
Keyword With Argument | ||
[Arguments] ${arg} | ||
${arg} IF ${VALUE} Use ${arg} | ||
|
||
Keyword With Local Variable | ||
${var} Set Variable default value | ||
${var} IF ${VALUE} Use ${var} | ||
|
||
Will no longer raise W0921 ``argument-overwritten-before-usage`` and W0922 ``variable-overwritten-before-usage``. | ||
|
||
And following code:: | ||
|
||
*** Keywords *** | ||
Inline If - Overwritten Variable | ||
${var} Set Variable default | ||
${var} IF condition Use ${var} | ||
|
||
InlineIf - Assign With The Same Name As Arg | ||
${assign} IF condition Do Nothing ELSE Use ${assign} | ||
|
||
Should now raise I0920 ``unused-variable`` for ``${var}`` and ``${assign}`` variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/atest/rules/misc/variable_overwritten_before_usage/inline_if.robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*** Keywords *** | ||
Overwritten In Inline IF | ||
${variable} Set Variable default value | ||
${variable} IF ${CONDITION} Replace String ${variable} TAG ${CONDITION_TAG} | ||
|
||
Overwritten In Inline IF ELSE | ||
${variable} Set Variable default value | ||
${variable} IF ${CONDITION} Do Nothing ELSE Replace String ${variable} TAG ${CONDITION_TAG} | ||
|
||
Overwritten In Inline IF ELSE IF | ||
${variable} Set Variable default value | ||
${variable} IF ${CONDITION} Do Nothing ELSE IF ${OTHER} Replace String ${variable} TAG ${CONDITION_TAG} | ||
|
||
Overwritten In Inline IF - Arguments | ||
[Documentation] Should not raise anything - it is argument. | ||
[Arguments] ${arg} | ||
${arg} IF ${CONDITION} Replace String ${arg} TAG ${CONDITION_TAG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters