Rule Definition
This issue makes it more difficult to maintain the software, which indirectly affects security by making it more difficult or time-consuming to find and/or fix vulnerabilities.
Remediation
Ensure you copy/paste does not exist in your conditional structure.
Violation Code Sample
if (b == 0) // VIOLATION
{
foo();
}
else
{
foo();
}
int b = a > 12 ? 3 : 3; // VIOLATION
switch (i) // VIOLATION BECAUSE THERE IS A DEFAULT BLOCK
{
case 1:
bar();
break;
case 2:
bar();
break;
case 3:
bar();
break;
default:
bar();
break;
}
Reference
Object Management Group (OMG). "Automated Source Code Maintainability Measure (ASCMM)". ASCMM-MNT-19. 2016-01. .
Related Technologies
Technical Criterion
CWE-1041 - Use of Redundant Code
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.