-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle VAR syntax in variable naming rules (#1018)
- Loading branch information
Showing
11 changed files
with
95 additions
and
12 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,8 @@ | ||
Updated existing rules with VAR support (#973) | ||
----------------------------------------------- | ||
|
||
Following rules now support ``VAR`` syntax: | ||
|
||
- W0310 ``non-local-variables-should-be-uppercase`` | ||
- I0317 ``hyphen-in-variable-name`` | ||
- W0324 ``overwriting-reserved-variable`` |
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
8 changes: 8 additions & 0 deletions
8
tests/atest/rules/naming/hyphen_in_variable_name/VAR_syntax.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,8 @@ | ||
*** Test Cases *** | ||
My Test Case | ||
VAR ${r} ${2-1} # this is fine | ||
VAR ${a-b} 1 # this will warn - because if it's later used as ${a-b} it can lead to ambiguous results | ||
VAR ${a\-b} 1 # this will warn | ||
VAR ${-} 1 scope=GLOBAL # this will warn | ||
VAR ${a-} 1 # this will warn | ||
VAR ${-b} 1 # this will warn |
5 changes: 5 additions & 0 deletions
5
tests/atest/rules/naming/hyphen_in_variable_name/expected_output_var.txt
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,5 @@ | ||
VAR_syntax.robot:4:12 [I] 0317 Use underscore in variable name '${a-b}' instead of hyphens to avoid treating them like minus sign | ||
VAR_syntax.robot:5:12 [I] 0317 Use underscore in variable name '${a\-b}' instead of hyphens to avoid treating them like minus sign | ||
VAR_syntax.robot:6:12 [I] 0317 Use underscore in variable name '${-}' instead of hyphens to avoid treating them like minus sign | ||
VAR_syntax.robot:7:12 [I] 0317 Use underscore in variable name '${a-}' instead of hyphens to avoid treating them like minus sign | ||
VAR_syntax.robot:8:12 [I] 0317 Use underscore in variable name '${-b}' instead of hyphens to avoid treating them like minus sign |
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
10 changes: 10 additions & 0 deletions
10
tests/atest/rules/naming/non_local_variables_should_be_uppercase/VAR_syntax.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,10 @@ | ||
*** Keywords *** | ||
VAR syntax | ||
VAR ${suite} value scope=SUITE | ||
VAR ${global} value scope=GLOBAL | ||
VAR ${test} value scope=TEST | ||
VAR ${task} value scope=TASK | ||
VAR ${local_default} value scope=local | ||
VAR ${local_default} value | ||
VAR ${invalid | ||
4 changes: 4 additions & 0 deletions
4
tests/atest/rules/naming/non_local_variables_should_be_uppercase/expected_output_var.txt
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,4 @@ | ||
VAR_syntax.robot:3:12 [W] 0310 Test, suite and global variables should be uppercase | ||
VAR_syntax.robot:4:12 [W] 0310 Test, suite and global variables should be uppercase | ||
VAR_syntax.robot:5:12 [W] 0310 Test, suite and global variables should be uppercase | ||
VAR_syntax.robot:6:12 [W] 0310 Test, suite and global variables should be uppercase |
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
12 changes: 12 additions & 0 deletions
12
tests/atest/rules/naming/overwriting_reserved_variable/VAR_syntax.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,12 @@ | ||
*** Test Cases *** | ||
Overwrite reserved with VAR | ||
VAR ${TEST_NAME} new_value | ||
VAR ${TEST DOCUMENTATION} new value scope=GLOBAL | ||
VAR ${LOG LEVEL} ${OPTIONS} scope=LOCAL | ||
|
||
|
||
*** Keywords *** | ||
Overwrite reserved with VAR | ||
VAR ${TEST_NAME} new_value | ||
VAR ${TEST DOCUMENTATION} new value scope=GLOBAL | ||
VAR ${LOG LEVEL} ${OPTIONS} scope=LOCAL |
6 changes: 6 additions & 0 deletions
6
tests/atest/rules/naming/overwriting_reserved_variable/expected_output_var.txt
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,6 @@ | ||
VAR_syntax.robot:3:13 [W] 0324 Variable '${TEST_NAME}' overwrites reserved variable '${TEST_NAME}' | ||
VAR_syntax.robot:4:12 [W] 0324 Variable '${TEST DOCUMENTATION}' overwrites reserved variable '${TEST_DOCUMENTATION}' | ||
VAR_syntax.robot:5:12 [W] 0324 Variable '${LOG LEVEL}' overwrites reserved variable '${LOG_LEVEL}' | ||
VAR_syntax.robot:10:13 [W] 0324 Variable '${TEST_NAME}' overwrites reserved variable '${TEST_NAME}' | ||
VAR_syntax.robot:11:12 [W] 0324 Variable '${TEST DOCUMENTATION}' overwrites reserved variable '${TEST_DOCUMENTATION}' | ||
VAR_syntax.robot:12:12 [W] 0324 Variable '${LOG LEVEL}' overwrites reserved variable '${LOG_LEVEL}' |
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