CMetrics measures size and complexity for C files
Shell C Python
Switch branches/tags
Nothing to show
Clone or download


C metrics package


see INSTALL file


cmetrics [-h] [-f] [-p] [-n] target_dir

positional arguments:
  target_dir       directory with sources (recursively scanned)

optional arguments:
  -h, --help       show this help message and exit
  -f, --functions  show metrics for functions instead of files
  -p, --path       show full file path in the last column
  -n, --no-header  do not show metrics names in the first row


CMetrics measures size and complexity for C files. The metrics are the

 SLOC    Source Lines of Code (text lines excluding blanks and
 LOC	 Text lines in the source code file (including blanks, etc)
 BLANK	 Number of blank lines
 COM.L	 Number of lines that are exclusively comments (no code)
 COM.N	 Number of comments in the file (a comment can be multiline)
 H.LEN	 Halstead's Length
 H.VOL	 Halstead's Volume
 H.LEVEL Halstead's Level
 H MEN.D Halstead's number of mental discriminations
 MAXCY	 Maximum McCabe's cyclomatic complexity (between all the
 MINCY	 Minimum McCabe's cyclomatic complexity
 AVGCY	 Average McCabe's cyclomatic complexity
 MEDCY	 Median McCabe's cyclomatic complexity
 TOTCY	 Total McCabe's cyclomatic complexity (sum of all functions)

If you use the '-f' option, you will get info for functions instead of
files. If the function name is "***", it means that it is code outside
of the scope of functions but inside the file. The available metrics

 SLOC    Source Lines of code
 CYCLO	 McCabe's cyclomatic complexity
 RETURN	 Number of exit points in the function


This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

See the COPYING file for details.

(c) 2007-2011 Israel Herraiz

Imported from the C Metrics package by Brian Renaud.

It has been "adopted" by Libresoft with permission of the original
author, and it is now part of the Libresoft-tools project.

Check for details