|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.Check
com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck
com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck
The check to ensure that requires that comments be the only thing on a line.
For the case of // comments that means that the only thing that should
precede it is whitespace.
It doesn't check comments if they do not end line, i.e. it accept
the following:
Thread.sleep( 10 <some comment here> );
Format property is intended to deal with the "} // while" example.
Rationale: Steve McConnel in "Code Complete" suggests that endline comments are a bad practice. An end line comment would be one that is on the same line as actual code. For example:
a = b + c; // Some insightful comment d = e / f; // Another comment for this lineQuoting "Code Complete" for the justfication:
To configure the check so it enforces only comment on a line:
<module name="TrailingComment">
<property name="format" value="^\\s*$"/>
</module>
| Constructor Summary | |
TrailingCommentCheck()
Creates new instance of the check. |
|
| Method Summary | |
void |
beginTree(DetailAST aRootAST)
Called before the starting to process a tree. Ideal place to initialise information that is to be collected whilst processing a tree. |
int[] |
getDefaultTokens()
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens. |
void |
visitToken(DetailAST aAST)
Called to process a token. |
| Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck |
getFormat, getRegexp, setFormat |
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check |
destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens |
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter |
getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, setSeverity |
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean |
configure, contextualize, finishLocalSetup, getConfiguration, setupChild |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TrailingCommentCheck()
throws org.apache.commons.beanutils.ConversionException
org.apache.commons.beanutils.ConversionException - unable to parse DEFAULT_FORMAT.| Method Detail |
public int[] getDefaultTokens()
getDefaultTokens in class CheckTokenTypespublic void visitToken(DetailAST aAST)
visitToken in class CheckaAST - the token to processpublic void beginTree(DetailAST aRootAST)
beginTree in class CheckaRootAST - the root of the tree
|
Back to the Checkstyle Home Page | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||