简体   繁体   English

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

[英]How to create customized ruleset using the codenarc plugin?

I am currently using the codenarc plugin , and I wanted to customize the codenarc ruleset property for it to check the proper indentation of my codes.我目前正在使用codenarc plugin ,我想为它自定义 codenarc 规则集属性以检查我的代码是否正确缩进。

Have anyone tried this?有没有人试过这个?

Please help.请帮忙。

Thanks!谢谢!

CodeNarc does not (currently) include any rules for checking/enforcing code indentation. CodeNarc 不(当前)包含任何检查/强制代码缩进的规则。 Though you are welcome to contribute one!虽然欢迎你贡献一份!

You can see a list of all rules at: http://codenarc.sourceforge.net/codenarc-rule-index.html您可以在以下位置查看所有规则的列表: http : //codenarc.sourceforge.net/codenarc-rule-index.html

The formatting rules are described at: http://codenarc.sourceforge.net/codenarc-rules-formatting.html格式规则在以下位置描述: http : //codenarc.sourceforge.net/codenarc-rules-formatting.html

Chris克里斯

Use the Indentation rule.使用Indentation规则。 This is included in rulesets/formatting.xml .这包含在rulesets/formatting.xml This will check the indentation (spaces only; not tabs) for class, field and method declarations, and statements.这将检查类、字段和方法声明以及语句的缩进(仅限空格;不是制表符)。 The default is 4 spaces per indentation level, This is configurable via the spacesPerIndentLevel property.默认为每个缩进级别 4 个空格,这可以通过spacesPerIndentLevel属性进行配置。 See this page for details.有关详细信息,请参阅此页面

With the rule enabled violations are reported like this, in the default HTML report: Example report showing violations of the 'Indentation' rule .在启用规则的情况下,在默认 HTML 报告中报告的违规情况如下:示例报告显示违反“缩进”规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM