Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using checkstyle/google_checks.xml with maven-checkstyle-plugin

I am trying to use checkstyles google_checks.xml with maven-checkstyle-plugin. If I use the google_checks.xml with the latest checkstyle intelliJ plugin everything is correct but when I try configurating it via maven-checkstyle plugin I get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (default-cli) on project XX_XX_XX: Failed during checkstyle configuration: cannot initialize module TreeWalker - Unable to instantiate AvoidEscapedUnicodeCharacters:
Unable to instantiate AvoidEscapedUnicodeCharactersCheck 

My pom.xml looks like this:

   <project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
    [...]
    <checkstyle.file.path>develop/checkstyle/google_checks.xml</checkstyle.file.path>
</properties>
[...]
<build>
    <plugins>
        [...]
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.13</version>
            <configuration>
                <configLocation>${checkstyle.file.path}</configLocation>
                <failOnViolation>false</failOnViolation>
            </configuration>
        </plugin>
    </plugins>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.9.1</version>
            <configuration>
                <configLocation>${checkstyle.file.path}</configLocation>
                <failOnViolation>false</failOnViolation>
            </configuration>
        </plugin>
    </plugins>
</reporting>

Do you guys have some suggestions about what could be wrong?

like image 285
ccDict Avatar asked Dec 07 '14 17:12

ccDict


People also ask

How do I fix Maven Checkstyle errors in IntelliJ?

You can configure your Checkstyle rules in the Idea's Code Style config (File -> Settings -> Code Style) and then reformat the code (Code -> Reformat Code [Ctrl+Alt+L]) according to the rules (you can apply it to the whole code base at once). Save this answer. Show activity on this post. reformat your code.


2 Answers

fixed this by updating the checkstyle-dependency manually to the latest stable version:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.13</version>
            <dependencies>
                <dependency>
                    <groupId>com.puppycrawl.tools</groupId>
                    <artifactId>checkstyle</artifactId>
                    <version>${checkstyle.latest.version}</version>
                </dependency>
            </dependencies>
            <configuration>
                <configLocation>${checkstyle.file.path}</configLocation>
                <failOnViolation>false</failOnViolation>
            </configuration>
        </plugin>
like image 95
ccDict Avatar answered Oct 18 '22 04:10

ccDict


Maven checkstyle plugin uses checkstyle 5.7 (the first line of plugin description).

Checkstyle 5.7 does not have this check (see checks package on grepcode).

You need either to disable this check or to wait for official fix of MCHECKSTYLE-261.

like image 21
ursa Avatar answered Oct 18 '22 03:10

ursa