Software Metrics Calculation

Overview

Considering the large amount of data involved, metrics calculation is carried out as a distinct process, should the user request it explicitly. Data compiled during the analysis is placed in the Metrics database, where it can later be accessed and used when generating metrics reports. Metrics calculation results can be examined visually by means of metrics reports, whose contents, as well as the form in which they are displayed, it is possible to adjust at will.

Starting Metrics Calculation

Metrics calculation is carried out immediately after static code analysis. Static code analysis and software metrics calculation can be started by means of either the Start > Build Database or the Start > Rebuild Database command. It is possible to turn metrics calculation off by clearing the Options > Software Metrics Calculator > [x] Generate software metricscheck box. Initially, the metrics calculation is turned off.

Metrics Calculation and Exceeding Limits

In calculating metrics, some of them may exceed the prescribed limits of the scope of acceptable values for a function, module, or group of modules. Should this happen, relevant warnings containing information on the parameter and function/module in question will appear on the Software Metrics tab of the Messages window.

You can disable warnings displayed when parameter values are exceeded for all types of parameters. In this way warnings not relevant to the project will not encumber the Message Logs. A warning that a particular parameter has exceed the prescribed value limits will appear only if the parameter in question has been selected on the General tab of the dialog box obtainable from the Options > Software Metrics Calculator menu. Minimum and maximum suitable parameter values, when applied to modules, that is, functions, can be set on the Module, that is, Function tabs of this dialog box.

Apart from warnings about exceeding limits being displayed, unacceptable property values will be specially marked in metrics report graphics as well.

The Influence of Preprocessing on Metrics Calculation

Preprocessing is a procedure which directly precedes C code compiling and incorporates including header files, resolving conditional compiling, and performing macro expansion.

The content of header files does not directly influence the metrics of the module which includes these files.

Conditional compilation determines which part of the written code, considered in its entirety, is to be compiled. In determining metrics, the metrics analyzer considers only that part of the code which is to be compiled.

Macro expansion can also influence particular metrics, because macro expansion changes the form in which the code to be compiled will be displayed.

The Relation Between Metrics Calculation and Static Code Analysis

The metrics analyzer cannot recognize syntax errors in the code. Syntax errors are pinpointed by the static code analysis process, launched immediately prior to metrics calculation. Should static code analysis show that there are syntax or other errors in the program, correcting them prior to use or interpretation of metrics calculation results is recommended.

Metrics Calculation and Different C Language Dialects

The metric analyzer recognizes the differences between the different C language dialects supported by DAC static code analysis. This is reflected in the different syntax of particular constructions, additional types of data, additional keywords, additional operators, and so on. As in the case of static code analysis, it is necessary to choose the correct dialect in which the source was implemented; otherwise, metrics data will not be valid.

Metrics Calculation and Specific Function Calls

Particular system calls and standard library functions, even if not a part of C language, can influence the course of program control. Examples would be exit() and longjmp(), which cause exiting of the current function (and probably other functions as well). The metrics analyzer considers these functions regular function calls. Using these functions can endanger the precision of metrics influenced by the number of exits from a function and metrics which count jump commands (for example, Cyclomatic Complexity depends on the number of exits from a function).

In order to determine property values with greater precision, you can, temporarily, substitute the specified function calls with equivalent C commands; for example, the return command.


Copyright 1993-2017, RistanCASE GmbH