The metrics report configuration file (metrics.xml) defines the metrics that are reported in Klocwork Static Code Analysis. The metrics.xml file is located at
<projects_root>/config
Important: Before you make any changes, back up the metrics report configuration file.
You can customize metrics reports under either of the following <category> tags:
<category catid="TotalMetricValue">
Reports the total value of specified metrics, such as the number of lines of code in given modules.
Important: TotalMetricValue can only use File/Class metrics (not Function/Method metrics).
<category catid="EntityCountOverThreshold">
Reports the number of entities whose value exceeds a threshold for the given metrics, for example, the number of methods with a cyclomatic complexity that exceeds 20.
Each <metric> element defines one metrics report. You can edit the values in the default reports, and add multiple custom metrics reports to each category by creating multiple <metric> sections.
The following are the sub-elements of the <metric> element that you may need to customize:
Element |
Purpose |
<name> |
A short name for the report that appears in Static Code Analysis. |
<description> |
A detailed title that appears at the top of the report in Static Code Analysis. Note: If you want to include the threshold value in the report title, you can use {threshold} as a placeholder. Klocwork replaces it with the threshold value. |
<custom_metric_names> |
Used for adding custom reports based on metrics you define (as opposed to the Klocwork metrics). One or more metrics from the .ume file (the value for the <metric_name> field). |
<kids> |
Used for adding custom reports based on Klocwork metrics (as opposed to metrics you define). For both EntityCountOverThreshold and TotalMetricValue, use the Klocwork metric ID. You can find the metric IDs in Metrics reference. See:
|
<entityKids> |
For the EntityCountOverThreshold report only. The list of Klocwork entity kinds to count. For the list of possible values, see Supported entity types. Typical value to represent C/C++ files and Java classes: 1,46 Typical value to represent C/C++ functions and Java methods: 5,48 |
<default_threshold> |
For the EntityCountOverThreshold report only. The default value for the threshold. If the default threshold value is not specified with this tag, a value of 20 is used. Note:
Static Code Analysis allows users to reset the threshold value. |
<enable> |
Disable the metric by setting it to "false"; enable the metric by setting it to "true". |