com.puppycrawl.tools.checkstyle
Class CheckStyleTask
java.lang.Object
|
+--org.apache.tools.ant.ProjectComponent
|
+--org.apache.tools.ant.Task
|
+--com.puppycrawl.tools.checkstyle.CheckStyleTask
- public class CheckStyleTask
- extends org.apache.tools.ant.Task
An implementation of a ANT task for calling checkstyle. See the documentation
of the task for usage.
- Author:
- Oliver Burn
Fields inherited from class org.apache.tools.ant.Task |
description, location, target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
project |
Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
getProject, setProject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CheckStyleTask
public CheckStyleTask()
setFailureProperty
public void setFailureProperty(java.lang.String aPropertyName)
- Tells this task to set the named property to "true" when there
is a violation.
- Parameters:
aPropertyName
- the name of the property to set
in the event of an failure.
setFailOnViolation
public void setFailOnViolation(boolean aFail)
- Parameters:
aFail
- whether to fail if a violation is found
addFileset
public void addFileset(org.apache.tools.ant.types.FileSet aFS)
- Adds a set of files (nested fileset attribute).
- Parameters:
aFS
- the file set to add
addFormatter
public void addFormatter(CheckStyleTask.Formatter aFormatter)
- Add a formatter
- Parameters:
aFormatter
- the formatter to add for logging.
setClasspath
public void setClasspath(org.apache.tools.ant.types.Path aClasspath)
- Set the class path.
- Parameters:
aClasspath
- the path to locate classes
createClasspath
public org.apache.tools.ant.types.Path createClasspath()
- Returns:
- a created path for locating classes
setFile
public void setFile(java.io.File aFile)
- Parameters:
aFile
- the file to be checked
setProperties
public void setProperties(java.io.File aProps)
- Sets a properties file for use instead
of individually setting them.
- Parameters:
aProps
- the properties File to use
setAllowTabs
public void setAllowTabs(boolean aAllowed)
- Parameters:
aAllowed
- whether tabs are allowed
setTabWidth
public void setTabWidth(int aTabWidth)
- Parameters:
aTabWidth
- number of spaces that are represented by one tab
setAllowProtected
public void setAllowProtected(boolean aAllowed)
- Parameters:
aAllowed
- whether protected data is allowed
setAllowPackage
public void setAllowPackage(boolean aAllowed)
- Parameters:
aAllowed
- whether package visible data is allowed
setAllowNoAuthor
public void setAllowNoAuthor(boolean aAllowed)
- Parameters:
aAllowed
- whether allow having no author
setMaxLineLen
public void setMaxLineLen(int aLen)
- Parameters:
aLen
- max allowed line length
setMaxMethodLen
public void setMaxMethodLen(int aLen)
- Parameters:
aLen
- max allowed method length
setMaxConstructorLen
public void setMaxConstructorLen(int aLen)
- Parameters:
aLen
- max allowed constructor length
setMaxFileLen
public void setMaxFileLen(int aLen)
- Parameters:
aLen
- max allowed file length
setIgnoreLineLengthPattern
public void setIgnoreLineLengthPattern(java.lang.String aPat)
- Parameters:
aPat
- line length check exclusion pattern
setIgnoreImportLen
public void setIgnoreImportLen(boolean aIgnore)
- Parameters:
aIgnore
- whether max line length should be ignored for
import statements
setMemberPattern
public void setMemberPattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for member variables
setPublicMemberPattern
public void setPublicMemberPattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for public member variables
setTodoPattern
public void setTodoPattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for todo lines
setParamPattern
public void setParamPattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for parameters
setConstPattern
public void setConstPattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for constant variables
setStaticPattern
public void setStaticPattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for static variables
setTypePattern
public void setTypePattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for type names
setLocalVarPattern
public void setLocalVarPattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for local variables
setMethodPattern
public void setMethodPattern(java.lang.String aPat)
- Parameters:
aPat
- pattern for method names
setHeaderFile
public void setHeaderFile(java.io.File aName)
- Parameters:
aName
- header file name
setHeaderLinesRegexp
public void setHeaderLinesRegexp(boolean aIsRegexp)
- Parameters:
aIsRegexp
- whether to interpret header lines as regexp
setHeaderIgnoreLine
public void setHeaderIgnoreLine(java.lang.String aList)
- Parameters:
aList
- Comma separated list of line numbers
setJavadocScope
public void setJavadocScope(java.lang.String aJavadocScope)
- Parameters:
aJavadocScope
- visibility scope where Javadoc is checked
setRequirePackageHtml
public void setRequirePackageHtml(boolean aRequirePackageHtml)
- Parameters:
aRequirePackageHtml
- whether package.html is required
setIgnoreImports
public void setIgnoreImports(boolean aIgnore)
- Parameters:
aIgnore
- whether to ignore import statements
setIllegalImports
public void setIllegalImports(java.lang.String aPkgPrefixList)
- Parameters:
aPkgPrefixList
- comma separated list of package prefixes
setIllegalInstantiations
public void setIllegalInstantiations(java.lang.String aClassList)
- Parameters:
aClassList
- comma separated list of fully qualified class names
setIgnoreWhitespace
public void setIgnoreWhitespace(boolean aIgnore)
- Parameters:
aIgnore
- whether to ignore whitespace
setIgnoreCastWhitespace
public void setIgnoreCastWhitespace(boolean aIgnore)
- Parameters:
aIgnore
- whether to ignore whitespace after casts
setIgnoreBraces
public void setIgnoreBraces(boolean aIgnore)
- Parameters:
aIgnore
- whether to ignore braces
setIgnoreLongEll
public void setIgnoreLongEll(boolean aIgnore)
- Parameters:
aIgnore
- whether to ignore long 'L'
setIgnorePublicInInterface
public void setIgnorePublicInInterface(boolean aIgnore)
- Parameters:
aIgnore
- whether to ignore 'public' in interfaces
setCheckUnusedThrows
public void setCheckUnusedThrows(boolean aEnable)
- Parameters:
aEnable
- whether to check if unused @throws are a
RuntimeException
setBasedir
public void setBasedir(java.io.File aBasedir)
- Parameters:
aBasedir
- set the base directory
setCacheFile
public void setCacheFile(java.io.File aCacheFile)
- Parameters:
aCacheFile
- the file to cache which files have been checked
setLCurlyMethod
public void setLCurlyMethod(java.lang.String aTo)
- Parameters:
aTo
- the left curly placement option for methods
setLCurlyType
public void setLCurlyType(java.lang.String aTo)
- Parameters:
aTo
- the left curly placement option for types
setLCurlyOther
public void setLCurlyOther(java.lang.String aTo)
- Parameters:
aTo
- the left curly placement option for others
setRCurly
public void setRCurly(java.lang.String aTo)
- Parameters:
aTo
- the right curly placement option
setTryBlock
public void setTryBlock(java.lang.String aTo)
- Parameters:
aTo
- the try block option
setCatchBlock
public void setCatchBlock(java.lang.String aTo)
- Parameters:
aTo
- the catch block option
setFinallyBlock
public void setFinallyBlock(java.lang.String aTo)
- Parameters:
aTo
- the finally block option
setParenPad
public void setParenPad(java.lang.String aTo)
- Parameters:
aTo
- the parenthesis padding option
setWrapOp
public void setWrapOp(java.lang.String aTo)
- Parameters:
aTo
- the operator wrapping option
execute
public void execute()
throws org.apache.tools.ant.BuildException
- Actually checks the files specified. All errors are reported to
System.out. Will fail if any errors occurred.
- Overrides:
execute
in class org.apache.tools.ant.Task
- Throws:
org.apache.tools.ant.BuildException
- an error occurred
getListeners
protected AuditListener[] getListeners()
throws java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.io.IOException
- Return the list of listeners set in this task.
- Returns:
- the list of listeners.
- Throws:
java.lang.ClassNotFoundException
- if an error occursjava.lang.InstantiationException
- if an error occursjava.lang.IllegalAccessException
- if an error occursjava.io.IOException
- if an error occurs
scanFileSets
protected java.lang.String[] scanFileSets()
- returns the list of files (full path name) to process.
- Returns:
- the list of files included via the filesets.