-
Type:
Language-Specification
-
Status: Active
-
Resolution: Unresolved
-
Labels:None
-
Impact:Unknown 'null' severity
-
Likelihood:Unknown 'null' severity
-
Legacy Key:OneStatementPerLine
Noncompliant Code Example
foo(); bar(); // Noncompliant
Compliant Solution
foo(); bar();
Exceptions
Control flow statements with a single nested statement are ignored.
if (condition) doSomething(); // Compliant while (condition) doSomething(); // Compliant
case or default statements containing a single statement and followed by break are ignored.
switch (foo) { case 0: doSomething(); break; // Compliant default: doSomething(); break; // Compliant }
Statements enclosed in curly braces on the same line are ignored.
auto lambda = [](int x) { doSomething(x); return x; }; // Compliant
- is related to
-
CPP-1811 S122: Add exception for flow statements with single nesting
-
- Closed
-