Skip to content

BSL208 — Mixing Latin and Cyrillic characters in one identifier

Summary

Mixing Latin and Cyrillic characters in one identifier

Identifiers

Field Value
Rule code BSL208
Compatible alias LatinAndCyrillicSymbolInWord
Severity WARNING
Enabled by default Yes
Implemented Yes
Tags suspicious, naming

Behavior

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

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

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

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

Do not use identifiers consisting of characters from different languages, вecause it makes it difficult to use them further, forcing to switch the layout. Also, the diagnostics detects the erroneous use of characters from another language, when it was used unintentionally. For exaple: o, c, B, p and etc.

To reduce "noise" in the names consisting of several words beginning or ending in the word in another language, in the diagnostics option has been added that is included by default. If the parameter is enabled, then NOT are considered erroneous names like ZebraДрайвер, КодHTTP, SMSШлюз and the like.

Examples

Sources