The CCCC Sensor is an Ant task that sends C/C++ and Java file metrics produced by CCCC to the Hackystat server. The CCCC sensor represents this metric data using the FileMetric sensor data type, documented in Section 25.11, “FileMetric”
The CCCC Sensor implements a custom Ant task definition that invokes CCCC on a set of C/C++ or Java files in one or more directory hierarchies. The results of the CCCC metrics computation are stored in an XML file. The CCCC Sensor then reads in this XML file and sends it off to the Hackystat server.
Each CCCC file generates one Hackystat FileMetric entry. All FileMetric entries include the fileName, the fileType, and the totalLines attributes. Table 26.3, “CCCC Optional Metrics” lists the additional optional metrics gathered by this sensor and stored on the FileMetric PropertyMap. Note that the specific optional metrics gathered for a given file depend upon its file type.
Table 26.3. CCCC Optional Metrics
| Metric | Description |
|---|---|
| sourceLines | Source lines Of code. Number of non-blank, non-comment source lines of code. |
| commentLines | Comment lines of code. Number of non-blank, comment lines of code. |
| s_c_r | Source code to comment ratio (sloc / cloc). Indicates density of comments with respect to textual size of program |
| mccn | McCabe's Cyclomatic Number. A measure of the decision complexity of the functions which make up the program. The strict definition of this measure is that it is the number of linearly independent routes through a directed acyclic graph which maps the flow of control of a subprogram. The analyser counts this by recording the number of distinct decision outcomes contained within each function, which yields a good approximation to the formally defined version of the measure. |
| m_c_r | McCabe's cyclomatic number to comment ratio (mccn / cloc). Indicates density of comments with respect to logical complexity of program. |
| if4 | Information flow (inclusive). A composite measure of structural complexity, calculated as the square of the product of the fan-in and fan-out of a single module. Proposed by Henry and Kafura. |
| if4v | Information flow (visible). Calculated using only relationships in the visible part of the module interface. |
| if4c | Information flow (concrete). Calculated using only those relationships which imply that changes to the client must be recompiled if the supplier's definition changes. |
The CCCC sensor requires Java 1.5.0 or later, Ant 1.6.5 or later, and CCCC 3.1.4.
Download CCCC 3.1.4, gunzip, untar, and run the appropriate build file as noted in the installation instructions.
![]() | Important |
|---|---|
Be sure you can manually invoke CCCC on a sample C/C++ or Java file and obtain metrics before proceeding with the installation of the CCCC sensor. | |
Follow the instructions in Chapter 2, Client-side configuration: Tool sensor installation to set your Hackystat host and user key.
In the HackyInstaller main window, select the Ant Build sensor and press "Configure Selected Sensor". Figure 26.6, “ CCCC installer configuration window ” shows what the configuration window should look like after the path to Ant is set, the sensor is enabled, and the "Install" button has been pressed to install the sensor.
This sensor supports the following properties and paths:
Enable CCCC Sensor: This property controls whether the sensor is active or not. If not checked, the sensor will not collect or send data even if installed.
Ant home directory: This path specifies the top-level directory for Ant. The CCCC sensor requires the placement of a sensor executable into Ant's lib/ directory.
Define a target in your build.xml file to calculate metrics from the .class files using CCCC and send them to Hackystat using the cccc sensor. Example 26.9, “An example CCCC target” illustrates one possible definition of such a target.
Example 26.9. An example CCCC target
<taskdef name="hacky-cccc" classname="org.hackystat.sensor.cccc.CCCCSensor"/>
<target name="cccc" description="Runs CCCC over source files and sends structural data to Hackystat.">
<hacky-cccc ccccHome="${ccccHome.dir}"
ccccExeName="cccc.exe"
ccccOutputDir="${ccccOutput.dir}"
verbose="on">
<fileset dir="${input.dir}" />
</hacky-cccc>
</target>
Please note the following regarding Example 26.9, “An example CCCC target”:
To verify your CCCC sensor installation, invoke the target and check to see that data is sent to the server. Example 26.10, “Example CCCC output” shows the shell output from an example run on the cccc_xml.cc file included with the CCCC distribution with verbose="on".
Example 26.10. Example CCCC output
[hacky-cccc] File Name : C:\svnHackystat\hackySensor_Cccc\test\CCCCMetricExtractor.java [hacky-cccc] Metric Data : sloc=87,cloc=44,s_c_r=1.977,mccn=3,m_c_r=3,if4=0,if4v=0,if4c=0 [hacky-cccc] [hacky-cccc] File Name : C:\svnHackystat\hackySensor_Cccc\test\Edge.cc [hacky-cccc] Metric Data : sloc=94,cloc=37,s_c_r=2.541,mccn=24,m_c_r=24,if4=0,if4v=0,if4c=0 [hacky-cccc] [hacky-cccc] File Name : C:\svnHackystat\hackySensor_Cccc\test\Edge.h [hacky-cccc] Metric Data : sloc=24,cloc=91,s_c_r=0.264,mccn=0,m_c_r=0,if4=0,if4v=0,if4c=0 [hacky-cccc] [hacky-cccc] File Name : C:\svnHackystat\hackySensor_Cccc\test\mpi_one_circ_msg.c [hacky-cccc] Metric Data : sloc=41,cloc=5,s_c_r=8.200,mccn=6,m_c_r=6,if4=0,if4v=0,if4c=0
Once you verify that CCCC data is being sent from the client using verbose mode, login to your account on your Hackystat server, and use the "List Sensor Data" command on the Extras page to verify that FileMetric data for today's date was received by the server for the CCCC tool, as illustrated in Figure 26.7, “ List Sensor Data with CCCC data ”.
The first step in troubleshooting your sensor installation is to verify that your Hackystat host and key settings are valid and that you can contact the Hackystat server, as described in Section 2.4, “HackyInstaller GUI: Setting and verifying the Hackystat host and user key”
The CCCC sensor writes out a file called cccc.0.log to the .hackystat/logs directory that can be useful in debugging your installation. Under normal conditions, this file should look similar to Example 26.11, “Log file for the CCCC sensor”.
If none of the above troubleshooting activities solves your problem, then you should send an email to your Hackystat Administrator to request help. Please include in your email the following information:
The output from 'java -version'.
The output from 'java -jar sensorshell.jar -verify'.
The contents of your sensor.properties file.
A description of the problem you are having.
You probably don't want to have to invoke "ant cccc" manually each time you want metric data sent to Hackystat. It is better to have the CCCC data calculated and sent to Hackystat automatically as a natural course of development. One strategy is to make the cccc target a dependent target of an "install" or "distribution" target so that structural data is recorded each time significant changes occur to the system. This provides a historical record of the structural evolution that can be later used by Hackystat analyses.
To disable CCCC data collection temporarily, invoke HackyInstaller, bring up the CCCC configuration window, and uncheck the "Enable CCCC sensor" property, and apply the setting. To permanently uninstall the CCCC sensor, press the "Uninstall" button and remove the CCCC targets from your Ant build.xml files.