What

GroovyLint is a library for Groovy that adds additional compile time checks.

Why

The sooner a problem is caught, the less time you have to spend debugging it.

How

To set up GroovyLint, follow these steps:

  1. Download GroovyLint
  2. Put groovylint.jar on your classpath
  3. Enjoy less runtime errors

Frequently Asked Questions

What IDEs does GroovyLint support?

GroovyLint has mainly been tested with Eclipse, but it should work in any IDE that supports Groovy. Here is a screenshot of it working in Eclipse:

How can you do compile-time checking if the MetaClass could be modified at run-time?

Even though you could use metaprogramming to do tricky things like making 5 + 5 return the String "hello", or changing a method to return a Map instead of a boolean, that probably isn't a good idea because it's confusing.

A lot of GroovyLint errors could be valid Groovy code, but the majority of the time it will be an error. And you can always turn off certain GroovyLint errors if they clash with your style of programming.

How do I disable certain GroovyLint warnings?

To disable a warning for a certain class or method, add the @DisableGroovyLint("warning_to_disable") annotation to the class or method. You can also disable a warning project-wide by creating a GroovyLintSettings.groovy file. For more details click here.

How does GroovyLint work?

Groovy lets developers extend the Groovy compiler by writing abstract syntax tree (AST) transformations. GroovyLint is an AST transformation that performs various checks on the abstract syntax tree of your program.

What license is GroovyLint under?

GroovyLint is licensed under the same license as Groovy: Apache License v2.0. Basically, you can use GroovyLint for whatever you want, as long as you leave copyright notices intact.

Open Issues

There are a few things that I haven't been able to figure out how to do yet for GroovyLint. If you have a suggestion, please post it on the GroovyLint Group

  1. Not tested with Grails yet. If you try it out, let me know if it works or not.
  2. How to add a warning during an AST Transformation. There is an addWarning method on the ErrorCollector class, but it requires a CSTNode, and I don't know where to get one. All I have is ASTNodes.
  3. A better way to change GroovyLint settings. Currently you must create a class in your project with the desired settings.
  4. Inner/Nested classes have not been tested with GroovyLint yet. Let me know if you test it out.



Have a suggestion, a bug to report, or need some help? Go to the GroovyLint Group