Skip to content

BSL216 — Missing spaces to the left or right of operators + - * / = % < > <> <= >=, keywords, and also to the right of , and ;

Summary

Missing spaces to the left or right of operators + - * / = % < > <> <= >=, keywords, and also to the right of , and ;

Identifiers

Field Value
Rule code BSL216
Compatible alias MissingSpace
Severity INFORMATION
Enabled by default Yes
Implemented Yes
Tags style, convention

Behavior

  • The public identifier BSL216 and alias MissingSpace 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 = ["BSL216"]
ignore = ["MissingSpace"]

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: BSL216
  • bsl-disable:
Value = "example";  // bsl-disable: BSL216
  • compatible BSLLS form:
Value = "example";  // BSLLS:MissingSpace-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: BSL216
// code without this diagnostic
// noqa-enable: BSL216

// bsl-disable: BSL216
// code without this diagnostic
// bsl-enable: BSL216

// BSLLS:MissingSpace-off
// code without this diagnostic
// BSLLS:MissingSpace-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

To improve code readability to the left and right of operators + - * / = % < > <> <= >= there must be spaces. Also, the space should be to the right of , и ;

Examples

Incorrect

Procedure Sum(Param1,Param2)
    If Param1=Param2 Then
        Sum=Price*Quantity;
    EndIf;
EndProcedure

Correct

Procedure Sum(Param1, Param2)
     If Param1 = Param2 Then
         Sum = Price * Quantity;
     EndIf;
EndProcedure

Using checkSpaceToRightOfUnary parameter

The parameter makes sense only in case the unary operator is listed in one of three base parameters.

If set to false

А = -B;     // Correct
А = - B;    // Correct

If set to true

А = -B;     // Incorrect
А = - B;    // Correct

Using allowMultipleCommas parameter

The parameter has sense only if , is listed in one of three base parameters Defaults to false

If set to false

    CommonModuleClientServer.MessageToUser(MessageText,,,, Cancel);        // Bad
    CommonModuleClientServer.MessageToUser(MessageText, , , , Cancel);     // Correct

If set to true

    CommonModuleClientServer.MessageToUser(MessageText,,,, Cancel);        // Correct
CommonModuleClientServer.MessageToUser(MessageText, , , , Cancel);     // Correct