Checkstyle xml



Keywords: checkstyle xml
Description: A Checkstyle configuration specifies which modules to plug in and apply to Java source files. Modules are structured in a tree whose root is the Checker module. The next level of modules

A Checkstyle configuration specifies which modules to plug in and apply to Java source files. Modules are structured in a tree whose root is the Checker module. The next level of modules contains:

  • FileSetChecks - modules that take a set of input files and fire error messages.
  • Filters - modules that filter audit events, including error messages, for acceptance.
  • AuditListeners - modules that report accepted events.

Many checks are submodules of the TreeWalker FileSetCheck module. The TreeWalker operates by separately transforming each of the Java source files into an abstract syntax tree and then handing the result over to each of its submodules which in turn have a look at certain aspects of the tree.

Checkstyle obtains a configuration from an XML document whose elements specify the configuration's hierarchy of modules and their properties. You provide a file that contains the configuration document when you invoke Checkstyle at the command line. and when you run a Checkstyle task in ant. The documentation directory of the Checkstyle distribution contains a sample configuration file sun_checks.xml which configures Checkstyle to check for the Sun coding conventions.

A module element in the configuration XML document specifies a module identified by the element's name attribute.

  • Root module Checker has child FileSetChecks JavadocPackage and TreeWalker. (Module JavadocPackage checks that all packages have package documentation.)
  • Module TreeWalker has submodules AvoidStarImport. ConstantName. and EmptyBlock. (Modules AvoidStarImport . ConstantName . and EmptyBlock check that a Java source file has no star imports, has valid constant names, and has no empty blocks, respectively.)

For each configuration module, Checkstyle loads a class identified by the name attribute of the module. There are several rules for loading a module's class:

  1. Load a class directly according to a package-qualified name. such as loading class com.puppycrawl.tools.checkstyle.TreeWalker for element:
This is useful for plugging third-party modules into a configuration.
  • Load a class of a pre-specified package, such as loading class com.puppycrawl.tools.checkstyle.checks.AvoidStarImport for element Checkstyle applies packages com.puppycrawl.tools.checkstyle. com.puppycrawl.tools.checkstyle.filters. and com.puppycrawl.tools.checkstyle.checks and its sub-packages (only those included in the Checkstyle distribution). You can specify other packages in a package names XML document when you invoke Checkstyle at the command line. and when you run a Checkstyle task in ant.
  • Apply the above rules to name concatenated with "Check". such as loading class com.puppycrawl.tools.checkstyle.checks.ConstantNameCheck for element

    Properties of a module control how the module performs its task. Each module property has a default value, and you are not required to define a property in the configuration document if the default value is satisfactory. To assign a non-default value to a module's property, define a child property element of the module element in the configuration XML document. Also provide appropriate name and value attributes for the property element. For example, property max of module MethodLength specifies the maximum allowable number of lines in a method or constructor, and has default value 150. Here is a configuration of module MethodLength so that the check reports methods and constructors with more than 60 lines:

    Command line properties and ant Checkstyle task properties apply to the root Checker module. Also, properties are inherited in the module hierarchy. These features make it easy to define one property value that applies to many modules. For example, the following configuration fragment specifies that a tabWidth of 4 applies to TreeWalker and its submodules:

    The value of a module property can be specified through property expansion with the $<property_name > notation, where property_name is a command line property or an ant Checkstyle task property. For example, the following configuration document element gives property headerFile the value of command line property checkstyle.header.file.

    You can use property expansion to re-specify a module property value without changing the configuration document.

    The property element provides an optional default attribute which is used when a property in the value cannot be resolved. For example this configuration snippet from a central configuration file checks that methods have javadoc, but allows individual projects to override the severity by specifying their desired value in the command line property checkstyle.javadoc.severity.

    This feature is a great help when setting up a centralized configuration file (e.g. one file for the whole company) to lower configuration maintenance costs. Projects that are happy with the default can simply use that configuration file as is, but individual projects with special needs have the flexibility to adjust a few settings to fit their needs without having to copy and maintain the whole configuration.






    Photogallery Checkstyle xml:


    Posts | Mark Story


    Eclipse Checkstyle Plugin


    Using the Checkstyle Eclipse plug-in - Tutorial


    SCM-Manager Plugins Part 6: Checkstyle | SCM-Manager Universe


    How do I generate a Checkstyle code style report for a site? - Web ...


    checkstyle  Writing Checks


    kakakikikeke????: Maven ?????? CheckStyle ?????


    Eclipse Checkstyle Plugin


    Using the Checkstyle Eclipse plug-in - Tutorial


    windows-preferences-pmd.png


    How do I generate a Checkstyle code style report for a site? - Web ...


    QAPlug  quality assurance plugin  Tutorials


    Chapter 4. Coding Standards


    Actioncenters project - Developer Workstation Setup


    Plugin de Eclipse para chequear el estilos del cdigo | luauf.com


    ConfiguringCheckstyleForEclipse - instinct - This page describes ...


    Getting Started: IntelliJ Setup  mongodb/mongo-java-driver Wiki ...


    ConfiguringCheckstyleForEclipse - instinct - This page describes ...