javancss
Class JavancssAntTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.MatchingTask
              extended by javancss.JavancssAntTask
All Implemented Interfaces:
Cloneable, org.apache.tools.ant.types.selectors.SelectorContainer

public class JavancssAntTask
extends org.apache.tools.ant.taskdefs.MatchingTask

Ant task to report and check basic code metrics.

This task wraps the JavaNCSS library for determining code metrics. The library determines several code metrics such as object counts, non-commented source statements (NCSS), cyclomatic complexity numbers (CCN), and javadoc statements. These counts are subtotaled per function, class, and package. This task allows you to place minimum and maximum thresholds on each of these (not all of these make sense but all are included for completeness).

The original version of this task was written by Steve Jernigan and made available on SourceForge as the JavaNCSS2Ant project. It was subsequently extended by Phillip Wells to enable access to the report generation feature of the tool whereupon it was submitted for inclusion in Ant itself.

JavaNCSS was developed by Christoph Clemens Lee and is available here.

Author:
Phillip Wells, Steve Jernigan, Clemens Lee

Field Summary
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
JavancssAntTask()
          Creates a new instance of the task.
 
Method Summary
 org.apache.tools.ant.types.Path createClasspath()
          Maybe creates a nested classpath element.
 void execute()
          Executes this task.
 void setAbortOnFail(boolean abortOnFail)
          Sets whether the build should halt if there is an error or a threshold is exceeded.
 void setCcnPerFuncMax(int ccnPerFuncMax)
          Sets the maximum value of the Cyclomatic Complexity Number per function.
 void setCcnPerFuncMin(int ccnPerFuncMin)
          Sets the minimum value of the Cyclomatic Complexity Number per function.
 void setClassMetrics(boolean classMetrics)
          Whether class/interface metrics should be generated.
 void setClasspath(org.apache.tools.ant.types.Path classpath)
          Set the classpath to be used.
 void setClassPerClassMax(int classPerClassMax)
          Sets the maximum number of inner classes per class.
 void setClassPerClassMin(int classPerClassMin)
          Sets the minimum number of inner classes per class.
 void setClassPerPkgMax(int classPerPkgMax)
          Sets the maximum number of classes per package.
 void setClassPerPkgMin(int classPerPkgMin)
          Sets the minimum number of classes per package.
 void setFormat(String format)
          Sets the format of the output file.
 void setFuncPerClassMax(int funcPerClassMax)
          Sets the maximum number of functions per class.
 void setFuncPerClassMin(int funcPerClassMin)
          Sets the minimum number of functions per class.
 void setFuncPerPkgMax(int funcPerPkgMax)
          Sets the maximum number of functions per package.
 void setFuncPerPkgMin(int funcPerPkgMin)
          Sets the minimum number of functions per package.
 void setFunctionMetrics(boolean functionMetrics)
          Whether function metrics should be generated.
 void setGenerateReport(boolean generateReport)
          Whether a report should be generated.
 void setJvdcPerClassMax(int jvdcPerClassMax)
          Sets the maximum number of javadoc comments per class.
 void setJvdcPerClassMin(int jvdcPerClassMin)
          Sets the minimum number of javadoc comments per class.
 void setJvdcPerFuncMax(int jvdcPerFuncMax)
          Sets the maximum number of javadoc comments per function.
 void setJvdcPerFuncMin(int jvdcPerFuncMin)
          Sets the minimum number of javadoc comments per function.
 void setNcssPerClassMax(int ncssPerClassMax)
          Sets the maximum number of non-commenting source statements per class.
 void setNcssPerClassMin(int ncssPerClassMin)
          Sets the minimum number of non-commenting source statements per class.
 void setNcssPerFuncMax(int ncssPerFuncMax)
          Sets the maximum number of non-commenting source statements per function.
 void setNcssPerFuncMin(int ncssPerFuncMin)
          Sets the minimum number of non-commenting source statements per function.
 void setNcssPerPkgMax(int ncssPerPkgMax)
          Sets the maximum number of non-commenting source statements per package.
 void setNcssPerPkgMin(int ncssPerPkgMin)
          Sets the minimum number of non-commenting source statements per package.
 void setOutputfile(File outputfile)
          Sets the location of the output file.
 void setPackageMetrics(boolean packageMetrics)
          Whether package metrics should be generated.
 void setSrcdir(File srcdir)
          Sets the directory to be scanned by the tool.
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavancssAntTask

public JavancssAntTask()
Creates a new instance of the task.

Method Detail

setFormat

public void setFormat(String format)
Sets the format of the output file.

Parameters:
format - the format of the output file. Allowable values are 'plain' or 'xml'.

setPackageMetrics

public void setPackageMetrics(boolean packageMetrics)
Whether package metrics should be generated.

Parameters:
packageMetrics - true if they should; false otherwise.

setClassMetrics

public void setClassMetrics(boolean classMetrics)
Whether class/interface metrics should be generated.

Parameters:
classMetrics - true if they should; false otherwise.

setFunctionMetrics

public void setFunctionMetrics(boolean functionMetrics)
Whether function metrics should be generated.

Parameters:
functionMetrics - true if they should; false otherwise.

setGenerateReport

public void setGenerateReport(boolean generateReport)
Whether a report should be generated. Default is false.

Parameters:
generateReport - true if they should; false otherwise.

setSrcdir

public void setSrcdir(File srcdir)
Sets the directory to be scanned by the tool. This should be the directory containing the source files whose metrics are to be analysed.

Parameters:
srcdir - the directory to be scanned by the tool.

setOutputfile

public void setOutputfile(File outputfile)
Sets the location of the output file.

Parameters:
outputfile - the location of the output file.

setClasspath

public void setClasspath(org.apache.tools.ant.types.Path classpath)
Set the classpath to be used.

Parameters:
classpath - the classpath to be used.

setAbortOnFail

public void setAbortOnFail(boolean abortOnFail)
Sets whether the build should halt if there is an error or a threshold is exceeded.

Parameters:
abortOnFail - true if it should; false otherwise.

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Executes this task.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if an error occurs.

createClasspath

public org.apache.tools.ant.types.Path createClasspath()
Maybe creates a nested classpath element.


setClassPerPkgMax

public void setClassPerPkgMax(int classPerPkgMax)
Sets the maximum number of classes per package.

Parameters:
classPerPkgMax - the maximum number of classes per package.

setClassPerPkgMin

public void setClassPerPkgMin(int classPerPkgMin)
Sets the minimum number of classes per package.

Parameters:
classPerPkgMin - the minimum number of classes per package.

setFuncPerPkgMax

public void setFuncPerPkgMax(int funcPerPkgMax)
Sets the maximum number of functions per package.

Parameters:
funcPerPkgMax - the maximum number of functions per package.

setFuncPerPkgMin

public void setFuncPerPkgMin(int funcPerPkgMin)
Sets the minimum number of functions per package.

Parameters:
funcPerPkgMin - the minimum number of functions per package.

setNcssPerPkgMax

public void setNcssPerPkgMax(int ncssPerPkgMax)
Sets the maximum number of non-commenting source statements per package.

Parameters:
ncssPerPkgMax - the maximum number of non-commenting source statements per package.

setNcssPerPkgMin

public void setNcssPerPkgMin(int ncssPerPkgMin)
Sets the minimum number of non-commenting source statements per package.

Parameters:
ncssPerPkgMin - the minimum number of non-commenting source statements per package.

setClassPerClassMax

public void setClassPerClassMax(int classPerClassMax)
Sets the maximum number of inner classes per class.

Parameters:
classPerClassMax - the maximum number of inner classes per class.

setClassPerClassMin

public void setClassPerClassMin(int classPerClassMin)
Sets the minimum number of inner classes per class.

Parameters:
classPerClassMin - the minimum number of inner classes per class.

setFuncPerClassMax

public void setFuncPerClassMax(int funcPerClassMax)
Sets the maximum number of functions per class.

Parameters:
funcPerClassMax - the maximum number of functions per class.

setFuncPerClassMin

public void setFuncPerClassMin(int funcPerClassMin)
Sets the minimum number of functions per class.

Parameters:
funcPerClassMin - the minimum number of functions per class.

setNcssPerClassMax

public void setNcssPerClassMax(int ncssPerClassMax)
Sets the maximum number of non-commenting source statements per class.

Parameters:
ncssPerClassMax - the maximum number of non-commenting source statements per class.

setNcssPerClassMin

public void setNcssPerClassMin(int ncssPerClassMin)
Sets the minimum number of non-commenting source statements per class.

Parameters:
ncssPerClassMin - the minimum number of non-commenting source statements per class.

setJvdcPerClassMax

public void setJvdcPerClassMax(int jvdcPerClassMax)
Sets the maximum number of javadoc comments per class.

Parameters:
jvdcPerClassMax - the maximum number of javadoc comments per class.

setJvdcPerClassMin

public void setJvdcPerClassMin(int jvdcPerClassMin)
Sets the minimum number of javadoc comments per class.

Parameters:
jvdcPerClassMin - the minimum number of javadoc comments per class.

setCcnPerFuncMax

public void setCcnPerFuncMax(int ccnPerFuncMax)
Sets the maximum value of the Cyclomatic Complexity Number per function.

Parameters:
ccnPerFuncMax - the maximum value of the Cyclomatic Complexity Number per function.

setCcnPerFuncMin

public void setCcnPerFuncMin(int ccnPerFuncMin)
Sets the minimum value of the Cyclomatic Complexity Number per function.

Parameters:
ccnPerFuncMin - the minimum value of the Cyclomatic Complexity Number per function.

setNcssPerFuncMax

public void setNcssPerFuncMax(int ncssPerFuncMax)
Sets the maximum number of non-commenting source statements per function.

Parameters:
ncssPerFuncMax - the maximum number of non-commenting source statements per function.

setNcssPerFuncMin

public void setNcssPerFuncMin(int ncssPerFuncMin)
Sets the minimum number of non-commenting source statements per function.

Parameters:
ncssPerFuncMin - the minimum number of non-commenting source statements per function.

setJvdcPerFuncMax

public void setJvdcPerFuncMax(int jvdcPerFuncMax)
Sets the maximum number of javadoc comments per function.

Parameters:
jvdcPerFuncMax - the maximum number of javadoc comments per function.

setJvdcPerFuncMin

public void setJvdcPerFuncMin(int jvdcPerFuncMin)
Sets the minimum number of javadoc comments per function.

Parameters:
jvdcPerFuncMin - the minimum number of javadoc comments per function.


Copyright © 1997-2011 Chr. Clemens Lee and companions. All Rights Reserved.