Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
com.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.Check
com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck
public class UnnecessaryParenthesesCheck
extends Check
return (x); // parens around identifier return (x + 1); // parens around return value int x = (y / 2 + 1); // parens around assignment rhs for (int i = (0); i < 10; i++) { // parens around literal t -= (z + 1); // parens around assignment rhsThe check is not "type aware", that is to say, it can't tell if parentheses are unnecessary based on the types in an expression. It also doesn't know about operator precedence and associatvity; therefore it won't catch something like
int x = (a + b) + c;In the above case, given that a, b, and c are all
int
variables, the parentheses around a + b
are not needed.
Method Summary | |
int[] | |
void |
|
void |
|
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check | |
beginTree , destroy , finishTree , getAcceptableTokens , getClassLoader , getDefaultTokens , getFileContents , getLines , getRequiredTokens , getTabWidth , getTokenNames , init , leaveToken , log , log , setClassLoader , setFileContents , setMessages , setTabWidth , setTokens , visitToken |
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter | |
getMessageBundle , getSeverity , getSeverityLevel , log , log , 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 |
public int[] getDefaultTokens()
- Overrides:
- getDefaultTokens in interface Check
- See Also:
Check
public void leaveToken(DetailAST aAST)
- Overrides:
- leaveToken in interface Check
- See Also:
Check
Back to the Checkstyle Home Page |