<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    Dead Code: Unused Field

    ABSTRACT

    從未以公共方法直接或間接使用這個字段。

    EXPLANATION

    這個字段從未被訪問過,或者僅通過 dead code 進行調用。Dead code 是指從未以公共方法直接或間接執行的代碼。雖然某一字段可能已經過時,不太被人們使用了,但 unused field 仍有可能指出 bug 的所在。

    例 1: 在以下的類中,并沒有使用到 glue 字段。但是該類的作者無意間對該字段名進行了引用,將其轉變成了字符串常量。


    public class Dead {

    string glue;

    public string GetGlue() {
    return "glue";
    }

    }


    例 2: 在下面這個類中使用了 glue 字段,但僅限于從未以公共方法調用的方法。


    public class Dead {

    string glue;

    private string GetGlue() {
    return glue;
    }

    }

    REFERENCES

    [1] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3050 CAT II

    [2] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3050 CAT II

    [3] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 561


    Copyright 2013 Fortify Software - All rights reserved.
    (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
    desc.structural.dotnet.dead_code_unused_field

    97av