Resolving Codenarc Compilation Warnings

To resolve compilation warnings when using Codenarc 0.19+, look at the enhanced rules..

Object Partners

After seeing several developers on my team make simple style errors, I looked into updating our custom codenarc ruleset. Most of the rules were turned off and it had not been updated in almost 10 minor releases.  In general, the updates were wonderful. The code is cleaner and new pull requests are much easier to read! After the update; however, I noticed pages of warnings all in the style:

Codenarc Compilation Warnings The task was still passing so I kept going for a while and made a note to fix it later.  Recently, I was digging through the Codenarc docs again and came across this:

NOTE: If a rule requiring a later compiler phase is included in the active CodeNarc ruleset and enabled and one or more of the required classes is not on the classpath, then CodeNarcwill log a Log4J WARN message for each source file that contains the missing references.

in the section on Enhanced Classpath Rules

According to the documentation, the Grails plugin and Ant task support the enhanced rules, but our configuration uses the Gradle codenarc plugin which does not.  I turned off the enhanced rules and the warnings resolved.  If you are using Codenarc 0.19+ and you are seeing this error, this might be the problem for you too.

Share this Post

Related Blog Posts

JVM

Using secondary datasources in Grails 3

March 9th, 2016

Something changed in Grails 3 and how datasources are configured. This post will explain what you need to do.

Mike Hostetler
JVM

Unit Testing URI-Based Grails Filters

March 1st, 2016

A workaround for the inability to mock URI-based filters in Grails.

Igor Shults
JVM

An Introduction to Kotlin

February 23rd, 2016

An overview of the Kotlin programming language which keeps the good parts of Java while reducing boilerplate to promote better Object-Oriented code.

Mike Plummer

About the author