BSL200 — Incorrect expression line break¶
Summary¶
Incorrect expression line break
Identifiers¶
| Field | Value |
|---|---|
| Rule code | BSL200 |
| Compatible alias | IncorrectLineBreak |
| Severity | INFORMATION |
| Enabled by default | Yes |
| Implemented | Yes |
| Tags | style, convention |
Behavior¶
- The public identifier
BSL200and aliasIncorrectLineBreakare stable. - The rule reports the cases documented on this page.
- Suppressions and project configuration are applied before publication.
- The rule requires neither an external analyzer nor network access.
Configuration and suppression¶
BSL### is the primary stable identifier. The compatible alias is accepted
in select, ignore, and compatible block suppression comments.
All three suppression families support both a current line and a range. When an opening comment follows code, it affects only that line. Use any one form:
noqa:
bsl-disable:
- compatible
BSLLSform:
When the same opening comment is on a line by itself, it starts a range. Close it with the matching marker from the same family:
// noqa: BSL200
// code without this diagnostic
// noqa-enable: BSL200
// bsl-disable: BSL200
// code without this diagnostic
// bsl-enable: BSL200
// BSLLS:IncorrectLineBreak-off
// code without this diagnostic
// BSLLS:IncorrectLineBreak-on
To disable the rule until the end of the file, omit the closing
noqa-enable, bsl-enable, or BSLLS:…-on marker.
Opening and closing markers must belong to the same family.
Description¶
Long arithmetic expressions are carried as follows: one entry can contain more than one operand; when wrapping, operation characters are written at the beginning of the line (and not at the end of the previous line); operands on a new line are preceded by standard indentation, or they are aligned to the beginning of the first operand, regardless of the operation signs.
If necessary, parameters of procedures, functions and methods should be transferred as follows:
- parameters are either aligned to the beginning of the first parameter, or preceded by standard indentation;
- closing parenthesis and operator separator ";" are written on the same line as the last parameter;
- the formatting method that offers the auto-formatting function in the configurator is also acceptable
Complex logical conditions in If ... ElseIf ... EndIf should be carried as follows:
- The basis for the newline if the line length is limited to 120 characters;
- logical operators AND, OR are placed at the beginning of a line, and not at the end of the previous line;
- all conditions are preceded by the standard first indent, or they are aligned at the start of work without taking into account the logical operator (it is recommended to use spaces to align expressions relative to the first line).
Examples of configuring exclusions:
- If your design standard requires a closing brace and statement separator ";" were written after the line containing the last parameter, then you need to change the
listOfIncorrectFirstSymbolparameter - instead of the substring
|\);(at the end of the setting) you need to write the substring|\)\s*;\s*\S+ - final version
\)|;|,\s*\S+|\)s*;\s*\S+ - code example is listed in the examples section
Without the specified setting, the rule will issue notes on the closing bracket and the operator separator ";", located on a separate line
Examples¶
Incorrect:
Correct:
or
An example of a possible arrangement of parameters and a closing bracket with the operator separator ";"
An example of a possible location of the closing bracket with the operator separator ";" on a separate line:
- without changing the listOfIncorrectFirstSymbol parameter (see above), the diagnostics will generate a issue for such expression wrapping.
Sources¶
- Standard: Wrap expressions (RU)