如何使用codenarc插件创建自定义规则集?

时间:2012-05-16 02:54:21

标签: grails groovy codenarc

我目前正在使用codenarc plugin,我想为它自定义codenarc规则集属性,以检查代码的正确缩进。

有没有人试过这个?

请帮忙。

谢谢!

2 个答案:

答案 0 :(得分:0)

CodeNarc(目前)不包含任何检查/执行代码缩进的规则。虽然欢迎你贡献一个!

您可以在以下位置查看所有规则的列表: http://codenarc.sourceforge.net/codenarc-rule-index.html

格式规则描述于: http://codenarc.sourceforge.net/codenarc-rules-formatting.html

克里斯

答案 1 :(得分:0)

使用Indentation规则。这包括在rulesets/formatting.xml中。这将检查类,字段和方法的声明以及语句的缩进(仅空格;不是制表符)。默认情况下,每个缩进级别为4个空格。可以通过spacesPerIndentLevel属性进行配置。有关详细信息,请参见this page

在启用规则的情况下,在默认的HTML报告中,将这样报告违规情况: Example report showing violations of the 'Indentation' rule

相关问题