Defining custom metrics for C/C++ [Halstead and others]
We are migrating from version 9 to 10 of C/C++. One of the things we wanted to do was run more metrics on code. Discovered a short blog on how to export, modify and then import the properties file. In our case we want to try out Halstead metrics and any of the other metrics available for C/C++. When we do the export we see the Halstead metrics for DotNet but not for C/C++. Attempted several configurations but no success. So I will list the questions followed by a textual example of the properties file.
**
Are the loading/saving of metrics configurable in version v10+ only or v9 as well ?
[ A CHART FOR WHICH F(X) ARE SUPPORTED IN EACH RELEASE WOULD BE GREAT ]
The Hastead metrics definitions are exported in the configuration for dotnet but not for C++, are these supported in C++ ?
Are there examples of setting up the configuration file for each metric ?
Are there examples of setting the range values for each metrics MAX/MIN ?
Examples-Questions follow:
1)
//tried this as a test - no luck
METRIC.HDIFM.ThresholdEnabled=true
METRIC.HDIFM.Threshold=1 10
2)
//added below as a test - no luck
com.parasoft.xtest.checker.metrics.enable.metric.cpp.CYCLOMATIC_COMPLEXITY=true
//although these are exported in the same file as dotnet options, we tried them with .cpp in the configuration name but no luck.
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.CYCLOMATIC_COMPLEXITY=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.EFFECTIVE_CODE_LINES_METHOD=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.INHERITANCE_DEPTH=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.LACK_OF_COHESION=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.MAINTAINABILITY_INDEX=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NESTED_BLOCKS_DEPTH=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_CLASS_COUPLING=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_CLASSES=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_CODE_LINES_IN_METHOD=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_INSTANCE_METHODS=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_INTERFACES=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_LINES_IN_METHOD=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_METHOD_PARAMETERS=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_NAMESPACES=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_STATIC_METHODS=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_TYPE_INSTANCE_FIELDS=true
com.parasoft.xtest.checker.metrics.enable.metric.dotnet.NUM_OF_TYPE_STATIC_FIELDS=true
com.parasoft.xtest.checker.metrics.enabled=true
~~~~
Comments
-
Hi Paul,
I wanted to get a quick response, so please forgive the brevity;
- do you have access to DTP? The Test Configuration UI in DTP should address most (if not all) of your questions ... I have included some references to the online documentation here ...
https://docs.parasoft.com/display/CPPTEST1033/Editing+Test+Configurations+Stored+in+DTP
NOTE: You can export/download a test configuration from DTP into a local property file
FYI: in 10.x we standardized all the products (dotTEST, Jtest, C/C++test) to have the same metrics ... this is not universally the same as 9.x. The full list can be accessed from within the Test Configuration view in DTP and I have attached an HTML file (as a text file so that it can be posted) containing all the metrics to this forum post.
FYI: in 10.4.0 (due out in early May) we will be introducing a new Test Configuration UI in the desktop plugin (based on the version that is currently in DTP).
Let me know if this helps
ML
0 -
Also ... attached is an 'All Metrics' property file with thresholds set for Halstead Difficulty [METRIC.HDIFM-3]
"METRIC.HDIFM=true
METRIC.HDIFM.Threshold=g 1 l 10
METRIC.HDIFM.ThresholdEnabled=true"Here is a doc ref that might also be helpful: https://docs.parasoft.com/display/CPPTEST1033/Analysis+Types+1#AnalysisTypes1-SettingMetricsThresholds
0