C Quality Metrics
Switch branches/tags
Clone or download
dspinellis Prevent nesting inflation by brace openings
Multiple brace openings not associated with statements
increased the indent level in the nesting top of stack. The brace
balance and indentation level is now maintained as a vector of Boolean
values, which is popped when a closing brace is encountered.

Issue: #8
Latest commit de78033 Mar 23, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Prevent nesting inflation by brace openings Mar 23, 2017
.bettercodehub.yml Add shell script files Jan 13, 2017
.travis.yml Move source code to subdirectory Jan 13, 2017
LICENSE Remove pesky CR line endings Jan 14, 2015
README.md Expand with software's rationale Jan 13, 2017
metrics.md Add metric which counts empty lines Mar 11, 2017


C Code Quality Metrics

Build Status Coverity Scan Build Status

The program qmcalc will read a C source code file from its standard input and print on its standard output a single line containing tens of metrics regarding size, complexity, used keywords, comments and documentation, use of the C preprocessor, and observed formatting style. The full set of the metrics is documented in the file metrics.md.

The code has been written to run efficiently and reliably. The program receives the code to analyze from its standard input, so that it can process data coming e.g. directly out of a git show command, without having intermediate data touch the disk. Also, the program can process code that may not be easy (or possible) to fully parse using a compiler front-end, due e.g. to missing header files or an unknown compiler configuration.

Furthermore, the software is designed in a way that should allow its easy extension to other languages with C-like syntax, such as Java, C++, C#, and Go. The main thing you need to add is an XMetricsCalculator and an XKeyword class. Pull requests for such extensions are more than welcomed.



  • C++ compiler
  • GNU make
  • CppUnit for running make test

To build type change the directory to src (cd src) and run make. This will also generate the files header.tab and header.txt, which can be used for loading the output into other programs for further processing.

Further reading

The style checks performed are based on the following guidelines.