Skip to content

Add Checkstyle to Project #5

@Anmol202005

Description

@Anmol202005

Implement Checkstyle for consistent code style and quality enforcement.

Add Maven plugin configuration:
Add Checkstyle to the build process so it runs automatically when we build/test the project.

Example:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${maven.checkstyle.plugin.version}</version>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>${checkstyle.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <includeResources>false</includeResources>
              <includeTestResources>false</includeTestResources>
              <includeTestSourceDirectory>true</includeTestSourceDirectory>
              <configLocation>
                https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-${checkstyle.version}/config/checkstyle_checks.xml
              </configLocation>
              <propertiesLocation>config/checkstyle.properties</propertiesLocation>
              <failOnViolation>true</failOnViolation>
              <logViolationsToConsole>true</logViolationsToConsole>
              <maxAllowedViolations>0</maxAllowedViolations>
              <violationSeverity>error</violationSeverity>
              <outputFileFormat>xml</outputFileFormat>
              <outputFile>
                ${project.build.directory}/checkstyle/checkstyle-report.xml
              </outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions