问题描述
我已经将maven-checkstyle-plugin从2.17升级到3.1.1,并且在运行mvn checkstyle:checkstyle时遇到了许多运行时错误,例如(最困难的部分是错误一次显示1-这意味着您修复第一个错误,然后显示第二个错误...):
public class UserResponse {
private User data;
// the variable is named data because it should be the same to the json key and the type of the variable is class `User`. Remember about the bolded text
// (variable named same is not a must,if different,you can use `Serializedname` annotation,you can read about it later)
// the setter getter here
}
这是因为在升级到最新插件版本时,版本已从6. *升级到8。*。
我试图找到一些验证器来告诉我XML不再有效,但是我找不到任何验证器,有没有这样的工具?
解决方法
您需要修改xml配置。 这是由于一些重大的兼容性更改。
- SuppressionCommentFilter应该是8.1版本https://checkstyle.org/releasenotes.html#Release_8.1之后的TreeWalker的子级
- LineLength应该是8.24版本https://checkstyle.org/releasenotes.html#Release_8.24之后的Checker的子级
- FileContentsHolder应该在8.2发布后从配置中删除,有关详细信息,请参见https://github.com/checkstyle/checkstyle/issues/3573#issue-191385595。