Checkstyle

{{Short description|Java code analysis tool}}

{{multiple issues|{{Primary sources|date=July 2010}}

{{update|date=August 2015}}}}

{{Infobox software

| name = Checkstyle

| logo = Checkstyle Logo.png

| screenshot =

| caption =

| developer =

| latest release version = 10.23.0

| latest release date = {{Start date and age|2025|04|02}}

| latest preview version =

| latest preview date =

| repo = {{URL|https://github.com/checkstyle/checkstyle}}

| operating system = Cross-platform

| language =

| programming language = Java

| genre = Static code analysis

| license = GNU Lesser General Public License

| website = {{ConditionalURL}}

}}

Checkstyle{{cite web | url = https://checkstyle.org/ | title = Checkstyle Home Page | year = 2010 | access-date = 2010-11-02}} is a static code analysis tool used in software development for checking if Java source code is compliant with specified coding rules.

Originally developed by Oliver Burn back in 2001, the project is maintained by a team of developers from around the world.

The current stable release is version 10.23.0{{Cite web |title=checkstyle – Release Notes |url=https://checkstyle.sourceforge.io/releasenotes.html#Release_10.23.0 |access-date=2024-12-17 |website=checkstyle.sourceforge.io}} which supports Java versions from 11 to 17.{{Cite web |title=checkstyle – Checkstyle Home Page |url=https://checkstyle.sourceforge.io/#JRE_and_JDK |access-date=2024-12-17 |website=checkstyle.sourceforge.io}}

Advantages and limits

The programming style adopted by a software development project can help to ensure that the code is compliant with good programming practices which improve the quality, readability, and re-usability of the code and may reduce the cost of development. The checks performed by Checkstyle are mainly limited to the presentation of the code. These checks do not confirm the correctness or completeness of the code. Checkstyle rules are not programming style, they are merely rules for formatting the code.

Examples of available modules

Checkstyle defines a set of available modules, each of which provides rules checking with a configurable level of strictness (mandatory, optional...). Each rule can raise notifications, warnings, and errors. For example, Checkstyle can examine the following:

  • Javadoc comments for classes, attributes and methods;
  • Naming conventions of attributes and methods;
  • The number of function parameters;
  • Line lengths;
  • The presence of mandatory headers;
  • The use of imports, and scope modifiers;
  • The spaces between some characters;
  • The practices of class construction;
  • Multiple complexity measurements.

Usage

Checkstyle is available as a JAR file which can run inside a Java VM or as an Apache Ant task. It can also be integrated into an IDE or other tools.

See also

{{Portal|Free and open-source software}}

  • List of tools for static code analysis
  • [https://checkstyle.org/eclipse-cs/ EclipseCS] - Eclipse plugin for checkstyle.
  • [https://github.com/jshiell/checkstyle-idea Checkstyle-IDEA] - Checkstyle plugin for IntelliJ IDEA and Android Studio
  • [https://sevntu-checkstyle.github.com/sevntu.checkstyle/ SevNTU-Checkstyle] {{Webarchive|url=https://web.archive.org/web/20130322001444/http://sevntu-checkstyle.github.com/sevntu.checkstyle/ |date=2013-03-22 }} - extension for EclipseCS with number of check that are not part of checkstyle upstream.
  • [https://checkstyle-addons.thomasjensen.com/ Checkstyle Addons] - Additional Checkstyle checks
  • [https://github.com/PHPCheckstyle/phpcheckstyle Checkstyle for PHP] - a PHP version of Checkstyle

References

{{Reflist}}