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


Custom Metric-Based Warning Classes

CodeSonar provides configuration parameters that allow users to specify custom warning classes based on metric values. A custom metric warning class is defined using five settings:

METRIC_WARNING_CLASS_NAME The warning class name.
METRIC_WARNING_CONDITION A condition of the form metric_tag[metric_granularity] op num, where op is one of <, <=, >, >=.

A warning will be triggered whenever the value of the specified metric falls in the specified range.

METRIC_WARNING_SIGNIFICANCE
A Significance value for the class.
METRIC_WARNING_CATEGORIES
[optional]
Categories associated with the warning class.
METRIC_WARNING_BASE_RANK
[optional]
The base rank for any triggered warning.

Example Custom Metric-Based Classes

The comments in the general template configuration file include three example classes implemented with METRIC_WARNING_* rules. To include checks for any of these classes:

High Cyclomatic Complexity

With this class enabled, CodeSonar will issue a High Cyclomatic Complexity warning for any function with a cyclomatic complexity of 20 or more.

#     METRIC_WARNING_CONDITION = vG[PROCEDURE] >= 20
#     METRIC_WARNING_CLASS_NAME = High Cyclomatic Complexity
#     METRIC_WARNING_CATEGORIES = METRIC.VG
#     METRIC_WARNING_BASE_RANK = 5.0
#     METRIC_WARNING_SIGNIFICANCE = STYLE

Large procedure

With this class enabled, CodeSonar will issue a Large procedure warning for any function containing more than 100 lines with code.

#     METRIC_WARNING_CONDITION = LCode[PROCEDURE] > 100
#     METRIC_WARNING_CLASS_NAME = Large procedure
#     METRIC_WARNING_CATEGORIES = METRIC.LCODE
#     METRIC_WARNING_BASE_RANK = 1.0
#     METRIC_WARNING_SIGNIFICANCE = STYLE

Too few comments

With this class enabled, CodeSonar will issue a Too few comments warning for any function containing fewer than 5 lines with comments.

#     METRIC_WARNING_CONDITION = LCom[PROCEDURE] < 5
#     METRIC_WARNING_CLASS_NAME = Too few comments
#     METRIC_WARNING_CATEGORIES = METRIC.LCOM
#     METRIC_WARNING_BASE_RANK = 2.0
#     METRIC_WARNING_SIGNIFICANCE = STYLE

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

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