net.sourceforge.cobertura.reporting

Class Util


public abstract class Util
extends java.lang.Object

Field Summary

private static Logger
logger

Method Summary

static double
getCCN(File file, boolean recursive)
Calculates the code complexity number for a given class.
private static Vector
getListOfFiles(File file, boolean recursive)
Create a Vector containing the file names of Java source code.

Field Details

logger

private static final Logger logger

Method Details

getCCN

public static double getCCN(File file,
                            boolean recursive)
Calculates the code complexity number for a given class. "CCN" stands for "code complexity number." This is sometimes referred to as McCabe's number. This method calculates the average cyclomatic code complexity of all methods in a given class, or of all methods of all classes in a given directory. This recursive calculation is useful for calculating the average CCN for a specific package.

Parameters:
file - The source of a Java class for which you want to calculate the complexity, or a directory containing Java source files for which you want to calculate the complexity.
recursive - If file is a directory, this parameter is used to decide whether to only list the files in the given directory, or to list all files in all subdirectories of the given directory.

Returns:
The average cyclomatic code complexity for this class.


getListOfFiles

private static Vector getListOfFiles(File file,
                                     boolean recursive)
Create a Vector containing the file names of Java source code. If the given file parameter is a regular file, then the return value only contains the absolute path of this file. However, if the given file parameter is a directory, this vector contains absolute paths to all files under this directory and all subdirectories.

Parameters:
file - A Java source file or a directory containing Java source files.

Returns:
A Vector containing Strings that are absolute paths to Java source files.