SplitTooLongLine¶
Split too long lines.
Disabling the formatter
SplitTooLongLine is included in the default formatters, but it can be also run separately with:
You can also disable it:
If a line exceeds the given length limit (120 by default), it will be split:
Allowed line length¶
Allowed line length is configurable using global parameter --line-length:
Or using dedicated for this formatter parameter line_length:
Split argument on every line¶
Using split_on_every_arg flag (True by default), you can force the formatter to fill keyword arguments
in one line until character limit:
will result in:
Split values on every line¶
Using split_on_every_value flag (True by default), you can force the formatter to fill values in one line
until character limit:
will result in:
Split settings arguments on every line¶
Using split_on_every_setting_arg flag (True by default), you can force the formatter to fill settings arguments
in one line until character limit:
will result in:
*** Keywords ***
Arguments
[Arguments] ${short}
... ${veryLongAndJavaLikeArgumentThatWillGoOverAllowedLength}
... ${veryLongAndJavaLikeArgumentThatWillGoOverAllowedLength}
Step
The first argument is kept on the same line as the setting name and the remaining arguments are split one per
line. This follows the Robot Framework style guide and does
not conflict with the first-argument-in-new-line (SPC18) and arguments-per-line (ARG07) linter rules.
Assignments¶
Assignments will be split to multi lines if they don't fit together with the Keyword in one line:
*** Keywords ***
Keyword
${first_assignment} ${second_assignment} Some Lengthy Keyword So That This Line Is Too Long
... ${arg1}
... ${arg2}
${first_assignment}
... ${second_assignment}
... ${third_assignment}
... Some Lengthy Keyword So That This Line Is Too Long And Bit Over
... ${arg1}
... ${arg2}
Single values¶
By default, single values (${variable} value) are not split. You can configure SplitTooLine formatter
to split on single too long values using split_single_value option:
will result in:
Align a new line¶
The new line can be aligned to the previous line when splitting the line.
By default, only settings (such as [Tags] or [Arguments]) are aligned.
Use the following flags to enable/disable this behaviour for a given type:
align_new_line_arg(defaultFalse) for keyword arguments alignmentalign_new_line_setting_arg(defaultTrue) for settings arguments alignmentalign_new_line_value(defaultFalse) for values alignment
For example, to align keyword arguments and values while keeping the default settings alignment:
Or to disable the settings arguments alignment enabled by default:
Alignment can be also enabled for all types at once using align_new_line. This flag takes precedence over
the granular flags above - when it is set to True, every type is aligned regardless of the
align_new_line_arg, align_new_line_setting_arg and align_new_line_value values:
will result in:
Ignore comments¶
To not count the length of the comment to line length, use skip option:
This allows ignoring lines that are longer than allowed length because of the added comment.
Skip formatting¶
It is possible to use the following arguments to skip formatting of the code:
It is also possible to use disablers but skip option makes it easier to skip
all instances of a given type of the code.