-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using multi-catch results in compilation failure #28
Comments
Since CodeNarc uses the Groovy compiler, perhaps using a more compatible version of Groovy would help. Have you tried running CodeNarc against this source code with Groovy 2.x? |
The project where I first saw this issue was definitely using Groovy 2.x, and calling Codenarc via Gradle. I was basing my statements of 1.7.5 being used on reproducing the behavior within CodeNarc's test suite, but that may not be an accurate test for this issue. If CodeNarc uses the provided Groovy's compiler, perhaps the problem is that the Gradle CodeNarc plugin is using a different version of Groovy than the one specified? |
The Gradle CodeNarc plugin (http://www.gradle.org/docs/current/userguide/codenarc_plugin.html) apparently allows specifying a dependency configuration for the CodeNarc libraries (version) to use, but I have not tried that myself. |
Assuming you mean the toolVersion property, I tried that. Same behavior (for this) between the default version and 0.20. UPDATE: upon re-reading, I now see a mention of the "codenarc" dependency configuration. I wish there was an example of use. I'll try to figure it out. |
I've tried using the "codenarc" dependency configuration, and it doesn't look like it helps either. However, I think I may have found the real root-cause of the problem. Gradle is calling the CodeNarc Ant task using an IsolatedAntBuilder, but doesn't appear to be specifying the Groovy to use (and thus defaulting to Gradle's Groovy). For Gradle 1.10, that's Groovy 1.8.6. I'll close this issue after opening a follow-up issue with the Gradle project. https://github.com/gradle/gradle/blob/master/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarc.groovy#L127 |
Posted to the Gradle project: http://forums.gradle.org/gradle/topics/gradle_codenarc_plugin_doesnt_use_correct_version_of_groovy Thanks for your help, @chrismair |
If you have classes that use a Groovy multi-catch block (available since Groovy 2.0), these classes will fail to compile in CodeNarc. The failure looks sort of like this when building with Gradle:
It does not appear to cause any issues to appear in the CodeNarc report. I'm unsure of whether rules are actually being run against these classes or not.
It appears that this is caused by using an old version of Groovy (1.7.5) for the compilation, resulting in an "unexpected token" error since it doesn't know about the multi-catch syntax that was introduced in later versions of Groovy.
http://groovy.codehaus.org/JN3035-Exceptions
The text was updated successfully, but these errors were encountered: