Skip to content

Unary Plus sign in string concatenation (UnaryPlusInConcatenation)

Type Scope Severity Activated
by default
Minutes
to fix
Tags
Error BSL
OS
Blocker Yes 1 suspicious
brainoverload

Description

When concatenating strings, a developer may mistakenly write code String + + String2, i.e. the second plus, the platform recognizes as unary and tries to cast to a number, which in most cases will lead to a runtime exception

Snippets

Diagnostic ignorance in code

// BSLLS:UnaryPlusInConcatenation-off
// BSLLS:UnaryPlusInConcatenation-on

Parameter for config

"UnaryPlusInConcatenation": false