Skip to content
SciTools Blog
Menu
  • Home
  • Blog
  • Support
  • Contact
  • Login
  • Pricing
  • Free Trial
Menu

Useful Script: Export All Metric Values, Not Just Violations

Posted on September 15, 2021

TLDR:

CodeCheck will currently tell you the violations of the metrics, but not all the details. This script exports a CSV that lets you know all the values, whether they pass the standard or not. We do this for the Hersteller Initiative Software Metrics, but you can easily tweak it to do all or any you choose. If you need help, hit us up at [email protected].

Details:

Metrics teach you a lot about your project’s code. Understand checks your code with hundreds of published metrics, including the Hersteller Initiative Software (HIS) Metrics. The initiative, which originated in the automobile industry, sets standards for common metrics that will help your code have clarity, simplicity, and higher quality. Interesting metrics like the number of paths, call tree depths and the cost of maintaining a function.

CodeCheck simplifies a project of any size. But, how do you compare functions that don’t violate the metrics? Maybe you want to track or visualize this data over time. This script exports all of the info you need, using the Understand Python API. We also have C, Java, and Perl APIs providing the same power. Learn about usage, customization, and download it here.

How does it work? The script 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. With this info, a check analyzes comment density, call complexity, recursion, etc.

How was it made? The Understand API gives us information about each entity, in this case, each function. An entity gives all references to itself, such as when it’s used, passed, or defined. The entity and reference API informs us of each occurrence of anything we want to look for, such as when a member method is defined in C++. The other tool in our toolbelt is the lexer. With it, we step through all the symbols and we know about the type of each symbol. Each of the 12 HIS checks uses these tools and report how well a function follows the metric. Add new metrics yourself by using the API.

The output is a CSV file with data for each function. Each line contains the parent, file name, line number, function name, and the 12 HIS metrics. Here’s an example of scanning the Linux kernel.

  • Instagram
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Learn more about Understand's Features

  • Dependency Graph
    View Dependency Graphs
  • Comply with Standards
  • View Useful Metrics
  • Team Annotations
  • Browse Depenedencies
  • Edit and Refactor

Related

Leave a Reply Cancel reply

You must be logged in to post a comment.

  • API
  • Architectures
  • Business
  • Code Comparison
  • Code Comprehension
  • Code Navigation
  • Code Visualization
  • Coding Standards
  • Dependencies
  • Developer Notes
  • DevOps
  • Getting Started
  • Legacy Code
  • Licensing
  • Metrics
  • Platform
  • Plugins
  • Power User Tips
  • Programming Practices
  • Uncategorized
  • Useful Scripts
  • User Stories
  • May 2025
  • January 2025
  • December 2024
  • November 2024
  • August 2024
  • June 2024
  • May 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • April 2023
  • January 2023
  • December 2022
  • November 2022
  • September 2022
  • August 2022
  • May 2022
  • April 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

©2025 SciTools Blog | Design: Newspaperly WordPress Theme