RemoveEmptySettings#

Remove empty settings.

Transformer configuration

RemoveEmptySettings is included in the default transformers, but it can be also run separately with:

robotidy --transform RemoveEmptySettings src

You can also disable RemoveEmptySettings:

robotidy --configure RemoveEmptySettings:enabled=False src
*** Settings ***
Documentation
Suite Setup
Metadata
Metadata    doc=1
Test Setup
Test Teardown    Teardown Keyword
Test Template
Test Timeout
Force Tags
Default Tags
Library
Resource
Variables

*** Test Cases ***
Test
    [Setup]
    [Template]    #  comment    and    comment
    [Tags]    tag
    Keyword
*** Settings ***
Metadata    doc=1
Test Teardown    Teardown Keyword

*** Test Cases ***
Test
    [Tags]    tag
    Keyword

You can configure which settings are affected by parameter work_mode. Possible values:

  • overwrite_ok (default) - does not remove settings that are overwriting suite settings (Test Setup, Test Teardown, Test Template, Test Timeout or Default Tags)

  • always - works on every settings

Empty settings that are overwriting suite settings will be converted to be more explicit (given that there is related suite settings present). You can disable that behavior by changing more_explicit parameter value to False:

robotidy --configure RemoveEmptySettings:more_explicit=False src
*** Settings ***
Test Timeout  1min
Force Tags

*** Test Case ***
Test
    [Documentation]    Empty timeout means no timeout even when Test Timeout has been used.
    [Timeout]
    No timeout
*** Settings ***
Test Timeout  1min

*** Test Case ***
Test
    [Documentation]    Empty timeout means no timeout even when Test Timeout has been used.
    [Timeout]    NONE
    No timeout
*** Settings ***
Test Timeout  1min

*** Test Case ***
Test
    [Documentation]    Empty timeout means no timeout even when Test Timeout has been used.
    [Timeout]
    No timeout

If you want to remove all empty settings even if they are overwriting suite settings (like in above example) then set work_mode to always:

robotidy --configure RemoveEmptySettings:work_mode=always src
*** Settings ***
Test Timeout  1min
Force Tags

*** Test Case ***
Test
    [Documentation]    Empty timeout means no timeout even when Test Timeout has been used.
    [Timeout]
    No timeout
*** Settings ***
Test Timeout  1min

*** Test Case ***
Test
    [Documentation]    Empty timeout means no timeout even when Test Timeout has been used.
    No timeout