结构: Simple
Abstraction: Base
状态: Draft
被利用可能性: unkown
The software contains dead code, which can never be executed.
Dead code is source code that can never be executed in a running program. The surrounding code makes it impossible for a section of code to ever be executed.
cwe_Nature: ChildOf cwe_CWE_ID: 1164 cwe_View_ID: 1000 cwe_Ordinal: Primary
cwe_Nature: ChildOf cwe_CWE_ID: 1164 cwe_View_ID: 699 cwe_Ordinal: Primary
范围 | 影响 | 注释 |
---|---|---|
Other | Quality Degradation | Dead code that results from code that can never be executed is an indication of problems with the source code that needs to be fixed and is an indication of poor quality. |
Other | Reduce Maintainability |
According to SOAR, the following detection techniques may be useful:
According to SOAR, the following detection techniques may be useful:
According to SOAR, the following detection techniques may be useful:
According to SOAR, the following detection techniques may be useful:
According to SOAR, the following detection techniques may be useful:
According to SOAR, the following detection techniques may be useful:
According to SOAR, the following detection techniques may be useful:
策略:
Remove dead code before deploying the application.
策略:
Use a static analysis tool to spot dead code.
The condition for the second if statement is impossible to satisfy. It requires that the variables be non-null, while on the only path where s can be assigned a non-null value there is a return statement.
bad C++
In the following class, two private methods call each other, but since neither one is ever invoked from anywhere else, they are both dead code.
bad Java
(In this case it is a good thing that the methods are dead: invoking either one would cause an infinite loop.)
The field named glue is not used in the following class. The author of the class has accidentally put quotes around the field name, transforming it into a string constant.
bad Java
标识 | 说明 | 链接 |
---|---|---|
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
CERT C Secure Coding | MSC07-C | Detect and remove dead code | |
SEI CERT Perl Coding Standard | MSC00-PL | Exact | Detect and remove dead code |
Software Fault Patterns | SFP2 | Unused Entities | |
OMG ASCMM | ASCMM-MNT-20 |