com.puppycrawl.tools.checkstyle.checks

Class GenericIllegalRegexpCheck

public class GenericIllegalRegexpCheck extends AbstractFormatCheck

A generic check for code problems, the user can search for any pattern. This is similar to a recursive grep, only that it's integrated in checkstyle.

Rationale: This Check can be used to prototype checks and to find common bad pratice such as calling ex.printStacktrace(), System.out.println(), System.exit(), etc.

An example of how to configure the check for calls to System.out.println is:

 <module name="GenericIllegalRegexp">
    <property name="format" value="System\.out\.println"/>
 </module>
 

Author: lkuehne Bill Schneider Daniel Grenner

Constructor Summary
GenericIllegalRegexpCheck()
Instantiates an new GenericIllegalRegexpCheck.
Method Summary
voidbeginTree(DetailAST aRootAST)
{@inheritDoc}
int[]getDefaultTokens()
{@inheritDoc}
StringgetMessage()
Getter for message property.
PatterngetRegexp()
voidsetIgnoreCase(boolean aCaseInsensitive)
Set whether or not the match is case sensitive.
voidsetIgnoreComments(boolean aIgnoreComments)
Sets if comments should be ignored.
voidsetMessage(String aMessage)
Setter for message property.

Constructor Detail

GenericIllegalRegexpCheck

public GenericIllegalRegexpCheck()
Instantiates an new GenericIllegalRegexpCheck.

Method Detail

beginTree

public void beginTree(DetailAST aRootAST)
{@inheritDoc}

getDefaultTokens

public int[] getDefaultTokens()
{@inheritDoc}

getMessage

public String getMessage()
Getter for message property.

Returns: custom message which should be used to report about violations.

getRegexp

public Pattern getRegexp()

Returns: the regexp to match against

setIgnoreCase

public void setIgnoreCase(boolean aCaseInsensitive)
Set whether or not the match is case sensitive.

Parameters: aCaseInsensitive true if the match is case insensitive.

setIgnoreComments

public void setIgnoreComments(boolean aIgnoreComments)
Sets if comments should be ignored.

Parameters: aIgnoreComments True if comments should be ignored.

setMessage

public void setMessage(String aMessage)
Setter for message property.

Parameters: aMessage custom message which should be used to report about violations.