Checkstyle

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard.

Version

7.7

Runtime

Java Versions

Supported Languages

Java

Official Documentation

http://checkstyle.sourceforge.net/

YAML Configuration

checkstyle:

  • input:

    Patterns to include in execution and reports.

  • ignore:

    Patterns to exclude from execution and reports.

  • auto-fix:

    true/false

  • config-file:

    Alias of -c option.

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.75 CPU with 2880 MiB RAM.

      Inspecode configures the maximum heap size (-Xmx) of the Java virtual machine (JVM) according to this value. Inspecode reserves 240 MiB RAM for system, and makes the rest of RAM available to JVM for heap allocation. For example, -Xmx2640m is specified by default (for 0.75 CPU), -Xmx5520m is specified for 1.5 CPU.

  • options:

    Below is the list of options that are supported:

    -c <arg>   Sets the check configuration file to use.
    -p <arg>   Loads the properties file
  • experimental:

    • incremental:

      true/false

      Note: The incremental analysis is disabled if any kinds of configuration files are changed. The files recognized as configuration files are as follows:

      • Configuration files:
        • Files specified in config-file field
        • Files specified to -c option
        • If none of the above configuration files are found:
          • **/checkstyle.xml
      • Properties files:
        • Files specified to -p option

YAML Examples

  • With default options:

    inspecode:
      checkstyle: default
  • With enabling auto-fixing and default options:

    inspecode:
      checkstyle: auto-fix
  • With custom machine:

    inspecode:
      checkstyle:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
  • With custom options:

    inspecode:
      checkstyle:
        options:
          -p: myCheckstyle.properties
  • With a configuration file:

    inspecode:
      checkstyle:
        config-file: /google_checks.xml

    The above configuration is equivalent to:

    inspecode:
      checkstyle:
        options:
          -c: /google_checks.xml

    /google_checks.xml is a configuration file embedded in Checkstyle, however, you can of course specify your own configuration file if you have.

Configuration File Detection

If no configuration files are specified via config-file or options field, Inspecode walks the file tree in lexical order in your repository to find a configuration file named checkstyle.xml and specifies the file first found to Checkstyle automatically via -c option.

Note: Inspecode ignores specific configuration files while searching. See Configuration > Tool Configuration > Field: config-file for detail.

If the configuration file detected by Inspecode is not the one you want to use or you do not want to use any configuration files, you can disable Inspecode from detecting configuration files by explicitly setting an empty string to config-file field like below:

inspecode:
  checkstyle:
    config-file: ""

If no configuration file can be determined from the YAML configuration and the repository search, Inspecode specifies /sun_checks.xml, which is embedded in Checkstyle itself, to Checkstyle by default since Checkstyle always requires a configuration file via -c option.

results matching ""

    No results matching ""