在我们的项目中,我们最近定义了检查样式。因此,如果提交代码时出现任何检查样式失败,则不允许在存储库中提交代码。但是代码中已经存在一些错误(在定义检查样式之前),我们不想纠正这些错误。
是否有任何选项使 checkstyle 仅在特定日期之后所做的更改上运行。如果可能的话,请提出建议。
In our project we have defined checkstyles recently. So, if there is any checkstyle failure while committig code then it is not allowing to commit the code in repository. But there are failures already present in the code(which are before defining checkstyles) and we dont want to correct those failures.
Is there any option that checkstyle will run only on the changes made after a particular date. Kindly, suggest if possible.
发布评论
评论(1)
在这种情况下,我推荐的是一个简单的计划:
要收集现有的 Checkstyle 违规,请运行 Checkstyle 并使用 XMLLogger 格式化程序。要了解如何使用 ANT 执行此操作,请参阅此处。
将错误转换为抑制 XML 文档,并尽可能具体地说明每个错误的位置错误被抑制。这样做的优点是,如果有人修改了文件,他们就被迫修复现有的错误。 注意:有些人在如何修改文件以避免修复 Checkstyle 错误方面非常有创意! :-)
最后,修改 Checkstyle 规则集以使用 SuppressionFilter。正确设置后,运行 Checkstyle 不应再报告任何违规行为 - 新的违规行为除外!
What I recommend in this situation is a simple plan of:
To collect the existing Checkstyle violations, run Checkstyle and report on the existing errors using the XMLLogger formatter. To see how to do this with ANT, see here.
Convert the errors into a Suppressions XML Document and be a specific as possible on the location of each error being suppressed. This has the advantage that if somebody modifies a file, they are forced to fix existing errors. Note: some people then get very creative on how they modify files to avoid having to fix Checkstyle errors! :-)
Finally, modify the Checkstyle rule set to use the SuppressionFilter. When setup correctly, running Checkstyle should no longer report any violations - except for new ones!