2

I am working on static Groovy scripts analysis. Only tool I've found is CodeNarc, but how can I edit rulesets, without editting CodeNarc.jar?

I am calling CodeNarc from command line:

java -classpath "binary-tools/CodeNarc/groovy-all-2.4.6-jenkins-1.jar:binary-tools/CodeNarc/CodeNarc-1.0.jar:binary-tools/CodeNarc/log4j-1.2.17.jar:binary-tools/CodeNarc/slf4j-api-1.7.2.jar:binary-tools/CodeNarc/slf4j-jdk14-1.7.2.jar" org.codenarc.CodeNarc -rulesetfiles="rulesets/basic.xml,rulesets/generic.xml,rulesets/logging.xml,rulesets/dry.xml,rulesets/serialization.xml"

I see that I can specify which rulesets form INSIDE CodeNarc I can use, I'd like to disable single rules from given ruleset. How to do it?

1 Answers1

1

Depending on what you are using to manage the jar, there should be a configuration option available to set the rules. The location will vary depending on the configuration in gradle, etc. You can see more at http://codenarc.sourceforge.net/codenarc-configuring-rules.html I highly recommend configuring the ruleset to your preferences as some rules are better for certain types of groovy projects than others. If you add some info about your project type (grails, spring boot, etc) and your build system(gradle, maven, etc), I can provide more specific help.

jstrater
  • 176
  • 1
  • 10
  • Nope, I wanted to made it a simple as calling one line in command line – Vardens Archangel Sep 13 '17 at 19:23
  • Ok. In command line example above, the rulesets are [relative file locations](http://codenarc.sourceforge.net/codenarc-command-line.html). If you create your own ruleset like [this](http://codenarc.sourceforge.net/codenarc-creating-ruleset.html) and configure which rules to include/exclude you should be able to pass that in instead. – jstrater Sep 14 '17 at 05:39