25.11. FileMetric

25.11.1. Overview

The FileMetric sensor data type is designed for representation of static structural metrics of a source file in a language-independent manner. Table 25.12, “FileMetric SDT attributes” documents its attributes.

Table 25.12. FileMetric SDT attributes

AttributeDescription
tstampThe UTC time at which this data was collected.
toolA string indicating the tool that collected this data, such as "BCML" or "LOCC".
fileNameThe absolute path to the source file from which these metrics were collected.
fileTypeThe type associated with this file. A sensor may derive the file type by either using the file extension (such as "java", "ppt", or "tex") or by examining the contents of the file (such as "makefile", or "csh").
totalLinesA string containing the total (nonblank) number of lines in this file. This constitutes the minimum, default "metric" that must be associated with any given file. Any number of additional metrics for this file can be provided as part of its property map data.

In addition to the above required fields for all FileMetric data, there are a number of "optional but common" attributes that can appear on the property map. These are documented in Table 25.13, “FileMetric SDT "optional but common" properties” so that size tool sensor writers can produce FileMetric sensor data that can be processed by the built-in FileMetric analyses and reduction functions.

Table 25.13. FileMetric SDT "optional but common" properties

PropertyDescription
sourceLinesThe number of non-comment, non-blank lines of code in the file.
commentLinesThe number of non-blank comment lines in the file.
classCountThe number of classes in the file.
functionCountThe number of functions (methods, subroutines, etc.) in the file.
functionSizeListA string containing the number of lines associated with each function, delimited by hyphens. For example, "23-45-89" represents three functions with 23, 45, and 89 LOC.
classNameA string containing the fully qualified class name associated with this file. This is used by the "workspace file mapping" mechanism, which enables unit test and coverage data that is sent with a className but no fileName to determine the fileName (and thus workspace) it is associated with.

Finally, it is important to note that the FileMetric SDT was evolved in January, 2005. Thus, there may exist data prior to that time (or subsequent to that time, if the sensors were not updated) that is stored on disk in a different format. However, the evolutionary mechanism will upgrade the old data to this format when reading it in from disk.

25.11.2. Applications of the FileMetric SDT

The LOCC tool generates a variety of structural metrics on source code files, ranging from standard line of code counts to more domain-specific metrics, such as the number of parallel processing (MPI) library invocations. A sensor for LOCC represents this data as FileMetric entries.

The BCML tool parses Java class files containing byte codes and generates metrics similar to the Chidamber-Kemerer object oriented metrics, including Weighted Methods per Class (WMC), Depth of inheritance tree (DIT), Number of children (NOC), Coupling between objects (CBO), and Response for class (RFC). A sensor for BCML represents this data as FileMetric entries.

The CCCC tool parses C++ files and generates a variety of procedural and object oriented metrics. A sensor for CCCC represents this data as FileMetric entries.

Once collected, FileMetric data can be used to track trends in the structural metrics associated with a system as it is developed, and to investigate potential relationships between its structure and other product or process measures, such as defects, time, dependencies, test failures, build failures, and so forth.