CQM-DeadImplementation¶
Unreachable statements
Required inputs: IR
Motivation
All code should be minimal, i.e. every single instruction serves directly or indirectly to ensure the quality of the application (functional as well as non-functional). If there are instructions that are not executed under any circumstances, they are superfluous and thus complicate all maintenance work on the code.
Dead code that can be reliably identified with tools is present on a control flow path
- after a
returnstatement or - after an exception has been thrown.
This rule is based on the CQM Quality Indicator: tote Implementierung (p. 294-296).
Reference
Simon, Frank/ Seng, Olaf/ Mohaupt, Thomas (2006): Code-Quality-Management: Technische Qualität industrieller Softwaresysteme transparent und vergleichbar gemacht, 1st ed., Heidelberg, Germany: dpunkt.verlag GmbH.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
function_never_called |
{what} never called |
None |
False |
function_only_called_from_uncalled_function |
{what} only called from uncalled function |
None |
False |
function_only_called_from_uncalled_function_or_dead_branches |
{what} only called from uncalled function or from dead branches |
None |
False |
unreachable_code |
Unreachable code |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
disregard_logical_shortcut¶
disregard_logical_shortcut : bool = False
false && ... or true || ....
report_dead_if_branch_with_const_literal_condition¶
report_dead_if_branch_with_const_literal_condition : bool = True
use_semantic_analysis¶
use_semantic_analysis : bool = True