Unconditional Control Flow Transfer outside of Switch Block

Incomplete Base
Structure: Simple
Description

This weakness occurs when code uses an unconditional jump, like a 'goto' statement, outside of a structured control flow block like a switch statement. This bypasses the intended logic and makes the program's execution path unpredictable and difficult to follow.

Extended Description

Using unconditional jumps outside their intended structured context creates confusing 'spaghetti code.' This significantly increases maintenance costs because tracing the program's logic becomes a manual, error-prone task. Developers spend more time deciphering code than fixing or improving it, which slows down the entire development lifecycle. The indirect security impact is substantial. This code smell makes it harder to spot genuine vulnerabilities during reviews and audits, as critical logic is hidden in jumps. Furthermore, when modifying such code, developers are more likely to introduce defects or security flaws because they cannot easily reason about all possible execution paths affected by a change.

Common Consequences 1
Scope: Other

Impact: Reduce Maintainability

References 1
Automated Source Code Maintainability Measure (ASCMM)
Object Management Group (OMG)
01-2016
ID: REF-960
Related Weaknesses
Taxonomy Mapping
  • OMG ASCMM