在升级Checkstyle后,如何验证自定义配置XML。

huangapple go评论67阅读模式
英文:

After Checkstyle upgrade how to validate custom config xml

问题

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

 1. 在 checkstyle 配置期间失败:无法初始化 TreeWalker 模块 - 无法实例化 'FileContentsHolder' 类,
 2. 无法初始化 TreeWalker 模块 - TreeWalker 不能作为 LineLength 的父级,请在 Web 文档中的 'Parent Module' 部分查看此检查的内容是否标准。
 3. SuppressionCommentFilter 不能作为 Checker 的子级。

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

我尝试找到一些验证器,告诉我 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?

答案1

得分: 7

你需要修改你的 XML 配置。
这是因为有几个破坏性的兼容性更改。

  1. 在 8.1 版本发布之后,SuppressionCommentFilter 应该是 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
英文:

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.

huangapple
  • 本文由 发表于 2020年10月9日 14:08:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/64274743.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定