Content-type: text/html Manpage of cyclo

cyclo

Section: User Commands (1)
Updated: Programmer's tools
Index Return to Main Contents
 

NAME

cyclo, mcstrip - tools for analysing cyclomatic complexity  

SYNOPSIS

cyclo [-l] [-t] [-f|-F] [-n func#] [-p] [-s scale] [-c] [-d] [-i]
mcstrip [-l] [-c] [-r] [-a] [inputfile]
 

DESCRIPTION

These two tools are used to measure the cyclomatic complexity of a piece of ANSI C or C++ code. A postscript flowgraph of the functions can also be produced.  

COMMANDS

mcstrip
This command removes comments, string and character constants from the input file, or standard input if none is specified. If any of the following options are given, it will give details of the file instead.

[-l] print number of lines in file
[-c] print number of lines that contain comments
[-r] print ratio of lines against lines with comments
[-a] print all of the above

cyclo
This command takes as its standard input a file that has had the comments, string and character constants removed (by mcstrip ). It will then produce either flowcharts or the cyclomatic complexity number of one or more files in the input.

Information [-l] prints results of tokenisation
[-t] prints results of flow generation
Functions [-i] ignores functions declared within a
struct/class/union
[-n func#] limits output of -p,-f,-F,-c to the given
function number, rather than the default of all functions.
[-f] prints function name(s)
[-F] prints functions called by each source function
[-c] print cyclomatic complexity of function(s)
[-p] produce postscript flow graph
[-s scale] scales postscript output (float)
[-d] prints function names to postscript standard output
 

RETURN CODES

mcstrip always returns zero. cyclo returns one in the event of an error, otherwise it returns zero.  

EXAMPLES

Information about file $ mcstrip -a main.C
63 comment lines
1199 lines
5 % comments to lines ratio
Function names $ mstrip main.C | cyclo -f
Token::Token
Token::~Token
print_funcs
display_arc
display
Function calls $ mcstrip main.C | cyclo -F -n 3
print_funcs
    setw
    setiosflags
    print_token
    resetiosflags Flow charts $ mcstrip main.C | cyclo -p -n 3 > flow.ps
$ gs flow.ps
 

MORE DETAILED INFORMATION

The cyclomatic complexity measure counts the number of decisions made within a piece of code. This number is equal to the number of linearly independent paths through the code. Its main application is in establishing test cases. Be aware that the measure may not be useful. It is recommended that further reading is done before using it.

The following papers contain further relevant information:

'A Complexity Measure' McCabe T.J., IEEE Transactions on Software Engineering vol SE-2, #4 1976, pp 308-320.

'A Critique of Cyclomatic Complexity as a Software Metric' Shepperd M., Software Engineering Journal, March 1988, pp 30-36.

'Software Defect Prevention Using McCabe's Complexity Metric' Ward W.T., Hewlett-Packard Journal, April 1989, pp 64-69.

 

SEE ALSO

cflow(1), wc(1)

 

LIMITATIONS

Only the ANSI C method of declaring functions is recognised.

Constructors that have an initialiser list have their names incorrectly detected.

Lexical elements that span more than one line are not recognised. This includes strings terminating with a continuation slash, struct and the following tag, and function names and the following opening parenthesis.

 

COPYRIGHT

(c) 1993 Roger Binns

These tools were produced by Roger Binns for a fourth year project as part of a computer science degree, for the Computer Science department, Brunel University, Uxbridge, Middlesex UB8 3PH, United Kingdom.

This software is provided in good faith, having been developed by Brunel University students as part of their normal course work. It should not be assumed that Brunel has any rights of ownership, and the University cannot accept any liability for its subsequent use. It is a condition of any such use that the user idemnifies the University against any claim (including third party claims) arising therefrom.

The cyclo tool was updated in 1996 to hande function declarations better and to fix a few bugs. See the README for more information.


 

Index

NAME
SYNOPSIS
DESCRIPTION
COMMANDS
RETURN CODES
EXAMPLES
MORE DETAILED INFORMATION
SEE ALSO
LIMITATIONS
COPYRIGHT

This document was created by man2html, using the manual pages.
Time: 16:20:05 GMT, October 24, 2015