Author: Xiao Pu
CheckStyle is a static analyser for Java. It can be used to assist developers in static analysis process.
CheckStyle will examine code based on different rules(or checks).
According to the checks list provided by CheckStyle, the checks(rules) can be divided into 14 sections.
As described here, there are several limitations in CheckStyle.
CheckStyle uses a configuration file to know all the rules that it is supposed to check.
CheckStyle supports suppressing warnings in four ways:
There are several ways to run CheckStyle.
Command Line:
Build Automation Tools:
IDE Integration:
There are two widely used configurations: Sun Code Conversions and Google Java Style. Some common rules are already included in these configurations.
CheckStyle will use ANTLR to parse your code into a AST(Abstract Syntax Tree) and visit it in a DFS(Depth First Search) pattern to check violations. Thus, it is necessary to make the code compilable in order for the ANTLR to work. You can view the syntax tree using CheckStyle Grammar Tree Viewer