com.puppycrawl.tools.checkstyle.checks.design
public final class MutableExceptionCheck extends AbstractFormatCheck
Ensures that exceptions (defined as any class name conforming to some regular expression) are immutable. That is, have only final fields.
Rationale: Exception instances should represent an error condition. Having non final fields not only allows the state to be modified by accident and therefore mask the original condition but also allows developers to accidentally forget to initialise state thereby leading to code catching the exception to draw incorrect conclusions based on the state.
Constructor Summary | |
---|---|
MutableExceptionCheck() Creates new instance of the check. |
Method Summary | |
---|---|
int[] | getDefaultTokens() {@inheritDoc} |
int[] | getRequiredTokens() {@inheritDoc} |
void | leaveToken(DetailAST aAST) {@inheritDoc} |
void | visitToken(DetailAST aAST) {@inheritDoc} |