eclipse checkstyle error cannot initialize module TreeWalker - TreeWalker is not allowed as a parent of FileLength

Anand B picture Anand B · Jun 27, 2013 · Viewed 14.6k times · Source

I get the following error when I try to load a user defined check style template.

cannot initialize module TreeWalker - TreeWalker is not allowed as a parent of FileLength

I think it might be due to the incompatibilty with checkstyle version in my eclipse. How will I be able to find the appropriate checkstyle version with checkstyle xml file

Answer

barfuin picture barfuin · Jun 27, 2013

This is an error in the template, independent of the Checkstyle version. FileLength goes directly under Checker, not under TreeWalker.

Example:

<module name="Checker">
    <property name="severity" value="warning"/>
    <module name="TreeWalker">
        <property name="tabWidth" value="4"/>
        <module name="JavadocType"/>
        <!-- many others -->
    </module>
    <module name="NewlineAtEndOfFile"/>
    <module name="FileLength"/>
    <module name="JavadocPackage"/>
    <!-- others -->
</module>