C and C++


LANG.COMM.CODE : コメントアウトされたコード

要旨

コメント内に多数のソースコードが含まれています。

コメント内容に含まれる演算子 (!#%^&*()+={}\[]:;<>/) の割合が一般的なC/C++のソースコードと一致する場合、 そのコメントは、ソースコードを含んでいると考えられます。 このヒューリスティックは、 コメントが短い場合には破棄される可能性がある為、コメントの文字数が少ない場合には、このワーニングは発行されません。

The various thresholds involved in this determination are controlled by configuration file parameters:

See the linked individual parameter documentation for full details.

プロパティ

クラス名 Commented-out Code
日本語クラス名 コメントアウトされたコード
クラス分類 スタイル (style)
ニーモニック LANG.COMM.CODE
カテゴリー
MisraC2023 MisraC2023:D.4.4 Sections of code should not be "commented out"
Misra2012 Misra2012:D.4.4 Sections of code should not be "commented out"
Misra2004 Misra2004:2.4 Sections of code should not be "commented out"
AUTOSARC++14 AUTOSARC++14:A2-7-2 Sections of code shall not be "commented out".
MisraC++2008 MisraC++2008:2-7-2 Sections of code shall not be "commented out" using C-style comments.
  MisraC++2008:2-7-3 Sections of code should not be "commented out" using C++ comments.
MisraC++2023 MisraC++2023:5.7.2 Sections of code should not be "commented out"
CWE CWE:615 Inclusion of Sensitive Information in Source Code Comments
  CWE:1085 Invokable Control Element with Excessive Volume of Commented-out Code
JSF++ JSF++:127 Code that is not used (commented out) shall be deleted.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Commented-out Code"

int f (int i){
                 /* 'Commented-out Code' warning issued for following comment block */
  
    /* int b;
     * int a = i;
     * a = i++;
     * b = g(a);
     */

    i++;
 
    /* this comment is ordinary text */                  /* does not contain source code */
    return i;
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。