如何仅针对特定规则抑制代码块内的检查样式检查?
可能的重复:
如何禁用特定的检查样式特定代码行的规则?
在关闭代码段的 Checkstyle 时,是否有一种语法可以仅抑制特定的检查。
所以不仅仅是
// CHECKSTYLE:OFF
代码
// CHECKSTYLE:ON
你可以有类似的东西
// CHECKSTYLE:OFF:RequireThis,
代码
// CHECKSTYLE:ON
如果我们故意对样式进行例外处理,最好更清楚例外情况是什么。
Possible Duplicate:
How to disable a particular checkstyle rule for a particular line of code?
In turning off Checkstyle for a segment of code, is there a syntax that would suppress only specific checks.
So rather than just
// CHECKSTYLE:OFF
code
// CHECKSTYLE:ON
you could have something like
// CHECKSTYLE:OFF:RequireThis,
code
// CHECKSTYLE:ON
In cases where we are purposely making an exception to the style, it would be nice to be clearer what the exception case is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
建议阅读 SuppressionCommentFilter 上的文档(它被隐藏在位)以获取大量示例。
如何配置过滤器的示例如下:
然后,您可以使用以下命令关闭代码块的 RequireThis 检查:
Recommend reading the documentation on SuppressionCommentFilter (it is buried at bit) for lots of examples.
An example of how to do configure the filter is:
You can then use the following to turn off the RequireThis check for a block of code: