【问题标题】:How to create customized ruleset using the codenarc plugin?如何使用 codenarc 插件创建自定义规则集?
【发布时间】:2012-05-16 02:54:21
【问题描述】:

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

有人试过吗?

请帮忙。

谢谢!

【问题讨论】:

    标签: grails groovy codenarc


    【解决方案1】:

    CodeNarc(当前)不包括任何检查/强制代码缩进的规则。虽然欢迎您贡献一份!

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

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

    克里斯

    【讨论】:

      【解决方案2】:

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

      启用规则后,默认 HTML 报告中的违规行为报告如下: Example report showing violations of the 'Indentation' rule.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-01-29
        • 1970-01-01
        • 2017-11-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-28
        相关资源
        最近更新 更多