Sunday, June 14, 2015

C and C++ Code Counter - A Software Metric Tool

         CCCC ( C and C++ Code Counter) a software metrics tool. CCCC  analyses and  reports measurements of source code in C, C++, and Java. It was developed to augment programmers' instinctive application of  numeric  rules  of thumb about what constitutes high or low quality products with an automated analysis tool. CCCC processes the files listed on its command line.  If the  file names include ‘-’, read a list of files from standard input.

         CCCC will provide the following details/information of the code modules.
  • MVG = McCabe's Cyclomatic Complexity
    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 sub-program. 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. 
  • NOM = Number of modules
    Number of non-trivial modules identified by the analyser. Non-trivial modules include all classes, and any other module for which member functions are identified.
  • LOC = Lines of Code
    Number of non-blank, non-comment lines of source code counted by the analyser.
  • COM = Lines of Comments
    Number of lines of comment identified by the analyser
  • L_C = Lines of code per line of comment
    Indicates density of comments with respect to textual size of program
  • M_C = Cyclomatic Complexity per line of comment
    Indicates density of comments with respect to logical complexity of program
  • IF4 = Information Flow measure
    Measure of information flow between modules suggested by Henry and Kafura. The analyser makes an approximate count of this by counting inter-module couplings identified in the module interfaces.

Installation: CCCC is included in most of the linux operating systems repositories. You just need to type the following command to install CCCC on debian based systems.

- sudo apt-get install cccc

If the tools not available in your linux system repository you can download it from http://sourceforge.net/projects/cccc/ .

Usage: To know the usage of CCCC type the command man cccc in your terminal. A typical command of cccc usage is as follows.

- cccc your_sourcefile_name.cpp

The above command will generate a html page with name cccc.html in your present working directory, which provides the above mentioned information of your modules in the your_sourcefile_name.cpp. A sample cccc.html screen shot is as follows.


No comments:

Post a Comment