com.puppycrawl.tools.checkstyle.checks.design
Class ThrowsCountCheck
- Configurable, Contextualizable
public final class ThrowsCountCheck
Restricts throws statements to a specified count (default = 1).
Rationale:
Exceptions form part of a methods interface. Declaring
a method to throw too many differently rooted
exceptions makes exception handling onerous and leads
to poor programming practices such as catch
(Exception). This check forces developers to put
exceptions into a heirachy such that in the simplest
case, only one type of exception need be checked for by
a caller but allows any sub-classes to be caught
specifically if necessary.
- Simon Harris
beginTree , destroy , finishTree , getAcceptableTokens , getClassLoader , getDefaultTokens , getFileContents , getLines , getRequiredTokens , getTabWidth , getTokenNames , init , leaveToken , log , log , setClassLoader , setFileContents , setMessages , setTabWidth , setTokens , visitToken |
getMessageBundle , getSeverity , getSeverityLevel , log , log , log , log , log , log , log , log , log , log , log , setSeverity |
ThrowsCountCheck
public ThrowsCountCheck()
Creates new instance of the check.
getDefaultTokens
public int[] getDefaultTokens()
- getDefaultTokens in interface Check
Check
getMax
public int getMax()
Getter for max property.
- maximum allowed throws statements.
getRequiredTokens
public int[] getRequiredTokens()
- getRequiredTokens in interface Check
Check
setMax
public void setMax(int aMax)
Setter for max property.
aMax
- maximum allowed throws statements.