Carlos Jaime C. De Leon
Carlos Jaime C. De Leon

Reputation: 2906

After Checkstyle upgrade how to validate custom config xml

I have upgraded the maven-checkstyle-plugin from 2.17 to 3.1.1 and when running mvn checkstyle:checkstyle I have encountered numerous runtime errors such as (and the hard part was the errors would show 1 at a time - meaning you fix the 1st error then the 2nd error shows...):

 1. Failed during checkstyle configuration: cannot initialize module TreeWalker - Unable to instantiate 'FileContentsHolder' class,
 2. cannot initialize module TreeWalker - TreeWalker is not allowed as a parent of LineLength Please review 'Parent Module' section for this Check in web documentation if Check is standard.
 3. SuppressionCommentFilter is not allowed as a child in Checker

This is because of the version upgrade from 6.* to 8.* upon upgrading to the latest plugin version.

I tried to find some validator that would tell me that the XML is no longer valid however I cannot find any, is there any such tool?

Upvotes: 4

Views: 2081

Answers (1)

strkk
strkk

Reputation: 669

You need to modify your xml config. This is due to several breaking compatibility changes.

  1. SuppressionCommentFilter should be child of TreeWalker after 8.1 release https://checkstyle.org/releasenotes.html#Release_8.1
  2. LineLength should be child of Checker after 8.24 release https://checkstyle.org/releasenotes.html#Release_8.24
  3. FileContentsHolder should be removed from config after 8.2 release, see https://github.com/checkstyle/checkstyle/issues/3573#issue-191385595 for details.

Upvotes: 11

Related Questions