New way To Configure a RuleSet for Static Groovy Code analysis using CodeNarc plugin

08 / Mar / 2011 by Ankur Tripathi 2 comments

The CodeNarc plugin provides static code analysis using CodeNarc library. CodeNarc analyzes Groovy code for defects, bad practices, inconsistencies, style issues etc. CodeNarc provides a Groovy DSL for defining RuleSets.

Install CodeNarc plugin into you grails project. Now create one groovy file say CustomRules.groovy and add following code into it.

[java]

ruleset {
Println
SystemOutPrint //these are the rules from CodeNarc library
}

[/java]

The above configuration will look for Println and SystemOutPrint (Logging Rules) rule violation in your project. see all rules.

Now add location of this file in Config.properties
[java]
codenarc.ruleSetFiles="file:grails-app/conf/CustomRules.groovy"
[/java]
and you are done with configuring custom rule, Now you can run codenarc for configured rule.

Hope this helps
Ankur
ankur@intelligrape.com

FOUND THIS USEFUL? SHARE IT

comments (2)

  1. www.calabriatechnology.com

    I appreciate you sharing this blog article.Really looking forward to read more. Really Great.

    Reply

Leave a Reply to www.calabriatechnology.com Cancel reply

Your email address will not be published. Required fields are marked *