Checkstyle升级后如何验证自定义配置xml

Car*_*eon 4 java checkstyle maven maven-checkstyle-plugin

我已将 maven-checkstyle-plugin 从 2.17 升级到 3.1.1,在运行 mvn checkstyle:checkstyle 时,我遇到了许多运行时错误,例如(最困难的部分是错误一次显示 1 - 这意味着您修复了第一个错误,然后第二个错误显示...):

 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
Run Code Online (Sandbox Code Playgroud)

这是因为升级到最新插件版本后,版本从 6.* 升级到了 8.*。

我试图找到一些验证器来告诉我 XML 不再有效,但我找不到任何验证器,有这样的工具吗?

str*_*rkk 7

您需要修改您的 xml 配置。这是由于一些破坏性的兼容性更改造成的。

  1. SuppressionCommentFilter 在 8.1 版本之后应该是 TreeWalker 的子级https://checkstyle.org/releasenotes.html#Release_8.1
  2. 8.24 版本之后,LineLength 应该是 Checker 的子项https://checkstyle.org/releasenotes.html#Release_8.24
  3. 8.2 版本后,应从配置中删除 FileContentsHolder,有关详细信息,请参阅https://github.com/checkstyle/checkstyle/issues/3573#issue-191385595