Skip to content

Crazy multiline literals (CrazyMultilineString)

Type Scope Severity Activated
by default
Minutes
to fix
Tags
Code smell BSL
OS
Major Yes 1 badpractice
suspicious
unpredictable

Description

In source text, multi-line constants can be initialized in two ways:

  • 'classic', which uses line feed and string concatenation
  • 'crazy' where lines are separated by whitespace

The second method complicates the perception; when using it, it is easy to make and miss a mistake.

Examples

Difficulty understanding:

String = "BBB" "CC"
"F";

Classic variant:

String = "BBB" + "CC"
         + "F";

Sources

Snippets

Diagnostic ignorance in code

// BSLLS:CrazyMultilineString-off
// BSLLS:CrazyMultilineString-on

Parameter for config

"CrazyMultilineString": false