Class ChildBlockLengthCheck
- java.lang.Object
- 
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
- 
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
- 
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
- 
- com.github.sevntu.checkstyle.checks.design.ChildBlockLengthCheck
 
 
 
 
- 
- All Implemented Interfaces:
- com.puppycrawl.tools.checkstyle.api.Configurable,- com.puppycrawl.tools.checkstyle.api.Contextualizable
 
 public class ChildBlockLengthCheck extends com.puppycrawl.tools.checkstyle.api.AbstractCheckThis check detects the child blocks, which length is more then 80% of parent block length.
 Supported keywords are used to detect blocks: 
 "if", "else", "for", "switch", "do", "while", "try", "catch".Rationale: Length of child block that is more then 80% of parent block is usually hard to read in case child block is long(few display screens). Such child blocks should be refactored or moved to separate method. - Since:
- 1.8.0
- Author:
- Daniil Yaroslavtsev
 
- 
- 
Constructor SummaryConstructors Constructor Description ChildBlockLengthCheck()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]getAcceptableTokens()int[]getDefaultTokens()int[]getRequiredTokens()voidsetBlockTypes(String... blockTypes)Sets allowed types of blocks to be checked.voidsetIgnoreBlockLinesCount(int ignoreBlockLinesCount)Sets the maximum linelength of blocks that will be ignored by check.voidsetMaxChildBlockPercentage(int maxChildBlockPercentage)Sets the maximum percentage ratio between child and parent block.voidvisitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)- 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheckbeginTree, clearViolations, destroy, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
 - 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
 
- 
 
- 
- 
- 
Field Detail- 
MSG_KEYpublic static final String MSG_KEY A key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
setBlockTypespublic void setBlockTypes(String... blockTypes) Sets allowed types of blocks to be checked. Supported block types: LITERAL_IF, LITERAL_SWITCH, LITERAL_FOR, LITERAL_DO, LITERAL_WHILE, LITERAL_TRY, LITERAL_ELSE, LITERAL_CATCH.- Parameters:
- blockTypes- - DetailAST tokenTypes that are related to the types which are allowed by user in check preferences.
 
 - 
setMaxChildBlockPercentagepublic void setMaxChildBlockPercentage(int maxChildBlockPercentage) Sets the maximum percentage ratio between child and parent block. (sets "maxChildBlockPercentage" option value)- Parameters:
- maxChildBlockPercentage- the new "maxChildBlockPercentage" option value.
 
 - 
setIgnoreBlockLinesCountpublic void setIgnoreBlockLinesCount(int ignoreBlockLinesCount) Sets the maximum linelength of blocks that will be ignored by check.- Parameters:
- ignoreBlockLinesCount- the maximum linelength of the block to be ignored.
 
 - 
getDefaultTokenspublic int[] getDefaultTokens() - Specified by:
- getDefaultTokensin class- com.puppycrawl.tools.checkstyle.api.AbstractCheck
 
 - 
getAcceptableTokenspublic int[] getAcceptableTokens() - Specified by:
- getAcceptableTokensin class- com.puppycrawl.tools.checkstyle.api.AbstractCheck
 
 - 
getRequiredTokenspublic int[] getRequiredTokens() - Specified by:
- getRequiredTokensin class- com.puppycrawl.tools.checkstyle.api.AbstractCheck
 
 - 
visitTokenpublic void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast) - Overrides:
- visitTokenin class- com.puppycrawl.tools.checkstyle.api.AbstractCheck
 
 
- 
 
-