Skip to content

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 BSL200 and alias IncorrectLineBreak are 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.

[tool.onec-hbk-bsl]
select = ["BSL200"]
ignore = ["IncorrectLineBreak"]

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:
Value = "example";  // noqa: BSL200
  • bsl-disable:
Value = "example";  // bsl-disable: BSL200
  • compatible BSLLS form:
Value = "example";  // BSLLS:IncorrectLineBreak-off

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 listOfIncorrectFirstSymbol parameter
  • 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:

AmountDocument = AmountWithoutDiscount +
                 AmountManualDiscounts +
                 AmountAutomaticDiscount;

Correct:

AmountDocument = AmountWithoutDiscount
    + AmountManualDiscounts
    + AmountAutomaticDiscount;

or

AmountDocument = AmountWithoutDiscount
                 + AmountManualDiscounts
                 + AmountAutomaticDiscount;

An example of a possible arrangement of parameters and a closing bracket with the operator separator ";"

Names = New ValueList;
Names.Add(Name,
                         Synonym);

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.

Names = New ValueList;
Names.Add(
    Name,
    Synonym
);

Sources