Details
-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:Refactor this suspicious code to not use the result of this non-boolean assignment as a condition
-
Highlighting:
-
Default Severity:Blocker
-
Impact:High
-
Likelihood:High
-
Default Quality Profiles:Sonar way
-
Targeted languages:C++, Cobol, JavaScript, PHP, PL/SQL, Swift
-
Irrelevant for Languages:C#, C, Java
-
Remediation Function:Constant/Issue
-
Constant Cost:5min
-
Analysis Scope:Main Sources, Test Sources
-
CERT:EXP19-CPP, EXP19-CPP.
-
MISRA C 2004:13.1
Description
Using the output of a non-boolean assignment as a condition is highly suspicious. Either it was done accidentally, and the assignment operator = was used in place of the equality operator ==, or it was done with the intent to rely on the automatic conversion of the non-boolean value to a boolean, which could be confusing for maintainers.
See
- MISRA C:2004, 13.1 - Assignment operators shall not be used in expressions that yield a Boolean value
Attachments
Issue Links
- relates to
-
RSPEC-1121 Assignments should not be made from within sub-expressions
- Active
1.
|
JavaScript | RSPEC-3932 |
|
Active | Unassigned | |
2.
|
C-Family | RSPEC-3933 |
|
Active | Unassigned |