Understand has a very extensible API for scanning projects in your own way. This script shows every result of the HIS metric suite - not just the violations - for every function in your project.

How does it work? The script uses the Python version of the API. It accesses your project’s .und folder, which gives it each file. Each file has a collection of all the references and entities. The main function loops through all the function entities, and runs the 12 checks on each entity. The entity gives us the kind, contents, references, and more. Additionally, the lexer gives us all lexemes in a function along with their token types. With all this info, a check analyzes comment density, call complexity, recursion, etc.

Here’s a result of running the script:

Each line in the CSV has the parent, file, line, function name, and the 12 HIS metrics. An asterisk at the end of the field indicates that there was a violation.


  1. Download the script hisMetricsCsv.py
  2. Each time you want to generate a CSV, scan your project in Understand. At the top menu, click Project > Analyze Changed Files (Ctrl+R).
  3. After the project analysis, run the script with upython:

    upython hisMetricsCsv.py <myProject>/<myProject>.und

  4. If the .und folder is found, the script checks your project. It makes a file, by default <myProject>/<myProject>-<timestamp>.csv.


  • Command Line Arguments
    • Change the HIS metric parameters. See all of the arguments with the -h or --help option:

      upython hisMetricsCsv.py -h

    • Specify the CSV name:

      upython hisMetricsCsv.py <myProject>/<myProject>.und -csv myReport.csv

    • Specify the CSV location and name with an absolute path:

      upython hisMetricsCsv.py <myProject>/<myProject>.und -csv C:/reports/myReport.csv

  • Edit the Script

    • All of the default HIS check metric parameters are at the top of the script. This way, you can save your configuration in the script.