JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Binaries


LANG.METRIC.VG_P : High Cyclomatic Complexity (Procedure)

要旨

A procedure's cyclomatic complexity is greater than 20.

プロパティ

クラス名 High Cyclomatic Complexity (Procedure)
日本語クラス名 High Cyclomatic Complexity (Procedure)
クラス分類 スタイル (style)
ニーモニック LANG.METRIC.VG_P
カテゴリー
CWE CWE:1121 Excessive McCabe Cyclomatic Complexity
JSF++ JSF++:3 All functions shall have a cyclomatic complexity number of 20 or less.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="High Cyclomatic Complexity (Procedure)"

static int low_cyclomatic_complexity(int i) {      // ok: cyclomatic complexity <20
  int rv = 0;
  if (i) {
    rv = 1;
  }
  return rv;
}

// 'High Cyclomatic Complexity (Procedure)' warning issued on following line
// - cyclomatic complexity of this procedure is >20
static int high_cyclomatic_complexity(int a, int b, int c, int d, int e) {
  int rv = 0;
  if (a) {
    rv += 1;
    if (b) {
      rv += 1;
      if (c) {
        rv +=1;
        if (d) {
          rv +=1;
          if (e) { rv += 1; }
          else { rv -= 1; }
        }
        else {
          rv -= 1;
          if (e) { rv += 1; }
          else { rv -= 1; }  
        }  
      }
      else {
        rv -=1;
        if (d) {
          rv +=1;
          if (e) { rv += 1; }
          else { rv -= 1; }
        }
        else {
          rv -= 1;
          if (e) { rv += 1; }
          else { rv -= 1; }
        }
      }
    }
    else {
      rv -= 1;
           if (c) {
        rv +=1;
        if (d) {
          rv +=1;
          if (e) { rv += 1; }
          else { rv -= 1; }
        }
        else {
          rv -= 1;
          if (e) { rv += 1; }
          else { rv -= 1; }
        }
      }
      else {
        rv -=1;
        if (d) {
          rv +=1;
          if (e) { rv += 1; }
          else { rv -= 1; }
        }
        else {
          rv -= 1;
          if (e) { rv += 1; }
          else { rv -= 1; }
        }
      }
    }
  }
  else {
    rv -= 1;
    if (b) {
      rv += 1;
      if (c) {
        rv +=1;
        if (d) { rv +=1; }
        else { rv -=1; }
      }
      else { rv -=1; }
    }
    else {
      rv -= 1;
      if (c) { rv +=1; }
      else { rv -=1; }
    }
  }
  return rv;
}

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

This class is implemented using a METRIC_WARNING_* rule set in the general template configuration file.

To adjust the triggering condition for this class, edit the corresponding METRIC_WARNING_CONDITION.

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

 

To report problems with this documentation, please visit https://support.codesecure.com/.