Community rules list

Community rules are optional rules that may handle specific issues or offer particular utility with certain limitations. All community rules are disabled by default and can be enabled by configuring enabled parameter:

robocop --configure sleep-keyword-used:enabled:True

or by including rule in --include:

robocop --include sleep-keyword-used

Usage

unused-keyword / I10101

Added in v5.3.0Supported RF versions: All

Message:

Keyword '{{ keyword_name }}' is not used

Documentation:

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.

Configurable parameters:

Name

Default value

Type

Description

severity

I

severity

Rule severity (E = Error, W = Warning, I = Info)

enabled

False

bool

Rule default enable status

Keywords

sleep-keyword-used / W10001

Added in v5.0.0Supported RF versions: All

Message:

Sleep keyword with '{{ duration_time }}' sleep time found

Documentation:

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 -c sleep-keyword-used:max_time:1min .

Configurable parameters:

Name

Default value

Type

Description

severity

W

severity

Rule severity (E = Error, W = Warning, I = Info)

enabled

False

bool

Rule default enable status

max_time

0

timestr_to_secs

Maximum amount of time allowed in Sleep


not-allowed-keyword / W10002

Added in v5.1.0Supported RF versions: All

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 -i not-allowed-keyword -c not-allowed-keyword:keywords:click_using_javascript

*** Keywords ***
Keyword With Obsolete Implementation
    [Arguments]    ${locator}
    Click Using Javascript    ${locator}  # Robocop will report not allowed keyword

If keyword call contains possible library name (ie. Library.Keyword Name), Robocop checks if it matches the not allowed keywords and if not, it will remove library part and check again.

Configurable parameters:

Name

Default value

Type

Description

severity

W

severity

Rule severity (E = Error, W = Warning, I = Info)

enabled

False

bool

Rule default enable status

keywords

None

comma_separated_list

Comma separated list of not allowed keywords


no-embedded-keyword-arguments / W10003

Added in v5.5.0Supported RF versions: All

Message:

Not allowed embedded arguments {{ arguments }} found in keyword '{{ keyword }}'

Documentation:

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.

Example:

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

Configurable parameters:

Name

Default value

Type

Description

severity

W

severity

Rule severity (E = Error, W = Warning, I = Info)

enabled

False

bool

Rule default enable status

Misc

non-builtin-imports-not-sorted / W10101

Added in v5.2.0Supported RF versions: All

Message:

Non builtin library import '{{ custom_import }}' should be placed before '{{ previous_custom_import }}'

Documentation:

Example of rule violation:

*** Settings ***
Library    Collections
Library    CustomLibrary
Library    AnotherCustomLibrary  # AnotherCustomLibrary library defined after custom CustomLibrary

Configurable parameters:

Name

Default value

Type

Description

severity

W

severity

Rule severity (E = Error, W = Warning, I = Info)

enabled

False

bool

Rule default enable status


resources-imports-not-sorted / W10102

Added in v5.2.0Supported RF versions: All

Message:

Resource import '{{ resource_import }}' should be placed before '{{ previous_resource_import }}'

Documentation:

Example of rule violation:

*** Settings ***
Resource   CustomResource.resource
Resource   AnotherFile.resource

Configurable parameters:

Name

Default value

Type

Description

severity

W

severity

Rule severity (E = Error, W = Warning, I = Info)

enabled

False

bool

Rule default enable status