{"id":3212,"date":"2011-03-08T16:11:09","date_gmt":"2011-03-08T10:41:09","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=3212"},"modified":"2011-03-08T16:11:09","modified_gmt":"2011-03-08T10:41:09","slug":"new-way-to-configure-a-ruleset-for-static-groovy-code-analysis-using-codenarc-plugin","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/new-way-to-configure-a-ruleset-for-static-groovy-code-analysis-using-codenarc-plugin\/","title":{"rendered":"New way To Configure a RuleSet for Static Groovy Code analysis using CodeNarc plugin"},"content":{"rendered":"<p>The <a href=\"http:\/\/www.grails.org\/plugin\/codenarc\">CodeNarc plugin<\/a> provides static code analysis using <a href=\"http:\/\/codenarc.sourceforge.net\/index.html\">CodeNarc<\/a> library. CodeNarc analyzes Groovy code for defects, bad practices, inconsistencies, style issues etc. CodeNarc provides a Groovy DSL for defining RuleSets.<\/p>\n<p>Install CodeNarc plugin into you grails project. Now create one groovy file say CustomRules.groovy and add following code into it.<\/p>\n<p>[java] <\/p>\n<p>ruleset {<br \/>\n\tPrintln<br \/>\n\tSystemOutPrint \/\/these are the rules from CodeNarc library<br \/>\n}<\/p>\n<p>[\/java]<\/p>\n<p>The above configuration will look for <a href=\"http:\/\/codenarc.sourceforge.net\/codenarc-rules-logging.html\">Println and SystemOutPrint (Logging Rules)<\/a> rule violation in your project. see all <a href=\"http:\/\/codenarc.sourceforge.net\/codenarc-rule-index.html\">rules<\/a>.<\/p>\n<p>Now add location of this file in Config.properties<br \/>\n[java]<br \/>\ncodenarc.ruleSetFiles=&quot;file:grails-app\/conf\/CustomRules.groovy&quot;<br \/>\n[\/java]<br \/>\nand you are done with configuring custom rule, Now you can run codenarc for configured rule.<br \/>\n<br \/>\nHope this helps<br \/>\nAnkur<br \/>\nankur@intelligrape.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":8},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3212"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=3212"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3212\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=3212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=3212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=3212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}