OrderSettingsSection¶
Order settings inside *** Settings *** section.
Disabling the formatter
OrderSettingsSection is included in the default formatters, but it can be also run separately with:
You can also disable it:
Settings are grouped in the following groups:
- documentation (Documentation, Metadata),
- imports (Library, Resource, Variables),
- settings (Suite Setup and Teardown, Test Setup and Teardown, Test Timeout, Test Template),
- tags (Force Tags, Default Tags)
Then ordered by groups (according to group_order = documentation,imports,settings,tags order). Every
group is separated by new_lines_between_groups = 1 new lines.
Settings are ordered inside a group. The default order can be modified through the following parameters:
documentation_order = documentation,metadataimports_order = preserved(default, see imports order section to how configure it)settings_order = suite_setup,suite_teardown,test_setup,test_teardown,test_timeout,test_template
*** Settings ***
Metadata value param
Force Tags tag
... tag
Documentation doc # this is comment
... another line
Test Timeout 1min
# I want to be keep together with Test Setup
Test Setup Keyword
Suite Setup Keyword
Default Tags 1
Suite Teardown Keyword2
Variables variables.py
Library Stuff
Library Collections
Resource robot.resource
Library stuff.py WITH NAME alias
*** Settings ***
Documentation doc # this is comment
... another line
Metadata value param
Variables variables.py
Library Stuff
Library Collections
Resource robot.resource
Library stuff.py WITH NAME alias
Suite Setup Keyword
Suite Teardown Keyword2
# I want to be keep together with Test Setup
Test Setup Keyword
Test Timeout 1min
Force Tags tag
... tag
Default Tags 1
Using the same example with non-default group order, we will move tags from end to beginning of the section:
will result in:
Settings order¶
The order of settings inside a common group can also be changed:
will result in:
Preserve order¶
If you want to preserve order of the settings inside the group you can use preserved value:
Imports are preserved by default.
Imports order¶
By default, the order of the imports is preserved. You can overwrite this behaviour:
With preceding configuration robocop format will put library imports first, then resources and variables last.
Builtin library imports are moved to the top and sorted alphabetically.
Example:
Removing settings¶
Setting names omitted from custom order will be removed from the file. In the following example we are missing metadata, therefore all metadata will be removed:
Empty lines between group of settings¶
Group of settings are separated by new_lines_between_groups = 1 new lines. It can be configured:
will result in:
If you're not preserving the default order of libraries, they will be grouped into built-in libraries and custom libraries. Parsing errors (such as Resources instead of Resource, duplicated settings) are moved to the end of a section.