Repository navigation
feat: split missing-section-variable-type into keyword and test variable rules #1982
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13351,29 +13351,19 @@ Robot Framework 7.3 introduced type conversion for variables. This rule | |
| enforces that variables in the ``*** Variables ***`` section have explicit | ||
| type annotations for better code clarity and automatic type conversion. | ||
|
|
||
| This rule also checks ``VAR`` statements and assignment expressions | ||
| (``${var} = Keyword``). | ||
| Variables defined in keywords and tests are checked by the separate | ||
| ``missing-keyword-variable-type`` and ``missing-test-variable-type`` rules. | ||
|
|
||
| Incorrect code example (when rule is enabled): | ||
|
|
||
| *** Variables *** | ||
| ${NUMBER} 42 | ||
|
|
||
| *** Keywords *** | ||
| Example | ||
| VAR ${local} value | ||
| ${result} = Some Keyword | ||
|
|
||
| Correct code: | ||
|
|
||
| *** Variables *** | ||
| ${NUMBER: int} 42 | ||
|
|
||
| *** Keywords *** | ||
| Example | ||
| VAR ${local: str} value | ||
| ${result: list} = Some Keyword | ||
|
|
||
| This rule is disabled by default. | ||
|
|
||
| **Parameters**: | ||
|
|
@@ -13595,3 +13585,135 @@ The VAR syntax needs to be used instead: | |
| "set-keyword-with-type.severity=E" | ||
| ] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### ANN05: missing-keyword-variable-type | ||
|
|
||
| > Rule is disabled by default. Enable it by using ``--select missing-keyword-variable-type`` option. | ||
|
|
||
| Added: `v9.5.0` | ||
|
|
||
| Supported RF version `>=7.3` | ||
|
|
||
| Fix availability: There is no automatic fix. | ||
|
|
||
| **Message**: | ||
|
|
||
| `Variable '{variable_name}' is missing type annotation` | ||
|
|
||
| **Documentation**: | ||
|
|
||
| Keyword variable without type annotation. | ||
|
|
||
| Robot Framework 7.3 introduced type conversion for variables. This rule | ||
| enforces that variables created inside keywords with ``VAR`` statements and | ||
| assignment expressions (``${var} = Keyword``) have explicit type annotations | ||
| for better code clarity and automatic type conversion. | ||
|
|
||
| Incorrect code example (when rule is enabled): | ||
|
|
||
| *** Keywords *** | ||
| Example | ||
| VAR ${local} value | ||
| ${result} = Some Keyword | ||
|
Comment on lines
+13618
to
+13619
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these be separate rules?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm personally leaning towards no right now. But if, at some point, types can be inferred from the keyword return value, this should maybe be split. |
||
|
|
||
| Correct code: | ||
|
|
||
| *** Keywords *** | ||
| Example | ||
| VAR ${local: str} value | ||
| ${result: list} = Some Keyword | ||
|
|
||
| This rule is disabled by default. | ||
|
|
||
| **Parameters**: | ||
|
|
||
| ??? example "severity" | ||
|
|
||
| Rule severity (e = error, w = warning, i = info) | ||
|
|
||
| **Default value:** I | ||
|
|
||
| **Type:** severity | ||
|
|
||
| === ":octicons-command-palette-24: cli" | ||
|
|
||
| ``` bash | ||
| robocop check --configure missing-keyword-variable-type.severity=I | ||
| ``` | ||
|
|
||
| === ":material-file-cog-outline: toml" | ||
|
|
||
| ``` toml | ||
| [tool.robocop.lint] | ||
| configure = [ | ||
| "missing-keyword-variable-type.severity=I" | ||
| ] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### ANN06: missing-test-variable-type | ||
|
|
||
| > Rule is disabled by default. Enable it by using ``--select missing-test-variable-type`` option. | ||
|
|
||
| Added: `v9.5.0` | ||
|
|
||
| Supported RF version `>=7.3` | ||
|
|
||
| Fix availability: There is no automatic fix. | ||
|
|
||
| **Message**: | ||
|
|
||
| `Variable '{variable_name}' is missing type annotation` | ||
|
|
||
| **Documentation**: | ||
|
|
||
| Test variable without type annotation. | ||
|
|
||
| Robot Framework 7.3 introduced type conversion for variables. This rule | ||
| enforces that variables created inside tests or tasks with ``VAR`` statements and | ||
| assignment expressions (``${var} = Keyword``) have explicit type annotations | ||
| for better code clarity and automatic type conversion. | ||
|
|
||
| Incorrect code example (when rule is enabled): | ||
|
|
||
| *** Test Cases *** | ||
| Example | ||
| VAR ${local} value | ||
| ${result} = Some Keyword | ||
|
|
||
| Correct code: | ||
|
|
||
| *** Test Cases *** | ||
| Example | ||
| VAR ${local: str} value | ||
| ${result: list} = Some Keyword | ||
|
|
||
| This rule is disabled by default. | ||
|
|
||
| **Parameters**: | ||
|
|
||
| ??? example "severity" | ||
|
|
||
| Rule severity (e = error, w = warning, i = info) | ||
|
|
||
| **Default value:** I | ||
|
|
||
| **Type:** severity | ||
|
|
||
| === ":octicons-command-palette-24: cli" | ||
|
|
||
| ``` bash | ||
| robocop check --configure missing-test-variable-type.severity=I | ||
| ``` | ||
|
|
||
| === ":material-file-cog-outline: toml" | ||
|
|
||
| ``` toml | ||
| [tool.robocop.lint] | ||
| configure = [ | ||
| "missing-test-variable-type.severity=I" | ||
| ] | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agent artifact without meaningful documentation value