Automate Java code style checks against team rules
You can stop manually checking hundreds of lines of Java code against style guides. Checkstyle is a program that mechanically verifies whether code follows standards like the Google Java Style Guide or Sun Code Conventions. Run it during the build process or from the command line to get immediate feedback on violations, ensuring consistent quality from the moment you write code.
Checks for logical errors like switch statements
Checkstyle does not just check formatting like indentation or variable names. As shown in the README examples, it also detects 'fall through' errors where a specific case in a switch statement proceeds to the next case. You define the rules to check in a config.xml file and run it with the java -jar command to print the violated lines and reasons to the console. This process can be invoked via ANT tasks or command-line programs, making it easy to integrate into existing development workflows.
Google Style Guide as the default
When you first install the tool, the Google Java Style Guide and Sun Code Conventions are applied as default settings. However, you do not need to follow every rule exactly. You can freely adjust the configuration to select only the rules that fit your project or add new ones. The latest release version is available for download from GitHub releases or Maven Central, and you can find detailed descriptions of each check item in the HTML-formatted documentation.
An open-source project maintained by voluntary contributions
Checkstyle is an open-source project developed and maintained by volunteers. Users can ask questions on the Discussions page or Stack Overflow and communicate with the community through Discord chat rooms or the Google Groups forum. If you want to contribute to the project, refer to the Contribution Guidelines to create issues or submit pull requests. You can also support the project's continued development through Liberapay or OpenCollective.
LGPL license and dependency libraries
Checkstyle is distributed under the GNU LGPL v2.1 license. It internally uses libraries such as ANTLR, Apache Commons, Google Guava, and Picocli. Before integrating this tool into a commercial project, you must verify that these license terms do not conflict with your project. It is also safe to directly verify compatibility with specific Java versions and the scope of supported check items through the latest documentation.