Details
-
Type:
Bug Detection
-
Status: Closed
-
Resolution: Duplicate
-
Labels:
-
Message:Remove this unexpected trailing semi-colon.
-
Highlighting:
-
Default Severity:Major
-
Impact:Low
-
Likelihood:High
-
Default Quality Profiles:Sonar way
-
Targeted languages:C#, C, C++, Java, JavaScript, Objective-C, PHP, PL/SQL
-
Irrelevant for Languages:Python, Swift
-
Remediation Function:Constant/Issue
-
Constant Cost:2mn
-
Analysis Scope:Main Sources, Test Sources
-
CERT:MSC51-J., EXP15-C.
Description
There is no point in creating a branch in the code only to execute an empty statement. Such code can only be due to the presence of an unexpected trailing semi-colon.
Noncompliant Code Example
if(foo); //Noncompliant, the semi-colon must be removed trigger(action1); // executes unconditionally else if (bar); //Noncompliant, the semi-colon must be removed trigger(action2); // executes unconditionally while (condition); // Noncompliant doTheThing(); // executes once, unconditionally
See
- CERT, MSC51-J. - Do not place a semicolon immediately following an if, for, or while condition
- CERT, EXP15-C. - Do not place a semicolon on the same line as an if, for, or while statement
Attachments
Issue Links
- duplicates
-
RSPEC-2681 Multiline blocks should be enclosed in curly braces
- Active
- relates to
-
RSPEC-1116 Empty statements should be removed
- Active