| pmccabe |
McCabe-style function complexity and line counting for C and C++ |
|||||||||||||||||
|
pmccabe calculates McCabe-style cyclomatic complexity for C and C++ source code. Per-function complexity may be used for spotting likely trouble spots and for estimating testing effort. pmccabe also includes a non-commented line counter, decomment which only removes comments from source code; codechanges, a program to calculate the amount of change which has occurred between two source trees or files; and vifn, to invoke vi given a function name rather than a file name. pmccabe attempts to calculate the apparent complexity rather than the complexity after the C++ and/or cpp preprocessors. This causes pmccabe to become confused with cpp constructs which cause unmatched curly braces - most of which can profitably be rewritten so they won't confuse prettyprinters anyway. pmccabe prints C-compiler-style error messages when the parser gets confused so they may be browsed with standard tools. Two types of cyclomatic complexity are generated - one type counts each C switch statement as regardless of the number of cases included and the other more traditional measure counts each case within the switch. pmccabe also calculates the starting line for each function, the number of lines consumed by the function, and the number of C statements within the function. pmccabe is open software licensed under the terms of the GNU General Public License. It has been used within Hewlett-Packard since the early nineties. |