Rules list¶
This is the complete list of all Robocop rules grouped by categories. If you want to learn more about the rules and their features, see rules.
There are over 170 rules available in Robocop and they are organized into the following categories:
- ARG: Arguments
- COM: Comments
- DEPR: Deprecated code
- DOC: Documentation
- DUP: Duplications
- ERR: Errors
- IMP: Imports
- KW: Keywords
- LEN: Lengths
- MISC: Miscellaneous
- NAME: Naming
- ORD: Order
- SPC: Spacing
- TAG: Tags
- VAR: Variables
- ANN: Annotations
Below is the list of all Robocop rules.
Arguments¶
Rules for keyword arguments.
ARG01: unused-argument¶
Added: v3.2.0
Supported RF version All
Deprecated names: 0919
Fix availability: There is no automatic fix.
Message:
Keyword argument '{name}' is not used
Documentation:
Keyword argument was defined but not used:
*** Keywords ***
Keyword
[Arguments] ${used} ${not_used} # will report ${not_used}
Log ${used}
IF $used
Log Escaped syntax is supported.
END
Keyword with ${embedded} and ${not_used} # will report ${not_used}
Log ${embedded}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
ARG02: argument-overwritten-before-usage¶
Added: v3.2.0
Supported RF version All
Deprecated names: 0921
Fix availability: There is no automatic fix.
Message:
Keyword argument '{name}' is overwritten before usage
Documentation:
Keyword argument was overwritten before it is used:
*** Keywords ***
Overwritten Argument
[Arguments] ${overwritten} # we do not use ${overwritten} value at all
${overwritten} Set Variable value # we only overwrite it
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
ARG03: undefined-argument-default¶
Added: v5.7.0
Supported RF version All
Deprecated names: 0932
Fix availability: There is no automatic fix.
Message:
Undefined argument default, use {arg_name}=${{ EMPTY }} instead
Documentation:
Keyword arguments can define a default value. Every time you call the keyword, you can optionally overwrite this default.
When you use an argument default, you should be as clear as possible. This improves the
readability of your code. The syntax ${argument}= is unclear unless you happen to know
that it is technically equivalent to ${argument}=${EMPTY}. To prevent people from
misreading your keyword arguments, explicitly state that the value is empty using the
built-in ${EMPTY} variable.
Example of a rule violation:
*** Keywords ***
My Amazing Keyword
[Arguments] ${argument_name}=
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ARG04: undefined-argument-value¶
Added: v5.7.0
Supported RF version All
Deprecated names: 0933
Fix availability: There is no automatic fix.
Message:
Undefined argument value, use {arg_name}=${{ EMPTY }} instead
Documentation:
When calling a keyword, it can accept named arguments.
When you call a keyword, you should be as clear as possible. This improves the
readability of your code. The syntax argument= is unclear unless you happen to know
that it is technically equivalent to argument=${EMPTY}. To prevent people from
misreading your keyword arguments, explicitly state that the value is empty using the
built-in ${EMPTY} variable.
If this rule falsely flags your argument, escape the = character in your argument
value by like so: \=.
Example of a rule violation:
*** Test Cases ***
Test case
My Amazing Keyword argument_name=
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ARG05: invalid-argument¶
Added: v1.11.0
Supported RF version >=4.0
Deprecated names: 0407
Fix availability: There is no automatic fix.
Message:
{error_msg}
Documentation:
Argument names should follow variable naming syntax: start with identifier ($, @ or &) and enclosed
in curly brackets ({}).
Valid names:
*** Keywords ***
Keyword
[Arguments] ${var} @{args} &{config} ${var}=default
Invalid names:
*** Keywords ***
Keyword
[Arguments] {var} @args} var=default
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ARG06: duplicated-argument-name¶
Added: v1.11.0
Supported RF version All
Deprecated names: 0811
Fix availability: There is no automatic fix.
Message:
Argument name '{argument_name}' is already used
Documentation:
Argument name is already used.
Variable names in Robot Framework are case-insensitive and ignores spaces and underscores. Following arguments are duplicates:
*** Keywords ***
Keyword
[Arguments] ${var} ${VAR} ${v_ar} ${v ar}
Other Keyword
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ARG07: arguments-per-line¶
Added: v\-
Supported RF version All
Deprecated names: 0532
Fix availability: There is no automatic fix.
Message:
There is too many arguments per continuation line ({arguments_count} / {max_arguments_count})
Documentation:
Too many arguments per continuation line.
If the keyword's [Arguments] are split into multiple lines, it is recommended to put only one argument
per every line.
Incorrect code example:
*** Keywords ***
Keyword With Multiple Arguments
[Arguments] ${first_arg}
... ${second_arg} ${third_arg}=default
Correct code:
*** Keywords ***
Keyword With Multiple Arguments
[Arguments] ${first_arg}
... ${second_arg}
... ${third_arg}=default
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
max_args
Maximum number of arguments allowed in the continuation line
Default value: 1
Type: int
Comments¶
Rules for comments.
COM01: todo-in-comment¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0701
Fix availability: There is no automatic fix.
Message:
Found a marker '{marker}' in the comments
Documentation:
TODO-like marker found in the comment.
By default, it reports TODO and FIXME markers.
Example:
# TODO: Refactor this code
# fixme
Configuration example:
robocop check --configure "todo-in-comment.markers=todo,Remove me,Fix this!"
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
markers
List of case-insensitive markers that violate the rule in comments.
Default value: todo,fixme
Type: comma separated value
COM02: missing-space-after-comment¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0702
Fix availability: There is no automatic fix.
Message:
Missing blank space after comment character
Documentation:
No space after the # character and comment body.
Comments usually start from the new line, or after 2 spaces in the same line. '#' characters denote the start of the comment, followed by the space and comment body:
# stand-alone comment
Keyword Call # inline comment
### block comments are fine ###
Deviating from this pattern may lead to inconsistent or less readable comment format.
It is possible to configure block comments syntax that should be ignored.
Configured regex for block comment should take into account the first character is #.
Example:
#bad
# good
### good block
Configuration example:
robocop check --configure missing-space-after-comment.block=^#[*]+
Allows commenting like:
#*****
#
# Important topics here!
#
#*****
or
#* Headers *#
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
block
Block comment regex pattern.
Default value: ^###
Type: regex
COM03: invalid-comment¶
Added: v1.0.0
Supported RF version <4.0
Deprecated names: 0703
Fix availability: There is no automatic fix.
Message:
Comment starts from the second character in the line
Documentation:
Invalid comment.
In Robot Framework 3.2.2, comments that started from the second character in the line were not recognised as comments. '#' characters need to be in first or any other than the second character in the line to be recognised as a comment.
Example:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
COM04: ignored-data¶
Added: v1.3.0
Supported RF version All
Deprecated names: 0704
Fix availability: There is no automatic fix.
Message:
Ignored data found in file
Documentation:
Ignored data found in the file.
All lines before the first test data section (ref)
are ignored. It's recommended to add a *** Comments *** section header for lines that should be ignored.
Missing section header:
Resource file.resource # it looks like *** Settings *** but section header is missing - line is ignored
*** Keywords ***
Keyword Name
No Operation
Comment lines that should be inside *** Comments ***:
Deprecated Test
Keyword
Keyword 2
*** Test Cases ***
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
COM05: bom-encoding-in-file¶
Rule is disabled by default. Enable it by using
--select bom-encoding-in-fileoption.
Added: v1.7.0
Supported RF version All
Deprecated names: 0705
Fix availability: There is no automatic fix.
Message:
BOM (Byte Order Mark) found in the file
Documentation:
BOM (Byte Order Mark) found in the file.
Some code editors can save Robot file using BOM encoding. It is not supported by older versions of the Robot Framework. Ensure that the file is saved in UTF-8 encoding.
Changes in 8.0.0: Rule is now optional since Robot Framework now supports BOM encoding.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
COM06: commented-out-code¶
Rule is disabled by default. Enable it by using
--select commented-out-codeoption.
Added: v7.1.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Commented out code: '{snippet}'
Documentation:
Commented out code detected.
Uses Robot Framework's tokenizer to detect comments that contain RF code syntax. This approach reliably identifies:
- Variable assignment:
${var}=,@{list}=,&{dict}= - Setting brackets:
[Tags],[Arguments],[Documentation],[Setup],[Teardown],[Template],[Timeout],[Return] - Control structures:
IF,ELSE,ELSE IF,END,FOR,WHILE,TRY,EXCEPT,FINALLY,BREAK,CONTINUE,RETURN,GROUP,VAR - Settings section statements:
Library,Resource,Variables,Suite Setup,Suite Teardown,Test Setup,Test Teardown,Metadata,Force Tags,Default Tags
The following are ignored:
- Comments starting with TODO/FIXME markers (configurable)
- Comments inside
[Documentation]sections (code examples are common there) - Plain prose comments (e.g., "If you need help" is not detected as IF statement)
This rule is disabled by default. Enable it to detect forgotten or accidentally commented-out code.
Example of violations:
Keyword
# ${result}= Get Value
# [Tags] smoke
# IF ${condition}
Other Keyword
Example of valid comments:
# This is a normal comment
# TODO: implement this feature
# If you need help, ask
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
markers
Markers that indicate legitimate comments (not code). comments starting with these markers are ignored.
Default value: todo,fixme
Type: comma separated value
Deprecated code¶
Rules for deprecated code or code replacement recommendations.
DEPR01: if-can-be-used¶
Added: v1.4.0
Supported RF version ==4.*
Deprecated names: 0908
Fix availability: There is no automatic fix.
Message:
'{run_keyword}' can be replaced with IF block since Robot Framework 4.0
Documentation:
Run Keyword If or Run Keyword Unless used instead of IF.
Starting from Robot Framework 4.0 IF block can be used instead of those keywords.
Incorrect code example:
*** Test Cases ***
Test case
Run Keyword If ${condition} Keyword Call ELSE Log Condition did not match.
Run Keyword Unless ${something_happened} Assert Results
Correct code:
*** Test Cases ***
Test case
IF ${condition}
Keyword Call
ELSE
Log Condition did not match.
END
IF not ${something_happened}
Assert Results
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
DEPR02: deprecated-statement¶
Warning
Rule is deprecated.
Added: v2.0.0
Supported RF version All
Deprecated names: 0319
Fix availability: There is no automatic fix.
Message:
'{statement_name}' is deprecated since Robot Framework version {version}, use '{alternative}' instead
Documentation:
Statement is deprecated.
Detects any piece of code that is marked as deprecated but still works in RF.
For example, Run Keyword and Continue For Loop keywords or [Return] setting.
Changes in 8.0.0: Rule is now split into separate deprecated-* rules and the original rule is deprecated.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DEPR03: deprecated-with-name¶
Added: v2.5.0
Supported RF version >=6.0
Deprecated names: 0321
Fix availability: There is no automatic fix.
Message:
Deprecated 'WITH NAME' alias marker used instead of 'AS'
Documentation:
Deprecated 'WITH NAME' alias marker used instead of 'AS'.
WITH NAME marker used when giving an alias to an imported library is going to be renamed to AS.
The motivation is to be consistent with Python that uses as for a similar purpose.
Incorrect code example:
*** Settings ***
Library Collections WITH NAME AliasedName
Correct code:
*** Settings ***
Library Collections AS AliasedName
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DEPR04: deprecated-singular-header¶
Added: v2.6.0
Supported RF version >=6.0
Deprecated names: 0322
Fix availability: There is no automatic fix.
Message:
'{singular_header}' deprecated singular header used instead of '{plural_header}'
Documentation:
Deprecated singular header used instead of plural form.
Robot Framework 6.0 starts a deprecation period for singular headers forms. The rationale behind this change is available at https://github.com/robotframework/robotframework/issues/4431
Incorrect code example:
*** Setting ***
*** Keyword ***
Correct code:
*** Settings ***
*** Keywords ***
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DEPR05: replace-set-variable-with-var¶
Added: v5.0.0
Supported RF version >=7.0
Deprecated names: 0327
Fix availability: There is no automatic fix.
Message:
{set_variable_keyword} used instead of VAR
Documentation:
Set X Variable used instead of VAR.
Starting from Robot Framework 7.0, it is possible to create variables inside tests and user keywords using the VAR syntax. The VAR syntax is recommended over previously existing keywords.
Incorrect code example:
*** Keywords ***
Set Variables To Different Scopes
Set Local Variable ${local} value
Set Test Variable ${TEST_VAR} value
Set Task Variable ${TASK_VAR} value
Set Suite Variable ${SUITE_VAR} value
Set Global Variable ${GLOBAL_VAR} value
Correct code:
*** Keywords ***
Set Variables To Different Scopes
VAR ${local} value
VAR ${TEST_VAR} value scope=TEST
VAR ${TASK_VAR} value scope=TASK
VAR ${SUITE_VAR} value scope=SUITE
VAR ${GLOBAL_VAR} value scope=GLOBAL
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
DEPR06: replace-create-with-var¶
Added: v5.0.0
Supported RF version >=7.0
Deprecated names: 0328
Fix availability: There is no automatic fix.
Message:
{create_keyword} used instead of VAR
Documentation:
Create List/Dictionary used instead of VAR.
Starting from Robot Framework 7.0, it is possible to create variables inside tests and user keywords using the VAR syntax. The VAR syntax is recommended over previously existing keywords.
Incorrect code example:
*** Keywords ***
Create Variables
@{list} Create List a b
&{dict} Create Dictionary key=value
Correct code:
*** Keywords ***
Create Variables
VAR @{list} a b
VAR &{dict} key=value
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
DEPR07: deprecated-force-tags¶
Added: v8.0.0
Supported RF version >=6.0
Fix availability: Fix is always available.
Message:
'Force Tags' is deprecated, use 'Test Tags' instead
Documentation:
Force Tags setting is deprecated.
The following code is deprecated and will be removed in the future:
*** Settings ***
Force Tags tag
Use Test Tags instead:
*** Settings ***
Test Tags tag
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DEPR08: deprecated-run-keyword-if¶
Added: v8.0.0
Supported RF version >=4.0
Fix availability: There is no automatic fix.
Message:
'{statement_name}' is deprecated, use 'IF' instead
Documentation:
Run Keyword If and Run Keyword Unless keywords are deprecated.
The following code is deprecated and will be removed in the future:
*** Test Cases ***
Test with conditions
Run Keyword If ${GLOBAL_FLAG} Conditional Keyword
Run Keyword Unless ${local_value} == "true" Conditional Keyword
Run Keyword If ${condition}
... Keyword ${arg}
... ELSE IF ${condition2} Keyword2
... ELSE Keyword3
Use IF instead:
*** Test Cases ***
Test with conditions
IF ${GLOBAL_FLAG} Conditional Keyword
IF not (${local_value} == "true") Conditional Keyword
Keyword
IF ${condition}
Keyword ${arg}
ELSE IF ${condition2}
Keyword2
ELSE
Keyword3
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DEPR09: deprecated-loop-keyword¶
Added: v8.0.0
Supported RF version >=5.0
Fix availability: There is no automatic fix.
Message:
'{statement_name}' is deprecated, use '{alternative}' instead
Documentation:
Loop keywords are deprecated.
The following loop keywords are deprecated:
Continue For LoopContinue For Loop IfExit For LoopExit For Loop If
Use CONTINUE and BREAK instead.
Incorrect code example:
*** Test Cases ***
Test with loops
WHILE ${condition}
Continue For Loop If ${second_condition}
Continue For Loop
END
FOR ${var} IN RANGE 10
Exit For Loop If ${var} = 5
Exit For Loop
END
Correct code:
*** Test Cases ***
Test with loops
WHILE ${condition}
First Keyword
IF ${second_condition} CONTINUE
CONTINUE
END
FOR ${var} IN RANGE 10
IF ${var} = 0 BREAK
BREAK
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DEPR10: deprecated-return-keyword¶
Added: v8.0.0
Supported RF version >=5.0
Fix availability: Fix is always available.
Message:
'{statement_name}' is deprecated, use '{alternative}' instead
Documentation:
Return From Keyword and Return From Keyword If keywords are deprecated.
Use RETURN or IF <condition> RETURN instead.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DEPR11: deprecated-return-setting¶
Added: v8.0.0
Supported RF version >=5.0
Fix availability: Fix is always available.
Message:
'[Return]' is deprecated, use 'RETURN' instead
Documentation:
[Return] settings is deprecated.
Use RETURN instead.
Incorrect code example:
*** Keywords ***
Return One Value
[Arguments] ${arg}
${value} Convert To Upper Case ${arg}
[Return] ${value}
Correct code:
*** Keywords ***
Return One Value
[Arguments] ${arg}
${value} Convert To Upper Case ${arg}
RETURN ${value}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
Documentation¶
Rules for documentation.
DOC01: missing-doc-keyword¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0201
Fix availability: There is no automatic fix.
Message:
Missing documentation in '{name}' keyword
Documentation:
Keyword without documentation.
Keyword documentation is displayed in a tooltip in most code editors, so it is recommended to write it for each keyword.
You can add documentation to keyword using following syntax:
*** Keywords ***
Keyword
[Documentation] Keyword documentation
Keyword Step
Other Step
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DOC02: missing-doc-test-case¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0202
Fix availability: There is no automatic fix.
Message:
Missing documentation in '{name}' test case
Documentation:
Test case without documentation.
You can add documentation to test case using following syntax:
*** Test Cases ***
Test
[Documentation] Test documentation
Keyword Step
Other Step
The rule by default ignores templated test cases but it can be configured with:
robocop check --configure missing-doc-test-case.ignore_templated=False
Possible values are: Yes / 1 / True (default) or No / False / 0.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
ignore_templated
Whether templated tests should be documented or not
Default value: True
Type: bool
DOC03: missing-doc-suite¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0203
Fix availability: There is no automatic fix.
Message:
Missing documentation in suite
Documentation:
Test suite without documentation.
You can add documentation to suite using following syntax:
*** Settings ***
Documentation Suite documentation
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DOC04: missing-doc-resource-file¶
Added: v2.8.0
Supported RF version All
Deprecated names: 0204
Fix availability: There is no automatic fix.
Message:
Missing documentation in resource file
Documentation:
Resource file without documentation.
You can add documentation to resource file using following syntax:
*** Settings ***
Documentation Resource file documentation
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
Duplications¶
Rules for duplicated code such as settings or variables.
DUP01: duplicated-test-case¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0801
Fix availability: There is no automatic fix.
Message:
Multiple test cases with name '{name}' (first occurrence in line {first_occurrence_line})
Documentation:
Multiple test cases with the same name in the suite.
It is not allowed to reuse the same name of the test case within the same suite in Robot Framework. Name matching is case-insensitive and ignores spaces and underscore characters.
Incorrect code example:
*** Test Cases ***
Test with name
No Operation
test_with Name
No Operation
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
DUP02: duplicated-keyword¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0802
Fix availability: There is no automatic fix.
Message:
Multiple keywords with name '{name}' (first occurrence in line {first_occurrence_line})
Documentation:
Multiple keywords with the same name in the file.
Do not define keywords with the same name inside the same file. Name matching is case-insensitive and ignores spaces and underscore characters.
Incorrect code example:
*** Keywords ***
Keyword
No Operation
keyword
No Operation
K_eywor d
No Operation
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
DUP03: duplicated-variable¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0803
Fix availability: There is no automatic fix.
Message:
Multiple variables with name '{name}' in Variables section (first occurrence in line {first_occurrence_line})
Documentation:
Multiple variables with the same name in the file.
Variable names in Robot Framework are case-insensitive and ignore spaces and underscores. Following variables are duplicates:
*** Variables ***
${variable} 1
${VARIAble} a
@{variable} a b
${v ariabl e} c
${v_ariable} d
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
DUP04: duplicated-resource¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0804
Fix availability: There is no automatic fix.
Message:
Multiple resource imports with path '{name}' (first occurrence in line {first_occurrence_line})
Documentation:
Duplicated resource imports.
Avoid re-importing the same imports.
Incorrect code example:
*** Settings ***
Resource path.resource
Resource other_path.resource
Resource path.resource
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DUP05: duplicated-library¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0805
Fix availability: There is no automatic fix.
Message:
Multiple library imports with name '{name}' and identical arguments (first occurrence in line {first_occurrence_line})
Documentation:
Duplicated library imports.
If you need to reimport library use alias:
*** Settings ***
Library RobotLibrary
Library RobotLibrary AS OtherRobotLibrary
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DUP06: duplicated-metadata¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0806
Fix availability: There is no automatic fix.
Message:
Duplicated metadata '{name}' (first occurrence in line {first_occurrence_line})
Documentation:
Duplicated metadata.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DUP07: duplicated-variables-import¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0807
Fix availability: There is no automatic fix.
Message:
Duplicated variables import with path '{name}' (first occurrence in line {first_occurrence_line})
Documentation:
Duplicated variables import.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DUP08: section-already-defined¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0808
Fix availability: There is no automatic fix.
Message:
'{section_name}' section header already defined in file (first occurrence in line {first_occurrence_line})
Documentation:
Section header already defined in the file.
Duplicated section in the file. Robot Framework will handle repeated sections but it is recommended to not duplicate them.
Incorrect code example:
*** Test Cases ***
My Test
Keyword
*** Keywords ***
Keyword
No Operation
*** Test Cases *** # duplicate
Other Test
Keyword
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
DUP09: both-tests-and-tasks¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0810
Fix availability: There is no automatic fix.
Message:
Both Task(s) and Test Case(s) section headers defined in file
Documentation:
Both Task(s) and Test Case(s) section headers defined in file.
The file contains both *** Test Cases *** and *** Tasks *** sections. Use only one of them. :
*** Test Cases ***
*** Tasks ***
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
DUP10: duplicated-setting¶
Added: v2.0
Supported RF version All
Deprecated names: 0813
Fix availability: There is no automatic fix.
Message:
{error_msg}
Documentation:
Duplicated setting.
Some settings can be used only once in a file. Only the first value is used.
Example:
*** Settings ***
Test Tags F1
Test Tags F2 # this setting will be ignored
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
Errors¶
Rules for syntax errors and critical issues with the code.
ERR01: parsing-error¶
Added: v1.0.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Robot Framework syntax error: {error_msg}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR03: missing-keyword-name¶
Added: v1.8.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Missing keyword name when calling some values
Documentation:
Missing keyword name.
Example of rule violation:
*** Keywords ***
Keyword
${var}
${one} ${two}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR04: variables-import-with-args¶
Added: v1.11.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
YAML variable files do not take arguments
Documentation:
YAML variables file import with arguments.
Example of rule violation:
*** Settings ***
Variables vars.yaml arg1
Variables variables.yml arg2
Variables module arg3 # valid from RF > 5
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR05: invalid-continuation-mark¶
Added: v1.11.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Invalid continuation mark '{mark}'. It should be '...'
Documentation:
Invalid continuation mark.
Example of rule violation:
Keyword
.. ${var} # .. instead of ...
... 1
.... 2 # .... instead of ...
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR08: non-existing-setting¶
Added: v1.11.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
{error_msg}
Documentation:
Non-existing setting used in the code.
Example of rule violation:
*** Test Cases *** Test case [Not Existing] arg [Arguments] ${arg}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR09: setting-not-supported¶
Added: v1.11.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Setting '[{setting_name}]' is not supported in {test_or_keyword}. Allowed are: {allowed_settings}
Documentation:
Not supported setting.
The following settings are supported in Test Case or Task:
*** Test Cases ***
Test case
[Documentation] Used for specifying a test case documentation.
[Tags] Used for tagging test cases.
[Setup] Used for specifying a test setup.
[Teardown] Used for specifying a test teardown.
[Template] Used for specifying a template keyword.
[Timeout] Used for specifying a test case timeout.
The following settings are supported in Keyword:
*** Keywords ***
Keyword
[Documentation] Used for specifying a user keyword documentation.
[Tags] Used for specifying user keyword tags.
[Arguments] Used for specifying user keyword arguments.
[Return] Used for specifying user keyword return values.
[Teardown] Used for specifying user keyword teardown.
[Timeout] Used for specifying a user keyword timeout.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR12: invalid-for-loop¶
Added: v1.0.0
Supported RF version >=4.0
Fix availability: There is no automatic fix.
Message:
Invalid for loop syntax: {error_msg}
Documentation:
Invalid FOR loop syntax.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR13: invalid-if¶
Added: v1.0.0
Supported RF version >=4.0
Fix availability: There is no automatic fix.
Message:
Invalid IF syntax: {error_msg}
Documentation:
Invalid IF syntax.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR14: return-in-test-case¶
Added: v2.0.0
Supported RF version >=5.0
Fix availability: There is no automatic fix.
Message:
RETURN can only be used inside a user keyword
Documentation:
RETURN used outside the user keyword.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR15: invalid-section-in-resource¶
Added: v3.1.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Resource file can't contain '{section_name}' section
Documentation:
Resource file with a not supported section.
The higher-level structure of resource files is the same as that of test case files, but they can't contain Test Cases or Tasks sections.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR16: invalid-setting-in-resource¶
Added: v3.3.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Settings section in resource file can't contain '{section_name}' setting
Documentation:
Not supported setting in the *** Settings *** section in a resource file.
The Setting section in resource files can contain only import settings (Library,
Resource, Variables), Documentation and Keyword Tags.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
ERR17: unsupported-setting-in-init-file¶
Added: v3.3.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Setting '{setting}' is not supported in initialization files
Documentation:
Not supported setting in a initialization file.
Settings Default Tags and Test Template are not supported in initialization files.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
Imports¶
Rules for resources, variables and libraries imports.
IMP01: wrong-import-order¶
Added: v1.7.0
Supported RF version All
Deprecated names: 0911
Fix availability: There is no automatic fix.
Message:
BuiltIn library import '{builtin_import}' should be placed before '{custom_import}'
Documentation:
Built-in imports placed after custom imports.
To make code more readable, it needs to be more consistent. That's why it is recommended to group known, built-in import before custom imports.
Example of rule violation:
*** Settings ***
Library Collections
Library CustomLibrary
Library OperatingSystem # BuiltIn library defined after custom CustomLibrary
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
IMP02: builtin-imports-not-sorted¶
Added: v5.2.0
Supported RF version All
Deprecated names: 0926
Fix availability: There is no automatic fix.
Message:
BuiltIn library import '{builtin_import}' should be placed before '{previous_builtin_import}'
Documentation:
Built-in imports are not sorted in alphabetical order.
To increase readability, sort the imports in alphabetical order.
Example of rule violation:
*** Settings ***
Library OperatingSystem
Library Collections # BuiltIn libraries imported not in alphabetical order
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
IMP03: non-builtin-imports-not-sorted¶
Rule is disabled by default. Enable it by using
--select non-builtin-imports-not-sortedoption.
Added: v5.2.0
Supported RF version All
Deprecated names: 10101
Fix availability: There is no automatic fix.
Message:
Non builtin library import '{custom_import}' should be placed before '{previous_custom_import}'
Documentation:
Custom imports are not sorted in alphabetical order.
To increase readability, sort the imports in alphabetical order. Beware that depending on your code, some of the custom imports may be depending on each other and the order of the imports.
Example of rule violation:
*** Settings ***
Library Collections
Library CustomLibrary
Library AnotherCustomLibrary # AnotherCustomLibrary library defined after custom CustomLibrary
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
IMP04: resources-imports-not-sorted¶
Rule is disabled by default. Enable it by using
--select resources-imports-not-sortedoption.
Added: v5.2.0
Supported RF version All
Deprecated names: 10102
Fix availability: There is no automatic fix.
Message:
Resource import '{resource_import}' should be placed before '{previous_resource_import}'
Documentation:
Resources imports are not sorted in alphabetical order.
To increase readability, sort the resources imports in a alphabetical order. Beware that depending on your code, some imports may depend on each other and the order of the imports.
Example of rule violation:
*** Settings ***
Resource CustomResource.resource
Resource AnotherFile.resource
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
Keywords¶
Rules for keywords.
KW01: sleep-keyword-used¶
Rule is disabled by default. Enable it by using
--select sleep-keyword-usedoption.
Added: v5.0.0
Supported RF version All
Deprecated names: 10001
Fix availability: There is no automatic fix.
Message:
Sleep keyword with '{duration_time}' sleep time found
Documentation:
Sleep keyword used.
Avoid using Sleep keyword in favour of polling.
For example:
*** Keywords ***
Add To Cart
[Arguments] ${item_name}
Sleep 30s # wait for page to load
Element Should Be Visible ${MAIN_HEADER}
Click Element //div[@name='${item_name}']/div[@id='add_to_cart']
Can be rewritten to:
*** Keywords ***
Add To Cart
[Arguments] ${item_name}
Wait Until Element Is Visible ${MAIN_HEADER}
Click Element //div[@name='${item_name}']/div[@id='add_to_cart']
It is also possible to report only if Sleep exceeds given time limit using max_time parameter:
robocop check -c sleep-keyword-used.max_time=1min .
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_time
Maximum amount of time allowed in sleep
Default value: 0
Type: timestr_to_secs
KW02: not-allowed-keyword¶
Rule is disabled by default. Enable it by using
--select not-allowed-keywordoption.
Added: v5.1.0
Supported RF version All
Deprecated names: 10002
Fix availability: There is no automatic fix.
Message:
Keyword '{keyword}' is not allowed
Documentation:
Reports usage of not allowed keywords.
Configure which keywords should be reported by using keywords parameter.
Keyword names are normalized to match Robot Framework search behaviour (lower case, removed whitespace and
underscores).
For example:
> robocop check --select not-allowed-keyword -c not-allowed-keyword.keywords=click_using_javascript
: # TODO
*** Keywords ***
Keyword With Obsolete Implementation
[Arguments] ${locator}
Click Using Javascript ${locator} # Robocop will report not allowed keyword
If keyword call contains possible library name (i.e. Library.Keyword Name), Robocop checks if it matches the not allowed keywords and if not, it will remove library part and check again.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
keywords
Comma separated list of not allowed keywords
Default value: None
Type: comma_separated_list
KW03: no-embedded-keyword-arguments¶
Rule is disabled by default. Enable it by using
--select no-embedded-keyword-argumentsoption.
Added: v5.5.0
Supported RF version All
Deprecated names: 10003
Fix availability: There is no automatic fix.
Message:
Keyword with embedded arguments: {arguments}
Documentation:
Embedded arguments in keyword found.
Avoid using embedded arguments in keywords.
When using embedded keyword arguments, you mix what you do (the keyword name) with the data related to the action (the arguments). Mixing these two concepts can create hard-to-understand code, which can result in mistakes in your test code.
Embedded keyword arguments can also make it hard to understand which keyword you're using. Sometimes even Robotframework gets confused when naming conflicts occur. There are ways to fix naming conflicts, but this adds unnecessary complexity to your keyword.
To prevent these issues, use normal arguments instead.
Using a keyword with one embedded argument. Buying the drink and the size of the drink are jumbled together:
*** Test Cases ***
Prepare for an amazing movie
Buy a large soda
*** Keywords ***
Buy a ${size} soda
# Do something wonderful
Change the embedded argument to a normal argument. Now buying the drink is separate from the size of the drink. In this approach, it's easier to see that you can change the size of your drink:
*** Test Cases ***
Prepare for an amazing movie
Buy a soda size=large
*** Keywords ***
Buy a soda
[Arguments] ${size}
# Do something wonderful
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
KW04: unused-keyword¶
Warning
Rule is deprecated.
Added: v5.3.0
Supported RF version All
Deprecated names: 10101
Fix availability: There is no automatic fix.
Message:
Keyword '{keyword_name}' is not used
Documentation:
Keyword is not used.
Reports not used keywords.
Example:
*** Test Cases ***
Test that only non used keywords are reported
Used Keyword
*** Keywords ***
Not Used Keyword # this keyword will be reported as not used
[Arguments] ${arg}
Should Be True ${arg}>50
Rule is under development - may report false negatives or positives. Currently it does only support keywords from suites and private keywords. If the keyword is called dynamically (for example through variable) it will be not detected as used.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
Lengths¶
Rules for lengths, such as length of the test case or the file.
LEN01: too-long-keyword¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0501
Fix availability: There is no automatic fix.
Message:
Keyword '{keyword_name}' is too long ({keyword_length}/{allowed_length})
Documentation:
Keyword is too long.
Avoid too long keywords for readability and maintainability.
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_lenwill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_len- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_len
Number of lines allowed in a keyword
Default value: 40
Type: int
ignore_docs
Ignore documentation
Default value: False
Type: bool
LEN02: too-few-calls-in-keyword¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0502
Fix availability: There is no automatic fix.
Message:
Keyword '{keyword_name}' has too few keywords inside ({keyword_count}/{min_allowed_count})
Documentation:
Too few keyword calls in keyword.
Consider if the custom keyword is required at all.
Incorrect code example:
*** Test Cases ***
Test
Thin Wrapper
*** Keywords ***
Thin Wrapper
Other Keyword ${arg}
Correct code example:
*** Test Cases ***
Test
Other Keyword ${arg}
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
min_callswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
min_calls- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
min_calls
Number of keyword calls required in a keyword
Default value: 1
Type: int
LEN03: too-many-calls-in-keyword¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0503
Fix availability: There is no automatic fix.
Message:
Keyword '{keyword_name}' has too many keywords inside ({keyword_count}/{max_allowed_count})
Documentation:
Too many keyword calls in keyword.
Avoid too long keywords for readability and maintainability.
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_callswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_calls- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_calls
Number of keyword calls allowed in a keyword
Default value: 10
Type: int
LEN04: too-long-test-case¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0504
Fix availability: There is no automatic fix.
Message:
Test case '{test_name}' is too long ({test_length}/{allowed_length})
Documentation:
Test case is too long.
Avoid too long test cases for readability and maintainability.
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_lenwill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_len- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_len
Number of lines allowed in a test case
Default value: 20
Type: int
ignore_docs
Ignore documentation
Default value: False
Type: bool
ignore_templated
Ignore templated tests
Default value: False
Type: bool
LEN05: too-few-calls-in-test-case¶
Added: v2.4.0
Supported RF version All
Deprecated names: 0528
Fix availability: There is no automatic fix.
Message:
Test case '{test_name}' has too few keywords inside ({keyword_count}/{min_allowed_count})
Documentation:
Too few keyword calls in test cases.
Test without keywords will fail. Add more keywords or set results using Fail, Pass Execution or
Skip keywords:
*** Test Cases ***
Test case
[Tags] smoke
Skip Test case draft
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
min_calls
Number of keyword calls required in a test case
Default value: 1
Type: int
ignore_templated
Ignore templated tests
Default value: False
Type: bool
LEN06: too-many-calls-in-test-case¶
Added: v1.0.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Test case '{test_name}' has too many keywords inside ({keyword_count}/{max_allowed_count})
Documentation:
Too many keyword calls in test case.
Redesign the test and move complex logic to separate keywords to increase readability.
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_callswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_calls- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_calls
Number of keyword calls allowed in a test case
Default value: 10
Type: int
ignore_templated
Ignore templated tests
Default value: False
Type: bool
LEN07: too-many-arguments¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0507
Fix availability: There is no automatic fix.
Message:
Keyword '{keyword_name}' has too many arguments ({arguments_count}/{max_allowed_count})
Documentation:
Keyword has too many arguments.
Style guide:
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_argswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_args- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_args
Number of lines allowed in a file
Default value: 5
Type: int
LEN08: line-too-long¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0508
Fix availability: There is no automatic fix.
Message:
Line is too long ({line_length}/{allowed_length})
Documentation:
The line is too long.
Comments with disabler directives (such as # robocop: off) are ignored. Lines that contain URLs are also
ignored.
It is possible to ignore lines that match the regex pattern. Configure it using the following option:
robocop check --configure line-too-long.ignore_pattern=pattern
Style guide:
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
line_lengthwill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
line_length- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
line_length
Number of characters allowed in line
Default value: 120
Type: int
ignore_pattern
Ignore lines that contain configured pattern
Default value: None
Type: regex
LEN09: empty-section¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0509
Fix availability: There is no automatic fix.
Message:
Section '{section_name}' is empty
Documentation:
Section is empty.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN10: number-of-returned-values¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0510
Fix availability: There is no automatic fix.
Message:
Too many return values ({return_count}/{max_allowed_count})
Documentation:
Too many return values.
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_returnswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_returns- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_returns
Allowed number of returned values from a keyword
Default value: 4
Type: int
LEN11: empty-metadata¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0511
Fix availability: There is no automatic fix.
Message:
Metadata settings does not have any value set
Documentation:
Metadata settings do not have any value set.
Incorrect code example:
*** Settings ***
Metadata
Correct code example:
*** Settings ***
Metadata Platform ${PLATFORM}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN12: empty-documentation¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0512
Fix availability: There is no automatic fix.
Message:
Documentation of {block_name} is empty
Documentation:
Documentation is empty.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN13: empty-force-tags¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0513
Fix availability: There is no automatic fix.
Message:
Force Tags are empty
Documentation:
Force Tags are empty.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN14: empty-default-tags¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0514
Fix availability: There is no automatic fix.
Message:
Default Tags are empty
Documentation:
Default Tags are empty.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN15: empty-variables-import¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0515
Fix availability: There is no automatic fix.
Message:
Import variables path is empty
Documentation:
Import variables path is empty.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN16: empty-resource-import¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0516
Fix availability: There is no automatic fix.
Message:
Import resource path is empty
Documentation:
Import resources path is empty.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN17: empty-library-import¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0517
Fix availability: There is no automatic fix.
Message:
Import library path is empty
Documentation:
Import library path is empty.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN18: empty-setup¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0518
Fix availability: There is no automatic fix.
Message:
Setup of {block_name} does not have any keywords
Documentation:
Empty setup.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN19: empty-suite-setup¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0519
Fix availability: There is no automatic fix.
Message:
Suite Setup does not have any keywords
Documentation:
Empty Suite Setup.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN20: empty-test-setup¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0520
Fix availability: There is no automatic fix.
Message:
Test Setup does not have any keywords
Documentation:
Empty Test Setup.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN21: empty-teardown¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0521
Fix availability: There is no automatic fix.
Message:
Teardown of {block_name} does not have any keywords
Documentation:
Empty Teardown.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN22: empty-suite-teardown¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0522
Fix availability: There is no automatic fix.
Message:
Suite Teardown does not have any keywords
Documentation:
Empty Suite Teardown.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN23: empty-test-teardown¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0523
Fix availability: There is no automatic fix.
Message:
Test Teardown does not have any keywords
Documentation:
Empty Test Teardown.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN24: empty-timeout¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0524
Fix availability: There is no automatic fix.
Message:
Timeout of {block_name} is empty
Documentation:
Empty Timeout.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN25: empty-test-timeout¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0525
Fix availability: There is no automatic fix.
Message:
Test Timeout is empty
Documentation:
Empty Test Timeout.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN26: empty-arguments¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0526
Fix availability: There is no automatic fix.
Message:
Arguments of {block_name} are empty
Documentation:
Empty [Arguments] setting.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN27: too-many-test-cases¶
Added: v1.10.0
Supported RF version All
Deprecated names: 0527
Fix availability: There is no automatic fix.
Message:
Too many test cases ({test_count}/{max_allowed_count})
Documentation:
Too many test cases.
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_testcases or max_templated_testcaseswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_testcases or max_templated_testcases- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_testcases
Number of test cases allowed in a suite
Default value: 50
Type: int
max_templated_testcases
Number of test cases allowed in a templated suite
Default value: 100
Type: int
LEN28: file-too-long¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0506
Fix availability: There is no automatic fix.
Message:
File has too many lines ({lines_count}/{max_allowed_count})
Documentation:
File has too many lines.
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_lineswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_lines- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_lines
Number of lines allowed in a file
Default value: 400
Type: int
LEN29: empty-test-template¶
Added: v3.1.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Test Template is empty
Documentation:
Test Template is empty.
Test Template sets the template to all tests in a suite. Empty value is considered an error
because it leads the users to wrong impression on how the suite operates.
Without value, the setting is ignored and the tests are not templated.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
LEN30: empty-template¶
Added: v3.1.0
Supported RF version All
Deprecated names: 0530
Fix availability: There is no automatic fix.
Message:
Template of {block_name} is empty. To overwrite suite Test Template use more explicit [Template] NONE
Documentation:
[Template] is empty.
The [Template] setting overrides the possible template set in the Setting section, and an empty value for
[Template] means that the test has no template even when Test Template is used.
If it is intended behavior, use a more explicit NONE value to indicate that you want to overwrite suite
Test Template:
*** Settings ***
Test Template Template Keyword
*** Test Cases ***
Templated test
argument
Not templated test
[Template] NONE
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN31: empty-keyword-tags¶
Added: v3.3.0
Supported RF version >=6
Deprecated names: 0531
Fix availability: There is no automatic fix.
Message:
Keyword Tags are empty
Documentation:
Keyword Tags are empty.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
LEN32: too-long-variable-name¶
Added: v6.7.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Variable name '{variable_name}' is too long ({variable_name_length}/{allowed_length})
Documentation:
Variable name is too long.
Avoid too long variable names for readability and maintainability.
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_lenwill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_len- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
max_len
Allowed length of a variable name
Default value: 40
Type: int
Miscellaneous¶
Miscellaneous rules.
MISC01: keyword-after-return¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0901
Fix availability: There is no automatic fix.
Message:
{error_msg}
Documentation:
Keyword call after the [Return] setting.
To improve readability, use [Return] setting at the end of the keyword. If you want to return immediately
from the keyword, use the RETURN statement instead. [Return] does not return from the keyword but only
sets the values that will be returned at the end of the keyword.
Incorrect code example:
*** Keywords ***
Keyword
Step
[Return] ${variable}
${variable} Other Step
Correct code:
*** Keywords ***
Keyword
Step
${variable} Other Step
[Return] ${variable}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
MISC02: empty-return¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0903
Fix availability: There is no automatic fix.
Message:
[Return] is empty
Documentation:
[Return] is empty.
[Return] statement is used to define variables returned from keyword. If you don't return anything from
a keyword, don't use [Return].
Incorrect code example:
*** Keywords ***
Keyword
Gather Results
Assert Results
[Return]
Correct code:
*** Keywords ***
Keyword
Gather Results
Assert Results
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
MISC03: nested-for-loop¶
Added: v1.0.0
Supported RF version <4.0
Deprecated names: 0907
Fix availability: There is no automatic fix.
Message:
Not supported nested for loop
Documentation:
Not supported nested for loop.
Older versions of Robot Framework did not support nested for loops:
*** Test Cases
Test case
FOR ${var} IN RANGE 10
FOR ${other_var} IN a b
# Nesting supported from Robot Framework 4.0+
END
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
MISC04: inconsistent-assignment¶
Added: v1.7.0
Supported RF version All
Deprecated names: 0909
Fix availability: There is no automatic fix.
Message:
The assignment sign is not consistent within the file. Expected '{expected_sign}' but got '{actual_sign}' instead
Documentation:
Not consistent assignment sign in the file.
Use only one type of assignment sign in a file.
Incorrect code example:
*** Keywords ***
Keyword
${var} = Other Keyword
No Operation
Keyword 2
No Operation
${var} ${var2} Some Keyword
Correct code:
*** Keywords ***
Keyword
${var} Other Keyword
No Operation
Keyword 2
No Operation
${var} ${var2} Some Keyword
By default, Robocop looks for the most popular assignment sign in the file. It is possible to define the expected assignment sign:
You can choose between the following assignment signs:
- 'autodetect' (default),
- 'none',
- 'equal_sign' (
=) - 'space_and_equal_sign' (
=).
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
assignment_sign_type
Possible values: 'autodetect' (default), 'none' (''), 'equal_sign' ('=') or space_and_equal_sign (' =')
Default value: autodetect
Type: assignment sign type
MISC05: inconsistent-assignment-in-variables¶
Added: v1.7.0
Supported RF version All
Deprecated names: 0910
Fix availability: There is no automatic fix.
Message:
The assignment sign is not consistent inside the variables section. Expected '{expected_sign}' but got '{actual_sign}' instead
Documentation:
Not consistent assignment sign in the *** Variables *** section.
Use one type of assignment sign in the Variables section.
Incorrect code example:
*** Variables ***
${var} = 1
${var2}= 2
${var3} = 3
${var4} a
${var5} b
Correct code:
*** Variables ***
${var} 1
${var2} 2
${var3} 3
${var4} a
${var5} b
By default, Robocop looks for the most popular assignment sign in the file. It is possible to define the expected assignment sign by running:
robocop check --configure inconsistent-assignment-in-variables.assignment_sign_type=equal_sign
You can choose between the following signs:
- 'autodetect' (default),
- 'none',
- 'equal_sign' (
=) - 'space_and_equal_sign' (
=).
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
assignment_sign_type
Possible values: 'autodetect' (default), 'none' (''), 'equal_sign' ('=') or space_and_equal_sign (' =')
Default value: autodetect
Type: assignment sign type
MISC06: can-be-resource-file¶
Added: v1.10.0
Supported RF version All
Deprecated names: 0913
Fix availability: There is no automatic fix.
Message:
No tests in '{file_name}' file, consider renaming to '{file_name_stem}.resource'
Documentation:
No tests in the file, consider renaming the file extension to .resource.
If the Robot file contains only keywords or variables, it's a good practice to use .resource extension.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
MISC07: if-can-be-merged¶
Added: v2.0.0
Supported RF version >=4.0
Deprecated names: 0914
Fix availability: There is no automatic fix.
Message:
IF statement can be merged with previous IF (defined in line {line})
Documentation:
IF statement can be merged with the previous IF.
IF statement follows another IF with identical conditions. It can be possibly merged into one.
Example of rule violation:
*** Test Cases ***
Test case
IF ${var} == 4
Keyword
END
# comments are ignored
IF ${var} == 4
Keyword 2
END
IF statement is considered identical only if all branches have identical conditions.
Similar but not identical IF:
*** Test Cases ***
Test case
IF ${variable}
Keyword
ELSE
Other Keyword
END
IF ${variable}
Keyword
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
MISC08: statement-outside-loop¶
Added: v2.0.0
Supported RF version >=5.0
Deprecated names: 0915
Fix availability: There is no automatic fix.
Message:
{name} {statement_type} used outside a loop
Documentation:
Loop statement used outside loop.
Following keywords and statements should only be used inside loop (WHILE or FOR):
- Exit For Loop
- Exit For Loop If
- Continue For Loop
- Continue For Loop If
- CONTINUE
- BREAK
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
MISC09: inline-if-can-be-used¶
Added: v2.0.0
Supported RF version >=5.0
Deprecated names: 0916
Fix availability: There is no automatic fix.
Message:
IF can be replaced with inline IF
Documentation:
IF can be replaced with inline IF.
Short and simple IF statements can be replaced with inline IF.
Following IF:
IF $condition
BREAK
END
can be replaced with:
IF $condition BREAK
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
max_widthwill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
max_width- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
max_width
Maximum width of if (in characters) below which it will be recommended to use inline if
Default value: 80
Type: int
MISC10: unreachable-code¶
Added: v3.1.0
Supported RF version >=5.0
Deprecated names: 0917
Fix availability: There is no automatic fix.
Message:
Unreachable code after {statement} statement
Documentation:
Unreachable code.
Detects the unreachable code after RETURN, BREAK or CONTINUE statements.
For example:
*** Keywords ***
Example Keyword
FOR ${animal} IN cat dog
IF '${animal}' == 'cat'
CONTINUE
Log ${animal} # unreachable log
END
BREAK
Log Unreachable log
END
RETURN
Log Unreachable log
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
MISC11: multiline-inline-if¶
Added: v3.1.0
Supported RF version >=5.0
Deprecated names: 0918
Fix availability: There is no automatic fix.
Message:
Inline IF split to multiple lines
Documentation:
Multi-line inline IF.
It's allowed to create inline IF that spans multiple lines, but it should be avoided,
since it decreases readability. Try to use normal IF/ELSE instead.
Incorrect code example:
*** Keywords ***
Keyword
IF ${condition} Log hello
... ELSE Log hi!
Correct code:
*** Keywords ***
Keyword
IF ${condition} Log hello ELSE Log hi!
or IF block can be used:
*** Keywords ***
Keyword
IF ${condition}
Log hello
ELSE
Log hi!
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
MISC12: unnecessary-string-conversion¶
Warning
Rule is deprecated.
Added: v4.0.0
Supported RF version >=4.0
Deprecated names: 0923
Fix availability: There is no automatic fix.
Message:
Variable '{name}' in '{block_name}' condition has unnecessary string conversion
Documentation:
Variable in the condition has unnecessary string conversion.
Expressions in Robot Framework are evaluated using Python's eval function. When a variable is used
in the expression using the normal ${variable} syntax, its value is replaced before the expression
is evaluated. For example, with the following expression:
*** Test Cases ***
Check if schema was uploaded
Upload Schema schema.avsc
Check If File Exist In SFTP schema.avsc
*** Keywords ***
Upload Schema
[Arguments] ${filename}
IF ${filename} == 'default'
${filename} Get Default Upload Path
END
Send File To SFTP Root ${filename}
"${filename}" will be replaced by "schema.avsc":
IF schema.avsc == 'default'
"schema.avsc" will not be recognized as Python variable. That's why you need to quote it:
IF '${filename}' == 'default'
However, it introduces unnecessary string conversion and can mask difference in the type. For example:
${numerical} Set Variable 10 # ${numerical} is actually string 10, not integer 10
IF "${numerical}" == "10"
You can use $variable syntax instead:
IF $numerical == 10
It will put the actual variable in the evaluated expression without converting it to string.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
MISC13: expression-can-be-simplified¶
Added: v4.0.0
Supported RF version >=4.0
Deprecated names: 0924
Fix availability: There is no automatic fix.
Message:
'{block_name}' condition can be simplified
Documentation:
Condition can be simplified.
Evaluated expression can be simplified.
Incorrect code example:
*** Keywords ***
Click On Element
[Arguments] ${locator}
IF ${is_element_visible}==${TRUE} RETURN
${is_element_enabled} Set Variable ${TRUE}
WHILE ${is_element_enabled} != ${TRUE}
${is_element_enabled} Get Element Status ${locator}
END
Click ${locator}
Correct code:
*** Keywords ***
Click On Element
[Arguments] ${locator}
IF ${is_element_visible} RETURN
${is_element_enabled} Set Variable ${FALSE}
WHILE not ${is_element_enabled}
${is_element_enabled} Get Element Status ${locator}
END
Click ${locator}
Comparisons to empty sequences (lists, dicts, sets), empty string or 0 can be also simplified:
*** Test Cases ***
Check conditions
Should Be True ${list} == [] # equivalent of 'not ${list}'
Should Be True ${string} != "" # equivalent of '${string}'
Should Be True len(${sequence})) # equivalent of '${sequence}'
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
MISC14: misplaced-negative-condition¶
Added: v4.0.0
Supported RF version >=4.0
Deprecated names: 0925
Fix availability: There is no automatic fix.
Message:
'{block_name}' condition '{original_condition}' can be rewritten to '{proposed_condition}'
Documentation:
The position of not operator can be changed for better readability.
Incorrect code example:
*** Keywords ***
Check Unmapped Codes
${codes} Get Codes From API
IF not ${codes} is None
FOR ${code} IN @{codes}
Validate Single Code ${code}
END
ELSE
Fail Did not receive codes from API.
END
Correct code:
*** Keywords ***
Check Unmapped Codes
${codes} Get Codes From API
IF ${codes} is not None
FOR ${code} IN @{codes}
Validate Single Code ${code}
END
ELSE
Fail Did not receive codes from API.
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
MISC15: unused-disabler¶
Added: v6.8.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Disabler directive found for '{rule_name}' rule(s) but no violation found
Documentation:
Robocop disabler directive is not used.
Overlapping disablers, code that was already fixed or rules that are disabled globally do not need rule disablers.
Rule violation examples:
*** Keywords ***
Log To Page
${email} Get Email # robocop: off=unused-variable
Log ${email}
FOR ${locator} IN @{email_locators}
# robocop: off
# robocop: off=some-rule
Fill Text ${locator}
END
In the above examples we disable unused-variable rule, but no violation is raised for this line. Also, we define disablers for all rules and some-rule in FOR loop, and all rules disabler overlaps second disabler which is never used.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
Naming¶
Naming rules.
NAME01: not-allowed-char-in-name¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0301
Fix availability: There is no automatic fix.
Message:
Not allowed character '{character}' found in {block_name} name
Documentation:
Not allowed character found.
Reports not allowed characters found in Test Case or Keyword names. By default, it's a dot (.). You can
configure what patterns are reported by calling:
robocop check --configure not-allowed-char-in-name.pattern=regex_pattern
regex_pattern should define a regex pattern not allowed in names. For example, [@\[] pattern
would report any occurrence of @[ characters.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
pattern
Pattern defining characters (not) allowed in a name
Default value: re.compile('[\.\?]')
Type: regex
NAME02: wrong-case-in-keyword-name¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0302
Fix availability: There is no automatic fix.
Message:
Keyword name '{keyword_name}' does not follow case convention
Documentation:
Keyword name does not follow case convention.
Keyword names need to follow a specific case convention.
The convention can be set using the convention parameter and accepts
one of the 2 values: each_word_capitalized or first_word_capitalized.
By default, it's configured to each_word_capitalized, which requires each keyword to follow such
convention:
*** Keywords ***
Fill Out The Form
Provide Shipping Address
Provide Payment Method
Click 'Next' Button
[Teardown] Log Form Data
You can also set it to first_word_capitalized which requires capitalising the first word of the keyword:
*** Keywords ***
Fill out the form
Provide shipping address
Provide payment method
Click 'Next' button
[Teardown] Log form data
The rule also accepts another parameter pattern which can be used to configure words
that are accepted in the keyword name, even though they violate the case convention.
pattern parameter accepts a regex pattern. For example, configuring it to robocop\.readthedocs\.io
would make the following keyword legal:
Go To robocop.readthedocs.io Page
See the sibling rule wrong-case-in-keyword-call that checks keyword call naming convention.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
convention
Possible values: 'each_word_capitalized' (default) or 'first_word_capitalized'
Default value: each_word_capitalized
Type: str
pattern
Pattern for accepted words in keyword
Default value: re.compile('')
Type: regex
NAME03: keyword-name-is-reserved-word¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0303
Fix availability: There is no automatic fix.
Message:
'{keyword_name}' is a reserved keyword{error_msg}
Documentation:
Keyword name is a reserved word.
Do not use reserved names for keyword names. The following names are reserved:
- IF
- ELSE IF
- ELSE
- FOR
- END
- WHILE
- CONTINUE
- RETURN
- TRY
- EXCEPT
- FINALLY
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
NAME04: underscore-in-keyword-name¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0305
Fix availability: There is no automatic fix.
Message:
Underscores in keyword name '{keyword_name}'
Documentation:
Underscores in keyword name.
You can replace underscores with spaces.
Incorrect code example:
keyword_with_underscores
Correct code:
Keyword Without Underscores
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
NAME05: setting-name-not-in-title-case¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0306
Fix availability: There is no automatic fix.
Message:
Setting name '{setting_name}' not in title or uppercase
Documentation:
Setting name not in the title or upper case.
Incorrect code example:
*** Settings ***
resource file.resource
*** Test Cases ***
Test
[documentation] Some documentation
Step
Correct code:
*** Settings ***
Resource file.resource
*** Test Cases ***
Test
[DOCUMENTATION] Some documentation
Step
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
NAME06: section-name-invalid¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0307
Fix availability: There is no automatic fix.
Message:
Section name should be in format '{section_title_case}' or '{section_upper_case}'
Documentation:
Section name does not follow convention.
Section name should use Title Case or CAP CASE case convention.
Incorrect code example:
*** settings ***
*** KEYwords ***
Correct code:
*** SETTINGS ***
*** Keywords ***
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
NAME07: not-capitalized-test-case-title¶
Added: v1.4.0
Supported RF version All
Deprecated names: 0308
Fix availability: There is no automatic fix.
Message:
Test case '{test_name}' title does not start with capital letter
Documentation:
Test case title does not start with a capital letter.
Incorrect code example:
*** Test Cases ***
validate user details
Correct code example:
*** Test Cases ***
Validate user details
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
NAME08: section-variable-not-uppercase¶
Added: v1.4.0
Supported RF version All
Deprecated names: 0309
Fix availability: There is no automatic fix.
Message:
Section variable '{variable_name}' name is not uppercase
Documentation:
Section variable name is not uppercase.
Incorrect code example:
*** Variables ***
${section_variable} value
Correct code:
*** Variables ***
${SECTION_VARIABLE} value
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
NAME09: else-not-upper-case¶
Added: v1.5.0
Supported RF version All
Deprecated names: 0311
Fix availability: There is no automatic fix.
Message:
ELSE and ELSE IF is not uppercase
Documentation:
ELSE and ELSE IF is not uppercase.
Incorrect code example:
*** Keywords ***
Describe Temperature
[Arguments] ${degrees}
If ${degrees} > ${30}
RETURN Hot
else if ${degrees} > ${15}
RETURN Warm
Else
RETURN Cold
Correct code:
*** Keywords ***
Describe Temperature
[Arguments] ${degrees}
IF ${degrees} > ${30}
RETURN Hot
ELSE IF ${degrees} > ${15}
RETURN Warm
ELSE
RETURN Cold
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
NAME10: keyword-name-is-empty¶
Added: v1.8.0
Supported RF version All
Deprecated names: 0312
Fix availability: There is no automatic fix.
Message:
Keyword name is empty
Documentation:
Keyword name is empty.
Remember to always add a keyword name and avoid such code:
*** Keywords ***
# no keyword name here!!!
Log To Console hi
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
NAME11: test-case-name-is-empty¶
Added: v1.8.0
Supported RF version All
Deprecated names: 0313
Fix availability: There is no automatic fix.
Message:
Test case name is empty
Documentation:
Test case name is empty.
Remember to always add a test case name and avoid such code:
*** Test Cases ***
# no test case name here!!!
Log To Console hello
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
NAME12: empty-library-alias¶
Added: v1.10.0
Supported RF version All
Deprecated names: 0314
Fix availability: There is no automatic fix.
Message:
Library alias is empty
Documentation:
Library alias is empty.
Use a non-empty name when using library import with alias.
Incorrect code example:
*** Settings ***
Library CustomLibrary AS
Correct code:
*** Settings ***
Library CustomLibrary AS AnotherName
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
NAME13: duplicated-library-alias¶
Added: v1.10.0
Supported RF version All
Deprecated names: 0315
Fix availability: There is no automatic fix.
Message:
Library alias is the same as original name
Documentation:
Library alias is the same as the original name.
Examples of rule violation:
*** Settings ***
Library CustomLibrary AS CustomLibrary # same as library name
Library CustomLibrary AS Custom Library # same as library name (spaces are ignored)
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
NAME14: bdd-without-keyword-call¶
Added: v1.11.0
Supported RF version All
Deprecated names: 0318
Fix availability: There is no automatic fix.
Message:
BDD reserved keyword '{keyword_name}' not followed by any keyword{error_msg}
Documentation:
BDD keyword isn't followed by any keyword.
When using BDD reserved keywords (such as GIVEN, WHEN, AND, BUT or THEN) use them together with
the name of the keyword to run.
Incorrect code example:
*** Test Cases ***
Test case
Given
When User Log In
Then User Should See Welcome Page
Correct code:
*** Test Cases ***
Test case
Given Setup Is Complete
When User Log In
Then User Should See Welcome Page
Since those words are used for BDD style, it's also recommended not to use them within the user keyword name.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
NAME15: not-allowed-char-in-filename¶
Added: v2.1.0
Supported RF version All
Deprecated names: 0320
Fix availability: There is no automatic fix.
Message:
Not allowed character '{character}' found in {block_name} name
Documentation:
Not allowed character found in filename.
Reports not allowed pattern found in Suite names. By default, it's a dot (.).
You can configure what characters are reported by running:
robocop check --configure not-allowed-char-in-filename.pattern=regex_pattern .
where regex_pattern should define regex pattern for characters not allowed in names. For example [@\[]
pattern would report any occurrence of @[ characters.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
pattern
Pattern defining characters (not) allowed in a name
Default value: re.compile('[\.\?]')
Type: regex
NAME16: invalid-section¶
Added: v3.2.0
Supported RF version >=6.1
Deprecated names: 0325
Fix availability: There is no automatic fix.
Message:
Invalid section '{invalid_section}'
Documentation:
Invalid section found.
Robot Framework 6.1 detects unrecognized sections based on the language defined for the specific files.
Consider using the -- language parameter if the file is defined with a different language.
It is also possible to configure language in the file:
language: pl
*** Przypadki Testowe ***
Wypisz dyrektywÄ™ 4
Log Błąd dostępu
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
NAME17: mixed-task-test-settings¶
Added: v3.3.0
Supported RF version All
Deprecated names: 0326
Fix availability: There is no automatic fix.
Message:
Use {task_or_test}-related setting '{setting}' if {tasks_or_tests} section is used
Documentation:
Task related setting used with *** Test Cases *** or Test related setting used with the *** Tasks ***
section.
If the *** Tasks *** section is present in the file, use task-related settings like Task Setup,
Task Teardown, Task Template, Task Tags and Task Timeout instead of their Test variants.
Similarly, use test-related settings when using the *** Test Cases *** section.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
NAME18: wrong-case-in-keyword-call¶
Added: v7.0.0
Supported RF version All
Fix availability: There is no automatic fix.
Message:
Keyword name '{keyword_name}' does not follow case convention
Documentation:
Keyword call name does not follow case convention.
Keyword names need to follow a specific case convention.
The convention can be set using the convention parameter and accepts
one of the 2 values: each_word_capitalized or first_word_capitalized.
By default, it's configured to each_word_capitalized, which requires each keyword to follow such
convention:
*** Keywords ***
Fill out the form
Provide Shipping Address
Provide Payment Method
Click 'Next' Button
[Teardown] Log Form Data
You can also set it to first_word_capitalized which requires capitalising the first word of the keyword:
*** Keywords ***
Fill out the form
Provide shipping address
Provide payment method
Click 'Next' button
[Teardown] Log form data
The rule also accepts another parameter pattern which can be used to configure words
that are accepted in the keyword name, even though they violate the case convention.
pattern parameter accepts a regex pattern. For example, configuring it to robocop\.readthedocs\.io
would make the following keyword legal:
Go To robocop.readthedocs.io Page
See the sibling rule wrong-case-in-keyword-name that checks keyword definition naming convention.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
convention
Possible values: 'each_word_capitalized' (default) or 'first_word_capitalized'
Default value: each_word_capitalized
Type: str
pattern
Pattern for accepted words in keyword
Default value: re.compile('')
Type: regex
Order¶
Ordering rules.
ORD01: test-case-section-out-of-order¶
Added: v5.3.0
Supported RF version All
Deprecated names: 0927
Fix availability: There is no automatic fix.
Message:
'{section_name}' is in wrong place of Test Case. Recommended order of elements in Test Cases: {recommended_order}
Documentation:
Settings or body in the test case are out of order.
Sections should be defined in order set by the sections_order parameter.
Default order: documentation,tags,timeout,setup,template,keyword,teardown.
To change the default order, use the following option:
robocop check --configure test-case-section-out-of-order.sections_order=comma,separated,list,of,sections
where section should be a case-insensitive name from the list:
- documentation
- tags
- timeout
- setup
- template
- keyword
- teardown
Order of not configured sections is ignored.
Incorrect code example:
*** Test Cases ***
Keyword After Teardown
[Documentation] This is test Documentation
[Tags] tag1 tag2
[Teardown] Log abc
Keyword1
Correct code:
*** Test Cases ***
Keyword After Teardown
[Documentation] This is test Documentation
[Tags] tag1 tag2
Keyword1
[Teardown] Log abc
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
sections_order
Order of sections in comma-separated list
Default value: documentation,tags,timeout,setup,template,keyword,teardown
Type: str
ORD02: keyword-section-out-of-order¶
Added: v5.3.0
Supported RF version All
Deprecated names: 0928
Fix availability: There is no automatic fix.
Message:
'{section_name}' is in wrong place of Keyword. Recommended order of elements in Keyword: {recommended_order}
Documentation:
Settings or body in keyword are out of order.
Sections should be defined in order set by the sections_order parameter.
Default order: documentation,tags,arguments,timeout,setup,keyword,teardown.
To change the default order use following option:
robocop check --configure keyword-section-out-of-order.sections_order=comma,separated,list,of,sections
where section should be case-insensitive name from the list: documentation, tags, arguments, timeout, setup, keyword, teardown. Order of not configured sections is ignored.
Incorrect code example:
*** Keywords ***
Keyword After Teardown
[Tags] tag1 tag2
[Teardown] Log abc
Keyword1
[Documentation] This is keyword Documentation
Correct code example:
*** Keywords ***
Keyword After Teardown
[Documentation] This is keyword Documentation
[Tags] tag1 tag2
Keyword1
[Teardown] Log abc
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
sections_order
Order of sections in comma-separated list
Default value: documentation,tags,arguments,timeout,setup,keyword,teardown
Type: str
ORD03: section-out-of-order¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0809
Fix availability: There is no automatic fix.
Message:
'{section_name}' section header is defined in wrong order: {recommended_order}
Documentation:
Section does not follow the recommended order.
It's advised to use consistent section orders for readability.
Default order: comments,settings,variables,testcases,keywords.
To change the default order, use the following option:
robocop check --configure section-out-of-order.sections_order=comma,separated,list,of,sections
The order of not configured sections is ignored.
Incorrect code example:
*** Settings ***
*** Keywords ***
*** Test Cases ***
Correct code:
*** Settings ***
*** Test Cases ***
*** Keywords ***
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
sections_order
Order of sections in comma-separated list
Default value: settings,variables,testcases,keywords
Type: str
Spacing¶
Spacing and whitespace related rules.
SPC01: trailing-whitespace¶
Added: v1.0.0
Supported RF version All
Deprecated names: 1001
Fix availability: Fix is always available.
Message:
Trailing whitespace at the end of line
Documentation:
Trailing whitespace at the end of the line.
Invisible, unnecessary whitespace can be confusing.
Incorrect code example:
*** Keywords *** \n
Validate Result\n
[Arguments] ${variable}\n
Should Be True ${variable} \n
Correct code:
*** Keywords ***\n
Validate Result\n
[Arguments] ${variable}\n
Should Be True ${variable}\n
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
SPC02: missing-trailing-blank-line¶
Added: v1.0.0
Supported RF version All
Deprecated names: 1002
Fix availability: There is no automatic fix.
Message:
Missing trailing blank line at the end of file
Documentation:
Missing trailing blank line at the end of file.
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
SPC03: empty-lines-between-sections¶
Added: v1.0.0
Supported RF version All
Deprecated names: 1003
Fix availability: There is no automatic fix.
Message:
Invalid number of empty lines between sections ({empty_lines}/{allowed_empty_lines})
Documentation:
Invalid number of empty lines between sections.
Ensure there is the same number of empty lines between sections for consistency and readability.
Incorrect code example:
*** Settings ***
Documentation Only one empty line after this section.
*** Keywords ***
Keyword Definition
No Operation
Correct code:
*** Settings ***
Documentation Only one empty line after this section.
*** Keywords ***
Keyword Definition
No Operation
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
empty_lines
Number of empty lines required between sections
Default value: 2
Type: int
SPC04: empty-lines-between-test-cases¶
Added: v1.0.0
Supported RF version All
Deprecated names: 1004
Fix availability: There is no automatic fix.
Message:
Invalid number of empty lines between test cases ({empty_lines}/{allowed_empty_lines})
Documentation:
Invalid number of empty lines between test cases.
Ensure there is the same number of empty lines between test cases for consistency and readability.
Incorrect code example:
*** Test Cases ***
First test case
No Operation
Second test case
No Operation
Correct code:
*** Test Cases ***
First test case
No Operation
Second test case
No Operation
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
empty_lines
Number of empty lines required between test cases
Default value: 1
Type: int
SPC05: empty-lines-between-keywords¶
Added: v1.0.0
Supported RF version All
Deprecated names: 1005
Fix availability: There is no automatic fix.
Message:
Invalid number of empty lines between keywords ({empty_lines}/{allowed_empty_lines})
Documentation:
Invalid number of empty lines between keywords.
Ensure there is the same number of empty lines between keywords for consistency and readability.
Incorrect code example:
*** Keywords ***
First Keyword
No Operation
Second Keyword
No Operation
Correct code:
*** Keywords ***
First Keyword
No Operation
Second Keyword
No Operation
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
empty_lines
Number of empty lines required between keywords
Default value: 1
Type: int
SPC06: mixed-tabs-and-spaces¶
Added: v1.1.0
Supported RF version All
Deprecated names: 1006
Fix availability: There is no automatic fix.
Message:
Inconsistent use of tabs and spaces in file
Documentation:
Mixed tabs and spaces in the file.
File contains both spaces and tabs. Use only one type of separators - preferably spaces.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
SPC08: bad-indent¶
Added: v3.0.0
Supported RF version All
Deprecated names: 1008
Fix availability: There is no automatic fix.
Message:
{bad_indent_msg}
Documentation:
Line is misaligned or indent is invalid.
This rule reports a warning if the line is misaligned in the current block.
The correct indentation is determined by the most common indentation in the current block.
It is possible to switch for stricter mode using the indent parameter (default -1).
Incorrect code example:
*** Keywords ***
Keyword
Keyword Call
Misaligned Keyword Call
IF $condition RETURN
Keyword Call
Correct code:
*** Keywords ***
Keyword
Keyword Call
Misaligned Keyword Call
IF $condition RETURN
Keyword Call
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
indent
Number of spaces per indentation level
Default value: -1
Type: int
SPC09: empty-line-after-section¶
Added: v1.2.0
Supported RF version All
Deprecated names: 1009
Fix availability: There is no automatic fix.
Message:
Too many empty lines after '{section_name}' section header ({empty_lines}/{allowed_empty_lines})
Documentation:
Too many empty lines after the section header.
Empty lines after the section header are not allowed by default.
Incorrect code example:
*** Test Cases ***
Test case name
Correct code:
*** Test Cases ***
Test case name
Style guide:
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
empty_lineswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
empty_lines- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
empty_lines
Number of empty lines allowed after section header
Default value: 0
Type: int
SPC10: too-many-trailing-blank-lines¶
Added: v1.4.0
Supported RF version All
Deprecated names: 1010
Fix availability: There is no automatic fix.
Message:
Too many blank lines at the end of file
Documentation:
Too many blank lines at the end of the file.
There should be exactly one blank line at the end of the file.
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
SPC11: misaligned-continuation¶
Added: v1.6.0
Supported RF version All
Deprecated names: 1011
Fix availability: There is no automatic fix.
Message:
Continuation marker is not aligned with starting row
Documentation:
Misaligned continuation marker.
Incorrect code example:
*** Settings ***
Default Tags default tag 1 default tag 2 default tag 3
... default tag 4 default tag 5
*** Test Cases ***
Example
Do X first argument second argument third argument
... fourth argument fifth argument sixth argument
Correct code:
*** Settings ***
Default Tags default tag 1 default tag 2 default tag 3
... default tag 4 default tag 5
*** Test Cases ***
Example
Do X first argument second argument third argument
... fourth argument fifth argument sixth argument
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
SPC12: consecutive-empty-lines¶
Added: v1.8.0
Supported RF version All
Deprecated names: 1012
Fix availability: There is no automatic fix.
Message:
Too many consecutive empty lines ({empty_lines}/{allowed_empty_lines})
Documentation:
Too many consecutive empty lines.
Incorrect code example:
*** Variables ***
${VAR} value
${VAR2} value
*** Keywords ***
Keyword
Step 1
Step 2
Correct code:
*** Variables ***
${VAR} value
${VAR2} value
*** Keywords ***
Keyword
Step 1
Step 2 # 1 empty line is also fine, but no more
Style guide:
Note: Severity thresholds
This rule supports dynamic severity configurable using thresholds (severity-threshold). Parameter
empty_lineswill be used to determine issue severity depending on the thresholds.When configuring thresholds remember to also set
empty_lines- its value should be lower or equal to the lowest value in the threshold.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
empty_lines
Number of allowed consecutive empty lines
Default value: 1
Type: int
SPC13: empty-lines-in-statement¶
Added: v1.8.0
Supported RF version All
Deprecated names: 1013
Fix availability: There is no automatic fix.
Message:
Multi-line statement with empty lines
Documentation:
Multi-line statement with empty lines.
Avoid using empty lines between continuation markers in multi line statement.
Incorrect code example:
*** Test Cases ***
Test case
Keyword
... 1
# empty line in-between multiline statement
... 2
... 3
Correct code:
*** Test Cases ***
Test case
Keyword
... 1
... 2
... 3
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
SPC14: variable-not-left-aligned¶
Added: v1.8.0
Supported RF version >=4.0
Deprecated names: 1014, variable-should-be-left-aligned
Fix availability: There is no automatic fix.
Message:
Variable in Variables section is not left aligned
Documentation:
Variable in *** Variables *** section should be left aligned.
Incorrect code example:
*** Variables ***
${VAR} 1
${VAR2} 2
Correct code:
*** Variables ***
${VAR} 1
${VAR2} 2
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
SPC15: misaligned-continuation-row¶
Added: v1.11.0
Supported RF version All
Deprecated names: 1015
Fix availability: There is no automatic fix.
Message:
Continuation line is not aligned with the previous one
Documentation:
The continuation marker should be aligned with the previous one.
Incorrect code example:
*** Variable ***
${VAR} This is a long string.
... It has multiple sentences.
... And this line is misaligned with previous one.
*** Test Cases ***
My Test
My Keyword
... arg1
... arg2 # misaligned
Correct code:
*** Variable ***
${VAR} This is a long string.
... It has multiple sentences.
... And this line is misaligned with previous one.
*** Test Cases ***
My Test
My Keyword
... arg1
... arg2 # misaligned
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
ignore_docs
Ignore documentation
Default value: True
Type: bool
ignore_run_keywords
Ignore run keywords
Default value: False
Type: bool
SPC16: suite-setting-not-left-aligned¶
Added: v2.4.0
Supported RF version >=4.0
Deprecated names: 1016, suite-setting-should-be-left-aligned
Fix availability: There is no automatic fix.
Message:
Setting in Settings section is not left aligned
Documentation:
Settings in the *** Settings *** section should be left aligned.
Incorrect code example:
*** Settings ***
Library Collections
Resource data.resource
Variables vars.robot
Correct code:
*** Settings ***
Library Collections
Resource data.resource
Variables vars.robot
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
SPC17: bad-block-indent¶
Added: v3.0.0
Supported RF version All
Deprecated names: 1017
Fix availability: There is no automatic fix.
Message:
Not enough indentation inside block
Documentation:
Not enough indentation.
Reports occurrences where indentation is less than two spaces than current block parent element (such as
FOR/IF/WHILE/TRY header).
Incorrect code example:
*** Keywords ***
Some Keyword
FOR ${elem} IN ${list}
Log ${elem} # this is fine
Log stuff # this is bad indent
# bad comment
END
Correct code:
*** Keywords ***
Some Keyword
FOR ${elem} IN ${list}
Log ${elem} # this is fine
Log stuff # this is bad indent
# bad comment
END
Style guide:
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
SPC18: first-argument-in-new-line¶
Added: v5.3.0
Supported RF version All
Deprecated names: 1018
Fix availability: There is no automatic fix.
Message:
First argument: '{argument_name}' is not placed on the same line as [Arguments] setting
Documentation:
The first argument is not in the same level as the [Arguments] setting.
Incorrect code example:
*** Keywords ***
Custom Keyword With Five Required Arguments
[Arguments]
... ${name}
... ${surname}
Correct code:
*** Keywords ***
Custom Keyword With Five Required Arguments
[Arguments] ${name}
... ${surname}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
SPC19: not-enough-whitespace-after-setting¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0402
Fix availability: There is no automatic fix.
Message:
Not enough whitespace after '{setting_name}' setting
Documentation:
Not enough whitespace after setting.
Provide at least two spaces after setting.
Incorrect code example:
*** Test Cases ***
Test
[Documentation] doc
Keyword
*** Keywords ***
Keyword
[Documentation] This is doc
[Arguments] ${var}
Should Be True ${var}
Correct code:
*** Test Cases ***
Test
[Documentation] doc
Keyword
*** Keywords ***
Keyword
[Documentation] This is doc
[Arguments] ${var}
Should Be True ${var}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
SPC20: not-enough-whitespace-after-newline-marker¶
Added: v1.11.0
Supported RF version All
Deprecated names: 0406
Fix availability: There is no automatic fix.
Message:
Not enough whitespace after '...' marker
Documentation:
Not enough whitespace after a newline marker.
Provide at least two spaces after a newline marker.
Incorrect code example:
*** Variables ***
@{LIST} 1
... 2
... 3
Correct code:
*** Variables ***
@{LIST} 1
... 2
... 3
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
SPC21: not-enough-whitespace-after-variable¶
Added: v1.11.0
Supported RF version >=4.0
Deprecated names: 0410
Fix availability: There is no automatic fix.
Message:
Not enough whitespace after '{variable_name}' variable name
Documentation:
Not enough whitespace after variable.
Provide at least two spaces after the variable name.
Incorrect code example:
*** Variables ***
${variable} 1
${other_var} 2
Correct code:
*** Variables ***
${variable} 1
${other_var} 2
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
SPC22: not-enough-whitespace-after-suite-setting¶
Added: v1.11.0
Supported RF version All
Deprecated names: 0411
Fix availability: There is no automatic fix.
Message:
Not enough whitespace after '{setting_name}' setting
Documentation:
Not enough whitespace after suite setting.
Provide at least two spaces after the suite setting.
Incorrect code example:
*** Settings ***
Library Collections
Test Tags tag
... tag2
Suite Setup Keyword
Correct code:
*** Settings ***
Library Collections
Test Tags tag
... tag2
Suite Setup Keyword
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: E
Type: severity
Tags¶
Rules for tags.
TAG01: tag-with-space¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0601
Fix availability: There is no automatic fix.
Message:
Tag '{tag}' contains spaces
Documentation:
Tag with space.
When including or excluding tags, it may lead to unexpected behavior. It's recommended to use short tag names without spaces.
Example of rule violation:
*** Test Cases ***
Test
[Tags] tag with space ${tag with space}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
TAG02: tag-with-or-and¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0602
Fix availability: There is no automatic fix.
Message:
Tag '{tag}' with reserved word OR/AND
Documentation:
OR or AND keyword found in the tag.
OR and AND words are used to combine tags when selecting tests to be run in Robot Framework. Using
the following configuration:
robocop check --include tagANDtag2
Robot Framework will only execute tests that contain tag and tag2. That's why it's best to avoid AND
and OR in tag names. See docs
for more information.
Tag matching is case-insensitive. If your tag contains OR or AND you can use lowercase to match it.
For example, if your tag is PORT, you can match it with port.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
TAG03: tag-with-reserved-word¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0603
Fix availability: There is no automatic fix.
Message:
Tag '{tag}' prefixed with reserved wordrobot:``
Documentation:
Tag is prefixed with reserved work robot:.
robot: prefix is used by Robot Framework special tags. More details in
RF User Guide.
Special tags that are currently in use:
- robot:exit
- robot:flatten
- robot:no-dry-run
- robot:continue-on-failure
- robot:recursive-continue-on-failure
- robot:skip
- robot:skip-on-failure
- robot:stop-on-failure
- robot:recursive-stop-on-failure
- robot:exclude
- robot:private
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
TAG05: could-be-test-tags¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0605
Fix availability: There is no automatic fix.
Message:
All tests in suite share these tags: '{tags}'
Documentation:
All tests share the same tags which can be moved to the Test Tags setting.
Example:
*** Test Cases ***
Test
[Tags] featureX smoke
Step
Test 2
[Tags] featureX
Step
In this example all tests share one common tag featureX. It can be declared just once using Test Tags
or Task Tags.
This rule was renamed from could-be-force-tags to could-be-test-tags in Robocop 2.6.0.
Will ignore robot:* tags.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
TAG06: tag-already-set-in-test-tags¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0606
Fix availability: There is no automatic fix.
Message:
Tag '{tag}' is already set by {test_force_tags} in suite settings
Documentation:
Tag is already set in the Test Tags setting.
Avoid repeating the same tags in tests when the tag is already declared in Test Tags or Force Tags.
Example of rule violation:
*** Settings ***
Test Tags common_tag
*** Test Cases ***
Test
[Tags] sanity common_tag
Some Keyword
This rule was renamed from tag-already-set-in-force-tags to tag-already-set-in-test-tags in
Robocop 2.6.0.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
TAG07: unnecessary-default-tags¶
Added: v1.0.0
Supported RF version All
Deprecated names: 0607
Fix availability: There is no automatic fix.
Message:
Tags defined in Default Tags are always overwritten
Documentation:
Default Tags setting is always overwritten and is unnecessary.
Example of rule violation:
*** Settings ***
Default Tags tag1 tag2
*** Test Cases ***
Test
[Tags] tag3
Step
Test 2
[Tags] tag4
Step
Since Test and Test 2 have the [Tags] section, the Default Tags setting is never used.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
TAG08: empty-tags¶
Added: v2.0.0
Supported RF version All
Deprecated names: 0608
Fix availability: There is no automatic fix.
Message:
[Tags] setting without values{optional_warning}
Documentation:
[Tags] setting without any value.
If you want to use empty [Tags] (for example, to overwrite Default Tags), then use the NONE value
to be explicit.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
TAG09: duplicated-tags¶
Added: v2.0.0
Supported RF version All
Deprecated names: 0609
Fix availability: There is no automatic fix.
Message:
Multiple tags with name '{name}' (first occurrence at line {line} column {column})
Documentation:
Duplicated tags found.
Tags are free text, but they are normalized so that they are converted to lowercase and all spaces are removed. Only the first tag is used, other occurrences are ignored.
Example of duplicated tags:
*** Test Cases ***
Test
[Tags] Tag TAG tag t a g
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
TAG10: could-be-keyword-tags¶
Added: v3.3.0
Supported RF version >=6
Deprecated names: 0610
Fix availability: There is no automatic fix.
Message:
All keywords in suite share these tags: '{tags}'
Documentation:
All keywords share the same tags which can be moved to the Keyword Tags setting.
Example:
*** Keywords ***
Keyword
[Tags] featureX smoke
Step
Keyword
[Tags] featureX
Step
In this example all keywords share one common tag featureX.It can be declared just once using
Keyword Tags.
Will ignore robot:* tags.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
TAG11: tag-already-set-in-keyword-tags¶
Added: v3.3.0
Supported RF version >=6
Deprecated names: 0611
Fix availability: There is no automatic fix.
Message:
Tag '{tag}' is already set by {keyword_tags} in suite settings
Documentation:
Tag is already set in the Test Keyword setting.
Avoid repeating the same tags in keywords when the tag is already declared in Keyword Tags.
Example of rule violation:
*** Settings ***
Keyword Tags common_tag
*** Keywords ***
Keyword
[Tags] sanity common_tag
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
Variables¶
Rules for variables.
VAR01: empty-variable¶
Added: v1.10.0
Supported RF version All
Deprecated names: 0912
Fix availability: There is no automatic fix.
Message:
Empty variable value
Documentation:
Variable without value.
Variables with placeholder ${EMPTY} values are more explicit.
Incorrect code example:
*** Variables ***
${VAR_NO_VALUE}
${VAR_WITH_EMPTY} ${EMPTY}
@{MULTILINE_FIRST_EMPTY}
...
... value
${EMPTY_WITH_BACKSLASH} \
Correct code:
*** Keywords ***
Create Variables
VAR @{var_no_value}
VAR ${var_with_empty} ${EMPTY}
Incorrect code example:
*** Variables ***
${VAR_NO_VALUE} ${EMPTY}
${VAR_WITH_EMPTY} ${EMPTY}
@{MULTILINE_FIRST_EMPTY}
... ${EMPTY}
... value
${EMPTY_WITH_BACKSLASH} \
*** Keywords ***
Create Variables
VAR @{var_no_value} @{EMPTY}
VAR ${var_with_empty} ${EMPTY}
You can configure empty-variable rule to run only in *** Variables *** section or on
VAR statements using variable_source parameter.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
variable_source
Variable sources that will be checked
Default value: section,var
Type: comma separated list
VAR02: unused-variable¶
Added: v3.2.0
Supported RF version All
Deprecated names: 0920
Fix availability: There is no automatic fix.
Message:
Variable '{name}' is assigned but not used
Documentation:
Unused variable.
Incorrect code example:
*** Keywords ***
Get Triangle Base Points
[Arguments] ${triangle}
${p1} ${p2} ${p3} Get Triangle Points ${triangle}
Log Triangle base points are: ${p1} and ${p2}.
RETURN ${p1} ${p2} # ${p3} is never used
You can use ${_} variable name or start variable name with _ underscore if you purposefully do not
use variable:
*** Keywords ***
Process Value 10 Times
[Arguments] ${value}
FOR ${_} IN RANGE 10
Process Value ${value}
END
${_first} ${second} Unpack List @{LIST}
Note that some keywords may use your local variables even if you don't pass them directly. For example,
BuiltIn Replace Variables or any custom keyword that retrieves variables from a local scope. In this case,
Robocop will still raise an unused-variable even if the variable is actually used.
You can configure the rule to ignore specific variable names in the *** Variables *** section using
the ignore parameter. This is useful for variables that are used by external listeners, libraries,
or variable files:
robocop check --configure unused-variable.ignore=suite_param,other_var
Variable names are matched case-insensitively following Robot Framework conventions.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
ignore
Comma-separated list of variable names to ignore in *** variables *** section (case-insensitive)
Default value:
Type: comma separated list
VAR03: variable-overwritten-before-usage¶
Added: v3.2.0
Supported RF version All
Deprecated names: 0922
Fix availability: There is no automatic fix.
Message:
Local variable '{name}' is overwritten before usage
Documentation:
Local variable is overwritten before usage.
Local variable in Keyword, Test Case or Task is overwritten before it is used:
*** Keywords ***
Overwritten Variable
${value} Keyword
${value} Keyword
In case the value of the variable is not important, it is possible to use ${_} name:
*** Test Cases ***
Call keyword and ignore some return values
${_} ${item} Unpack List @{LIST}
FOR ${_} IN RANGE 10
Log Run this code 10 times.
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
VAR04: no-global-variable¶
Added: v5.6.0
Supported RF version All
Deprecated names: 0929
Fix availability: There is no automatic fix.
Message:
Variable with global scope defined outside variables section
Documentation:
Global variable defined outside the *** Variables *** section.
Setting or updating global variables in a test/keyword often leads to hard-to-understand code. In most cases, you're better off using local variables.
Changes in global variables during a test are hard to track because you must remember what's happening in multiple pieces of code at once. A line in a seemingly unrelated file can mess up your understanding of what the code should be doing.
Local variables don't suffer from this issue because they are always created in the keyword/test you're looking at.
In this example, the keyword changes the global variable. This will cause the test to fail. Looking at just the test, it's unclear why the test fails. It only becomes clear if you also remember the seemingly unrelated keyword:
*** Variables ***
${hello} Hello, world!
*** Test Cases ***
My Amazing Test
Do A Thing
Should Be Equal ${hello} Hello, world!
*** Keywords ***
Do A Thing
Set Global Variable ${hello} Goodnight, moon!
Using the VAR-syntax:
*** Variables ***
${hello} Hello, world!
*** Test Cases ***
My Amazing Test
Do A Thing
Should Be Equal ${hello} Hello, world!
*** Keywords ***
Do A Thing
VAR ${hello} Goodnight, moon! scope=GLOBAL
In some specific situations, global variables are a great tool. But most of the time, it makes code needlessly hard to understand.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
VAR05: no-suite-variable¶
Added: v5.6.0
Supported RF version All
Deprecated names: 0930
Fix availability: There is no automatic fix.
Message:
Variable defined with suite scope
Documentation:
Using suite variables in a test/keyword often leads to hard-to-understand code. In most cases, you're better off using local variables.
Changes in suite variables during a test are hard to track because you must remember what's happening in multiple pieces of code at once. A line in a seemingly unrelated file can mess up your understanding of what the code should be doing.
Local variables don't suffer from this issue because they are always created in the keyword/test you're looking at.
In this example, the keyword changes the suite variable. This will cause the test to fail. Looking at just the test, it's unclear why the test fails. It only becomes clear if you also remember the seemingly unrelated keyword:
*** Test Cases ***
My Amazing Test
Set Suite Variable ${hello} Hello, world!
Do A Thing
Should Be Equal ${hello} Hello, world!
*** Keywords ***
Do A Thing
Set Suite Variable ${hello} Goodnight, moon!
Using the VAR-syntax:
*** Test Cases ***
My Amazing Test
VAR ${hello} Hello, world! scope=SUITE
Do A Thing
Should Be Equal ${hello} Hello, world!
*** Keywords ***
Do A Thing
VAR ${hello} Goodnight, moon! scope=SUITE
In some specific situations, suite variables are a great tool. But most of the time, it makes code needlessly hard to understand.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
VAR06: no-test-variable¶
Added: v5.6.0
Supported RF version All
Deprecated names: 0931
Fix availability: There is no automatic fix.
Message:
Variable defined with test/task scope
Documentation:
Using test/task variables in a test/keyword often leads to hard-to-understand code. In most cases, you're better off using local variables.
Changes in test/task variables during a test are hard to track because you must remember what's happening in multiple pieces of code at once. A line in a seemingly unrelated file can mess up your understanding of what the code should be doing.
Local variables don't suffer from this issue because they are always created in the keyword/test you're looking at.
In this example, the keyword changes the test/task variable. This will cause the test to fail. Looking at just the test, it's unclear why the test fails. It only becomes clear if you also remember the seemingly unrelated keyword:
*** Test Cases ***
My Amazing Test
Set Test Variable ${hello} Hello, world!
Do A Thing
Should Be Equal ${hello} Hello, world!
*** Keywords ***
Do A Thing
Set Test Variable ${hello} Goodnight, moon!
Using the VAR-syntax:
*** Test Cases ***
My Amazing Test
VAR ${hello} Hello, world! scope=TEST
Do A Thing
Should Be Equal ${hello} Hello, world!
*** Keywords ***
Do A Thing
VAR ${hello} Goodnight, moon! scope=TEST
In some specific situations, test/task variables are a great tool. But most of the time, it makes code needlessly hard to understand.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
VAR07: non-local-variables-should-be-uppercase¶
Added: v1.4.0
Supported RF version All
Deprecated names: 0310
Fix availability: There is no automatic fix.
Message:
Non local variable is not uppercase
Documentation:
Non-local variable is not uppercase.
Non-local variable is not uppercase to easily identify scope of the variable.
Incorrect code example:
*** Test Cases ***
Test case
Set Task Variable ${my_var} 1
Set Suite Variable ${My Var} 1
Set Test Variable ${myvar} 1
Set Global Variable ${my_var${NESTED}} 1
Correct code:
*** Test Cases ***
Test case
Set Task Variable ${MY_VAR} 1
Set Suite Variable ${MY VAR} 1
Set Test Variable ${MY_VAR} 1
Set Global Variable ${MY VAR${nested}} 1
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
VAR08: possible-variable-overwriting¶
Added: v1.10.0
Supported RF version All
Deprecated names: 0316
Fix availability: There is no automatic fix.
Message:
Variable '{variable_name}' may overwrite similar variable inside '{block_name}' {block_type}
Documentation:
Variable may overwrite similar variable inside code block.
Variable names are case-insensitive, and also spaces and underscores are ignored. Following assignments overwrite the same variable:
*** Keywords ***
Retrieve Usernames
${username} Get Username id=1
${User Name} Get Username id=2
${user_name} Get Username id=3
Use consistent variable naming guidelines to avoid unintended variable overwriting.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
VAR09: hyphen-in-variable-name¶
Added: v1.10.0
Supported RF version All
Deprecated names: 0317
Fix availability: There is no automatic fix.
Message:
Hyphen in variable name '{variable_name}'
Documentation:
Hyphen in the variable name.
Hyphens can be treated as minus sign by Robot Framework. If it is not intended, avoid using hyphen (-)
character in variable name.
Incorrect code example:
*** Test Cases ***
Test case
${var2} Set Variable ${${var}-${var2}}
That's why there is a possibility that hyphen in name is not recognized as part of the name but as a minus sign. Better to use underscore instead:
Correct code:
*** Test Cases ***
Test case
${var2} Set Variable ${${var}_${var2}}
Hyphens in *** Variables *** section or in [Arguments] are also reported for consistency reason.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
VAR10: inconsistent-variable-name¶
Added: v3.2.0
Supported RF version All
Deprecated names: 0323
Fix availability: There is no automatic fix.
Message:
Variable '{name}' has inconsistent naming. First used as '{first_use}'
Documentation:
Variable with inconsistent naming.
Variable names are case-insensitive and ignore underscores and spaces. It is possible to write the variable in multiple ways, and it will be a valid Robot Framework code. However, it makes it harder to maintain the code that does not follow the consistent naming.
Incorrect code example:
*** Keywords ***
Check If User Is Admin
[Arguments] ${username}
${role} Get User Role ${username}
IF '${ROLE}' == 'Admin' # inconsistent name with ${role}
Log ${Username} is an admin # inconsistent name with ${username}
ELSE
Log ${user name} is not an admin # inconsistent name
END
Correct code:
*** Keywords ***
Check If User Is Admin
[Arguments] ${username}
${role} Get User Role ${username}
IF '${role}' == 'Admin'
Log ${username} is an admin
ELSE
Log ${username} is not an admin
END
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
VAR11: overwriting-reserved-variable¶
Added: v3.2.0
Supported RF version All
Deprecated names: 0324
Fix availability: There is no automatic fix.
Message:
{var_or_arg} '{variable_name}' overwrites reserved variable '{reserved_variable}'
Documentation:
Variable overwrites reserved variable.
Overwriting reserved variables may bring unexpected results.
For example, overwriting a variable with the name ${LOG_LEVEL} can break Robot Framework logging.
See the full list of reserved variables at
Robot Framework User Guide.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: W
Type: severity
VAR12: duplicated-assigned-var-name¶
Added: v1.12.0
Supported RF version All
Deprecated names: 0812
Fix availability: There is no automatic fix.
Message:
Assigned variable name '{variable_name}' is already used
Documentation:
Variable names in Robot Framework are case-insensitive and ignores spaces and underscores. Following variables are duplicates:
*** Test Cases ***
Test
${var} ${VAR} ${v_ar} ${v ar} Keyword
It is possible to use ${_} to note that variable name is not important and will not be used:
*** Keywords ***
Get Middle Element
[Arguments] ${list}
${_} ${middle} ${_} Split List ${list}
RETURN ${middle}
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
Annotations¶
Rules for typing and annotations.
ANN01: missing-section-variable-type¶
Rule is disabled by default. Enable it by using
--select missing-section-variable-typeoption.
Added: v7.1.0
Supported RF version >=7.3
Fix availability: There is no automatic fix.
Message:
Variable '{variable_name}' is missing type annotation
Documentation:
Section variable without type annotation.
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).
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:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
ANN02: missing-argument-type¶
Rule is disabled by default. Enable it by using
--select missing-argument-typeoption.
Added: v7.1.0
Supported RF version >=7.3
Fix availability: There is no automatic fix.
Message:
Argument '{variable_name}' is missing type annotation
Documentation:
Keyword argument without type annotation.
Robot Framework 7.3 introduced type conversion for variables. This rule enforces that keyword arguments have explicit type annotations for better code clarity and automatic type conversion.
Incorrect code example (when rule is enabled):
*** Keywords ***
Example
[Arguments] ${arg} @{varargs} &{kwargs}
Log ${arg}
Correct code:
*** Keywords ***
Example
[Arguments] ${arg: str} @{varargs: list} &{kwargs: dict}
Log ${arg}
This rule is disabled by default.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
ANN03: missing-for-loop-variable-type¶
Rule is disabled by default. Enable it by using
--select missing-for-loop-variable-typeoption.
Added: v7.1.0
Supported RF version >=7.3
Fix availability: There is no automatic fix.
Message:
FOR loop variable '{variable_name}' is missing type annotation
Documentation:
FOR loop variable without type annotation.
Robot Framework 7.3 introduced type conversion for variables. This rule enforces that FOR loop variables have explicit type annotations for better code clarity and automatic type conversion.
Incorrect code example (when rule is enabled):
*** Test Cases ***
Example
FOR ${index} IN RANGE 10
Log ${index}
END
Correct code:
*** Test Cases ***
Example
FOR ${index: int} IN RANGE 10
Log ${index}
END
This rule is disabled by default.
Parameters:
severity
Rule severity (e = error, w = warning, i = info)
Default value: I
Type: severity
ANN04: set-keyword-with-type¶
Added: v8.0.0
Supported RF version >=7.3
Fix availability: There is no automatic fix.
Message:
Set variable keyword with variable type
Documentation:
Set Test/Suite/Global Variable keyword with variable type.
Variable type conversion does not work with Set Test/Suite/Global Variable keywords:
*** Keywords ***
Set Variables
Set Local Variable ${variable: int} 1
Set Suite Variable ${variable: str} value
Set Test Variable ${variable: list[str]} value value
Set Task Variable ${variable: int} 2
Set Global Variable ${variable: int} 3
The VAR syntax needs to be used instead:
*** Keywords ***
Set Variables
VAR ${variable: int} 1
VAR ${variable: str} value
VAR ${variable: list[str]} value value
VAR ${variable: int} 2
VAR ${variable: int} 3
Parameters: