Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

Simple walk-through: Customizing the default Size and Complexity reports

As a simple example, we walk through customizing the default Size and Complexity reports. This example familiarizes you with the metrics.xml file, so that you can perform more complicated customizations, such as adding your own report types. It also shows you where you need to verify that your changes appear in Klocwork Static Code Analysis.

To customize the default Size and Complexity reports:

  1. Back up the following file:
    <projects_root>/config/metrics.xml
  2. Open the original metrics.xml file for editing.
  3. For the Size report, you can change only the label that appears in the list of report types in Static Code Analysis. To change this label, edit the value for the <name> element (Size by default).
    As an example, we change the value for the <name> element to "Lines of Code":
    <category catid="TotalMetricValue">
    <metric>
    <name>Lines of Code</name>
    <description>Lines of Code</description>
    <!--involved kw internal metric kinds-->
    <kids>45,84</kids>
    <enable>true</enable>
    </metric>
    </category>
  4. For the Complexity report:
    • To change the short title (the label that appears in the list of report types in Static Code Analysis), edit the value for the <name> element (Complexity by default).
    • To change the default threshold (the value that appears in the editable Threshold field in Static Code Analysis), edit the value for the <default_threshold> element (20 by default).
    As an example, we change the value for the <default_threshold> element to 10:
    <category catid="EntityCountOverThreshold">
    <metric>
    <name>Complexity</name>
    <description>Method Complexity >{threshold}</description>
    <kids>135</kids>
    <entityKids></entityKids>
    <default_threshold>10</default_threshold>
    <enable>true</enable>
    </metric>
    </category>
  5. Save the file.
  6. Restart the Klocwork Server with kwservice restart or Windows Services Administration.
    The changes you have made are visible to all Static Code Analysis users when they log in, or when they refresh the Reports page. We now verify that our changes are appearing correctly.
  7. Log in to Static Code Analysis.
  8. Click Reports for your project.
  9. Click Create a new report.
    Note: If you were already viewing the report types, refresh your browser to pick up the changes to metrics.xml.
  10. The report types are displayed on the right. Scroll down and click see more.
    We see that our list now includes the Lines of Code report type (instead of Size).
  11. Select Complexity.
    We see that the default threshold is now set at 10 (instead of 20).