groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch master updated: minor refactor: remove some codenarc violations (cont'd)
Date Tue, 02 Apr 2019 13:35:53 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new ebe8c51  minor refactor: remove some codenarc violations (cont'd)
ebe8c51 is described below

commit ebe8c5110683aa7a5397f033a000ce6c9bf3b9f4
Author: Paul King <paulk@asert.com.au>
AuthorDate: Tue Apr 2 23:35:40 2019 +1000

    minor refactor: remove some codenarc violations (cont'd)
---
 .../beans/ListenerListASTTransformation.groovy     |   2 +-
 src/main/groovy/groovy/grape/GrapeIvy.groovy       | 251 +++++++++++----------
 .../codehaus/groovy/ast/builder/AstBuilder.groovy  |  54 +++--
 .../customizers/ASTTransformationCustomizer.groovy |  69 +++---
 .../org/codehaus/groovy/tools/GrapeMain.groovy     |  86 +++----
 .../groovy/transform/ASTTestTransformation.groovy  |  55 +++--
 ...onditionalInterruptibleASTTransformation.groovy | 158 ++++++-------
 .../ThreadInterruptibleASTTransformation.groovy    |  10 +-
 .../TimedInterruptibleASTTransformation.groovy     |  30 +--
 .../groovy/transform/tailrec/AstHelper.groovy      |  16 +-
 .../transform/tailrec/CollectRecursiveCalls.groovy |   6 +-
 .../transform/tailrec/InWhileLoopWrapper.groovy    |  20 +-
 .../transform/tailrec/RecursivenessTester.groovy   |  10 +-
 .../tailrec/ReturnAdderForClosures.groovy          |   4 +-
 .../ReturnStatementToIterationConverter.groovy     |   7 +-
 .../transform/tailrec/StatementReplacer.groovy     |  17 +-
 .../tailrec/TailRecursiveASTTransformation.groovy  |  10 +-
 .../tailrec/TernaryToIfStatementConverter.groovy   |   5 +-
 .../tailrec/VariableAccessReplacer.groovy          |   4 +-
 .../tailrec/VariableExpressionReplacer.groovy      |   7 +-
 .../tailrec/VariableExpressionTransformer.groovy   |   7 +-
 21 files changed, 437 insertions(+), 391 deletions(-)

diff --git a/src/main/groovy/groovy/beans/ListenerListASTTransformation.groovy b/src/main/groovy/groovy/beans/ListenerListASTTransformation.groovy
index 9ac3f44..7696def 100644
--- a/src/main/groovy/groovy/beans/ListenerListASTTransformation.groovy
+++ b/src/main/groovy/groovy/beans/ListenerListASTTransformation.groovy
@@ -169,7 +169,7 @@ class ListenerListASTTransformation implements ASTTransformation, Opcodes {
     }
 
     /**
-     * Adds the remove<Listener> method like:
+     * Adds the remove&lt;Listener&gt; method like:
      * <pre>
      * synchronized void remove${name.capitalize}(${listener.name} listener) {
      *     if (listener == null)
diff --git a/src/main/groovy/groovy/grape/GrapeIvy.groovy b/src/main/groovy/groovy/grape/GrapeIvy.groovy
index 014bbdd..3e11a9e 100644
--- a/src/main/groovy/groovy/grape/GrapeIvy.groovy
+++ b/src/main/groovy/groovy/grape/GrapeIvy.groovy
@@ -65,14 +65,15 @@ import java.util.zip.ZipFile
 class GrapeIvy implements GrapeEngine {
 
     private static final String METAINF_PREFIX = 'META-INF/services/'
-    private static final String RUNNER_PROVIDER_CONFIG = GroovyRunner.class.getName()
+    private static final String RUNNER_PROVIDER_CONFIG = GroovyRunner.name
+    private static final List<String> DEF_CONFIG = ['default']
 
     private final exclusiveGrabArgs = [
             ['group', 'groupId', 'organisation', 'organization', 'org'],
             ['module', 'artifactId', 'artifact'],
             ['version', 'revision', 'rev'],
             ['conf', 'scope', 'configuration'],
-        ].inject([:], {m, g -> g.each {a -> m[a] = (g - a) as Set};  m})
+    ].inject([:], { m, g -> g.each { a -> m[a] = (g - a) as Set }; m })
 
     boolean enableGrapes
     Ivy ivyInstance
@@ -85,92 +86,91 @@ class GrapeIvy implements GrapeEngine {
     // we keep the settings so that addResolver can add to the resolver chain
     IvySettings settings
 
+    @SuppressWarnings('Instanceof')
     GrapeIvy() {
         // if we are already initialized, quit
         if (enableGrapes) return
 
         // start ivy
-        Message.defaultLogger = new DefaultMessageLogger(System.getProperty("ivy.message.logger.level", "-1") as int)
+        Message.defaultLogger = new DefaultMessageLogger(System.getProperty('ivy.message.logger.level', '-1') as int)
         settings = new IvySettings()
 
         // configure settings
-        def grapeConfig = getLocalGrapeConfig()
+        def grapeConfig = localGrapeConfig
         if (!grapeConfig.exists()) {
-            grapeConfig = GrapeIvy.getResource("defaultGrapeConfig.xml")
+            grapeConfig = GrapeIvy.getResource('defaultGrapeConfig.xml')
         }
         try {
             settings.load(grapeConfig) // exploit multi-methods for convenience
         } catch (java.text.ParseException ex) {
             def configLocation = grapeConfig instanceof File ? grapeConfig.canonicalPath : grapeConfig.toString()
             System.err.println "Local Ivy config file '$configLocation' appears corrupt - ignoring it and using default config instead\nError was: " + ex.message
-            grapeConfig = GrapeIvy.getResource("defaultGrapeConfig.xml")
+            grapeConfig = GrapeIvy.getResource('defaultGrapeConfig.xml')
             settings.load(grapeConfig)
         }
 
         // set up the cache dirs
-        settings.defaultCache = getGrapeCacheDir()
+        settings.defaultCache = grapeCacheDir
 
-        settings.setVariable("ivy.default.configuration.m2compatible", "true")
+        settings.setVariable('ivy.default.configuration.m2compatible', 'true')
         ivyInstance = Ivy.newInstance(settings)
-        IvyContext.getContext().setIvy(ivyInstance)
+        IvyContext.context.ivy = ivyInstance
         resolvedDependencies = []
         downloadedArtifacts = []
 
-        //TODO add grab to the DGM??
-
         enableGrapes = true
     }
 
     @CompileStatic
     File getGroovyRoot() {
-        String root = System.getProperty("groovy.root")
+        String root = System.getProperty('groovy.root')
         def groovyRoot
         if (root == null) {
-            groovyRoot = new File(System.getProperty("user.home"), ".groovy")
+            groovyRoot = new File(System.getProperty('user.home'), '.groovy')
         } else {
             groovyRoot = new File(root)
         }
         try {
             groovyRoot = groovyRoot.canonicalFile
-        } catch (IOException e) {
+        } catch (IOException ignore) {
             // skip canonicalization then, it may not exist yet
         }
-        return groovyRoot
+        groovyRoot
     }
 
     @CompileStatic
     File getLocalGrapeConfig() {
-        String grapeConfig = System.getProperty("grape.config")
-        if(grapeConfig) {
+        String grapeConfig = System.getProperty('grape.config')
+        if (grapeConfig) {
             return new File(grapeConfig)
         }
-        return new File(getGrapeDir(), 'grapeConfig.xml')
+        new File(grapeDir, 'grapeConfig.xml')
     }
 
     @CompileStatic
     File getGrapeDir() {
-        String root = System.getProperty("grape.root")
-        if(root == null) {
-            return getGroovyRoot()
+        String root = System.getProperty('grape.root')
+        if (root == null) {
+            return groovyRoot
         }
         File grapeRoot = new File(root)
         try {
             grapeRoot = grapeRoot.canonicalFile
-        } catch (IOException e) {
+        } catch (IOException ignore) {
             // skip canonicalization then, it may not exist yet
         }
-        return grapeRoot
+        grapeRoot
     }
 
     @CompileStatic
     File getGrapeCacheDir() {
-        File cache =  new File(getGrapeDir(), 'grapes')
+        File cache = new File(grapeDir, 'grapes')
         if (!cache.exists()) {
             cache.mkdirs()
         } else if (!cache.isDirectory()) {
             throw new RuntimeException("The grape cache dir $cache is not a directory")
         }
-        return cache
+        cache
     }
 
     @CompileStatic
@@ -190,30 +190,31 @@ class GrapeIvy implements GrapeEngine {
             //    loader = GrapeIvy.class.classLoader
             //}
             if (!isValidTargetClassLoader(loader)) {
-                throw new RuntimeException("No suitable ClassLoader found for grab")
+                throw new RuntimeException('No suitable ClassLoader found for grab')
             }
         }
-        return loader
+        loader
     }
 
     @CompileStatic
     private boolean isValidTargetClassLoader(loader) {
-        return isValidTargetClassLoaderClass(loader?.class)
+        isValidTargetClassLoaderClass(loader?.class)
     }
 
     @CompileStatic
     private boolean isValidTargetClassLoaderClass(Class loaderClass) {
-        return (loaderClass != null) &&
-            (
-             (loaderClass.name == 'groovy.lang.GroovyClassLoader') ||
-             (loaderClass.name == 'org.codehaus.groovy.tools.RootLoader') ||
-             isValidTargetClassLoaderClass(loaderClass.superclass)
-            )
+        loaderClass != null &&
+                (
+                        (loaderClass.name == 'groovy.lang.GroovyClassLoader') ||
+                                (loaderClass.name == 'org.codehaus.groovy.tools.RootLoader') ||
+                                isValidTargetClassLoaderClass(loaderClass.superclass)
+                )
     }
 
+    @SuppressWarnings('Instanceof')
     IvyGrabRecord createGrabRecord(Map deps) {
         // parse the actual dependency arguments
-        String module =  deps.module ?: deps.artifactId ?: deps.artifact
+        String module = deps.module ?: deps.artifactId ?: deps.artifact
         if (!module) {
             throw new RuntimeException('grab requires at least a module: or artifactId: or artifact: argument')
         }
@@ -228,30 +229,30 @@ class GrapeIvy implements GrapeEngine {
 
         ModuleRevisionId mrid = ModuleRevisionId.newInstance(groupId, module, version)
 
-        boolean force      = deps.containsKey('force')      ? deps.force      : true
-        boolean changing   = deps.containsKey('changing')   ? deps.changing   : false
+        boolean force = deps.containsKey('force') ? deps.force : true
+        boolean changing = deps.containsKey('changing') ? deps.changing : false
         boolean transitive = deps.containsKey('transitive') ? deps.transitive : true
-        def conf = deps.conf ?: deps.scope ?: deps.configuration ?: ['default']
+        def conf = deps.conf ?: deps.scope ?: deps.configuration ?: DEF_CONFIG
         if (conf instanceof String) {
-            if (conf.startsWith("[") && conf.endsWith("]")) conf = conf[1..-2]
-            conf = conf.split(",").toList()
+            if (conf.startsWith('[') && conf.endsWith(']')) conf = conf[1..-2]
+            conf = conf.split(',').toList()
         }
         def classifier = deps.classifier ?: null
 
-        return new IvyGrabRecord(mrid:mrid, conf:conf, changing:changing, transitive:transitive, force:force, classifier:classifier, ext:ext, type:type)
+        new IvyGrabRecord(mrid: mrid, conf: conf, changing: changing, transitive: transitive, force: force, classifier: classifier, ext: ext, type: type)
     }
 
     @Override
     @CompileStatic
     grab(String endorsedModule) {
-        return grab(group:'groovy.endorsed', module:endorsedModule, version:GroovySystem.version)
+        grab(group: 'groovy.endorsed', module: endorsedModule, version: GroovySystem.version)
     }
 
     @Override
     @CompileStatic
     grab(Map args) {
-        args.calleeDepth = args.calleeDepth?:DEFAULT_CALLEE_DEPTH + 1
-        return grab(args, args)
+        args.calleeDepth = args.calleeDepth ?: DEFAULT_CALLEE_DEPTH + 1
+        grab(args, args)
     }
 
     @Override
@@ -263,9 +264,9 @@ class GrapeIvy implements GrapeEngine {
         try {
             // identify the target classloader early, so we fail before checking repositories
             loader = chooseClassLoader(
-                classLoader:args.remove('classLoader'),
-                refObject:args.remove('refObject'),
-                calleeDepth:args.calleeDepth?:DEFAULT_CALLEE_DEPTH,
+                    classLoader: args.remove('classLoader'),
+                    refObject: args.remove('refObject'),
+                    calleeDepth: args.calleeDepth ?: DEFAULT_CALLEE_DEPTH,
             )
 
             // check for non-fail null.
@@ -287,7 +288,7 @@ class GrapeIvy implements GrapeEngine {
                 }
             }
             if (runnerServicesFound) {
-                GroovyRunnerRegistry.getInstance().load(loader)
+                GroovyRunnerRegistry.instance.load(loader)
             }
         } catch (Exception e) {
             // clean-up the state first
@@ -300,17 +301,18 @@ class GrapeIvy implements GrapeEngine {
             }
             throw e
         }
-        return null
+        null
     }
 
     private void addURL(ClassLoader loader, URI uri) {
         loader.addURL(uri.toURL())
     }
 
+    @SuppressWarnings('Instanceof')
     @CompileStatic
     private processCategoryMethods(ClassLoader loader, File file) {
         // register extension methods if jar
-        if (file.name.toLowerCase().endsWith(".jar")) {
+        if (file.name.toLowerCase().endsWith('.jar')) {
             def mcRegistry = GroovySystem.metaClassRegistry
             if (mcRegistry instanceof MetaClassRegistryImpl) {
                 try (JarFile jar = new JarFile(file)) {
@@ -340,7 +342,7 @@ class GrapeIvy implements GrapeEngine {
                             classesToBeUpdated*.addNewMopMethods(methods)
                         }
                     }
-                } catch(ZipException zipException) {
+                } catch (ZipException zipException) {
                     throw new RuntimeException("Grape could not load jar '$file'", zipException)
                 }
             }
@@ -380,7 +382,7 @@ class GrapeIvy implements GrapeEngine {
                 services.add(providerConfig)
 
                 try (InputStream is = zf.getInputStream(pluginRunners)) {
-                    processRunners(is, f.getName(), loader)
+                    processRunners(is, f.name, loader)
                 }
             }
             // GroovyRunners are loaded per ClassLoader using a ServiceLoader so here
@@ -388,29 +390,29 @@ class GrapeIvy implements GrapeEngine {
             if (zf.getEntry(METAINF_PREFIX + RUNNER_PROVIDER_CONFIG) != null) {
                 services.add(RUNNER_PROVIDER_CONFIG)
             }
-        } catch(ZipException ignore) {
+        } catch (ZipException ignore) {
             // ignore files we can't process, e.g. non-jar/zip artifacts
             // TODO log a warning
         }
-        return services
+        services
     }
 
     @CompileStatic
     void processSerializedCategoryMethods(InputStream is) {
         is.text.readLines().each {
-            println it.trim() // TODO implement this or delete it
+            System.err.println it.trim() // TODO implement this or delete it
         }
     }
 
     @CompileStatic
     void processRunners(InputStream is, String name, ClassLoader loader) {
-        GroovyRunnerRegistry registry = GroovyRunnerRegistry.getInstance()
-        is.text.readLines()*.trim().findAll{ String line -> !line.isEmpty() && line[0] != '#' }.each {
+        GroovyRunnerRegistry registry = GroovyRunnerRegistry.instance
+        is.text.readLines()*.trim().findAll { String line -> !line.isEmpty() && line[0] != '#' }.each {
             String line = (String) it
             try {
                 registry[name] = (GroovyRunner) loader.loadClass(line).newInstance()
             } catch (Exception ex) {
-                throw new IllegalStateException("Error registering runner class '" + it + "'", ex)
+                throw new IllegalStateException("Error registering runner class '$it'", ex)
             }
         }
     }
@@ -420,31 +422,33 @@ class GrapeIvy implements GrapeEngine {
 
         def millis = System.currentTimeMillis()
         def md = new DefaultModuleDescriptor(ModuleRevisionId
-                .newInstance("caller", "all-caller", "working" + millis.toString()[-2..-1]), "integration", null, true)
+                .newInstance('caller', 'all-caller', 'working' + millis.toString()[-2..-1]), 'integration', null, true)
         md.addConfiguration(new Configuration('default'))
-        md.setLastModified(millis)
+        md.lastModified = millis
 
         addExcludesIfNeeded(args, md)
 
         for (IvyGrabRecord grabRecord : grabRecords) {
             def conf = grabRecord.conf ?: ['*']
-            DefaultDependencyDescriptor dd = (DefaultDependencyDescriptor) md.dependencies.find {it.dependencyRevisionId.equals(grabRecord.mrid)}
+            DefaultDependencyDescriptor dd = (DefaultDependencyDescriptor) md.dependencies.find {
+                it.dependencyRevisionId.equals(grabRecord.mrid)
+            }
             if (dd) {
-                createAndAddDependencyArtifactDescriptor(dd, grabRecord, conf)
+                addDependencyArtifactDescriptor(dd, grabRecord, conf)
             } else {
                 dd = new DefaultDependencyDescriptor(md, grabRecord.mrid, grabRecord.force,
                         grabRecord.changing, grabRecord.transitive)
-                conf.each {dd.addDependencyConfiguration('default', it)}
-                createAndAddDependencyArtifactDescriptor(dd, grabRecord, conf)
+                conf.each { dd.addDependencyConfiguration('default', it) }
+                addDependencyArtifactDescriptor(dd, grabRecord, conf)
                 md.addDependency(dd)
             }
         }
 
-       // resolve grab and dependencies
+        // resolve grab and dependencies
         ResolveOptions resolveOptions = new ResolveOptions()
-            .setConfs(['default'] as String[])
-            .setOutputReport(false)
-            .setValidate((boolean) (args.containsKey('validate') ? args.validate : false))
+                .setConfs(GrapeIvy.DEF_CONFIG as String[])
+                .setOutputReport(false)
+                .setValidate((boolean) (args.containsKey('validate') ? args.validate : false))
 
         ivyInstance.settings.defaultResolver = args.autoDownload ? 'downloadGrapes' : 'cachedGrapes'
         if (args.disableChecksums) {
@@ -461,10 +465,10 @@ class GrapeIvy implements GrapeEngine {
             try {
                 report = ivyInstance.resolve(md, resolveOptions)
                 break
-            } catch(IOException ioe) {
+            } catch (IOException ioe) {
                 if (attempt--) {
                     if (reportDownloads)
-                        System.err.println "Grab Error: retrying..."
+                        System.err.println 'Grab Error: retrying...'
                     sleep attempt > 4 ? 350 : 1000
                     continue
                 }
@@ -485,7 +489,7 @@ class GrapeIvy implements GrapeEngine {
             cacheManager.getResolvedIvyPropertiesInCache(md.moduleRevisionId).delete()
         }
 
-        return report
+        report
     }
 
     private addIvyListener() {
@@ -496,7 +500,7 @@ class GrapeIvy implements GrapeEngine {
                         def name = it.toString()
                         if (!resolvedDependencies.contains(name)) {
                             resolvedDependencies << name
-                            System.err.println "Resolving " + name
+                            System.err.println "Resolving $name"
                         }
                     }
                     break
@@ -505,7 +509,7 @@ class GrapeIvy implements GrapeEngine {
                         def name = it.toString()
                         if (!downloadedArtifacts.contains(name)) {
                             downloadedArtifacts << name
-                            System.err.println "Preparing to download artifact " + name
+                            System.err.println "Preparing to download artifact $name"
                         }
                     }
                     break
@@ -514,9 +518,10 @@ class GrapeIvy implements GrapeEngine {
     }
 
     @CompileStatic
-    private void createAndAddDependencyArtifactDescriptor(DefaultDependencyDescriptor dd, IvyGrabRecord grabRecord, List<String> conf) {
+    private void addDependencyArtifactDescriptor(DefaultDependencyDescriptor dd, IvyGrabRecord grabRecord, List<String> conf) {
         // TODO: find out "unknown" reason and change comment below - also, confirm conf[0] check vs conf.contains('optional')
-        if (conf[0]!="optional" || grabRecord.classifier) {  // for some unknown reason optional dependencies should not have an artifactDescriptor
+        if (conf[0] != 'optional' || grabRecord.classifier) {
+            // for some unknown reason optional dependencies should not have an artifactDescriptor
             def dad = new DefaultDependencyArtifactDescriptor(dd,
                     grabRecord.mrid.name, grabRecord.type ?: 'jar', grabRecord.ext ?: 'jar', null, grabRecord.classifier ? [classifier: grabRecord.classifier] : null)
             conf.each { dad.addConfiguration(it) }
@@ -541,19 +546,7 @@ class GrapeIvy implements GrapeEngine {
                         def publis = root.getElementsByTagName('publications')
                         for (int i = 0; i < publis.length; i++) {
                             def artifacts = publis.item(i).getElementsByTagName('artifact')
-                            for (int j = 0; j < artifacts.length; j++) {
-                                def artifact = artifacts.item(j)
-                                def attrs = artifact.attributes
-                                def name = attrs.getNamedItem('name').getTextContent() + "-$rev"
-                                def classifier = attrs.getNamedItemNS("m", "classifier")?.getTextContent()
-                                if (classifier) name += "-$classifier"
-                                name += ".${attrs.getNamedItem('ext').getTextContent()}"
-                                def jarfile = new File(jardir, name)
-                                if (jarfile.exists()) {
-                                    println "Deleting ${jarfile.name}"
-                                    jarfile.delete()
-                                }
-                            }
+                            processArtifacts(artifacts, rev, jardir)
                         }
                         ivyFile.delete()
                     }
@@ -562,9 +555,25 @@ class GrapeIvy implements GrapeEngine {
         }
     }
 
+    private void processArtifacts(artifacts, String rev, File jardir) {
+        for (int j = 0; j < artifacts.length; j++) {
+            def artifact = artifacts.item(j)
+            def attrs = artifact.attributes
+            def name = attrs.getNamedItem('name').textContent + "-$rev"
+            def classifier = attrs.getNamedItemNS('m', 'classifier')?.textContent
+            if (classifier) name += "-$classifier"
+            name += ".${attrs.getNamedItem('ext').textContent}"
+            def jarfile = new File(jardir, name)
+            if (jarfile.exists()) {
+                System.err.println "Deleting ${jarfile.name}"
+                jarfile.delete()
+            }
+        }
+    }
+
     private addExcludesIfNeeded(Map args, DefaultModuleDescriptor md) {
         if (!args.containsKey('excludes')) return
-        args.excludes.each{ map ->
+        args.excludes.each { map ->
             def excludeRule = new DefaultExcludeRule(new ArtifactId(
                     new ModuleId(map.group, map.module), PatternMatcher.ANY_EXPRESSION,
                     PatternMatcher.ANY_EXPRESSION,
@@ -580,30 +589,30 @@ class GrapeIvy implements GrapeEngine {
     Map<String, Map<String, List<String>>> enumerateGrapes() {
         Map<String, Map<String, List<String>>> bunches = [:]
         Pattern ivyFilePattern = ~/ivy-(.*)\.xml/ //TODO get pattern from ivy conf
-        grapeCacheDir.eachDir {File groupDir ->
+        grapeCacheDir.eachDir { File groupDir ->
             Map<String, List<String>> grapes = [:]
             bunches[groupDir.name] = grapes
             groupDir.eachDir { File moduleDir ->
                 List<String> versions = []
-                moduleDir.eachFileMatch(ivyFilePattern) {File ivyFile ->
+                moduleDir.eachFileMatch(ivyFilePattern) { File ivyFile ->
                     def m = ivyFilePattern.matcher(ivyFile.name)
                     if (m.matches()) versions += m.group(1)
                 }
                 grapes[moduleDir.name] = versions
             }
         }
-        return bunches
+        bunches
     }
 
     @Override
     @CompileStatic
-    URI[] resolve(Map args, Map ... dependencies) {
+    URI[] resolve(Map args, Map... dependencies) {
         resolve(args, null, dependencies)
     }
 
     @Override
     @CompileStatic
-    URI[] resolve(Map args, List depsInfo, Map ... dependencies) {
+    URI[] resolve(Map args, List depsInfo, Map... dependencies) {
         // identify the target classloader early, so we fail before checking repositories
         ClassLoader loader = chooseClassLoader(
                 classLoader: args.remove('classLoader'),
@@ -613,20 +622,22 @@ class GrapeIvy implements GrapeEngine {
 
         // check for non-fail null.
         // If we were in fail mode we would have already thrown an exception
-        if (!loader) return
+        if (!loader) {
+            return [] as URI[]
+        }
 
         resolve(loader, args, depsInfo, dependencies)
     }
 
     @CompileStatic
-    URI [] resolve(ClassLoader loader, Map args, Map... dependencies) {
-        return resolve(loader, args, null, dependencies)
+    URI[] resolve(ClassLoader loader, Map args, Map... dependencies) {
+        resolve(loader, args, null, dependencies)
     }
 
-    URI [] resolve(ClassLoader loader, Map args, List depsInfo, Map... dependencies) {
+    URI[] resolve(ClassLoader loader, Map args, List depsInfo, Map... dependencies) {
         // check for mutually exclusive arguments
         Set keys = args.keySet()
-        keys.each {a ->
+        keys.each { a ->
             Set badArgs = exclusiveGrabArgs[a]
             if (badArgs && !badArgs.disjoint(keys)) {
                 throw new RuntimeException("Mutually exclusive arguments passed into grab: ${keys.intersect(badArgs) + a}")
@@ -634,7 +645,9 @@ class GrapeIvy implements GrapeEngine {
         }
 
         // check the kill switch
-        if (!enableGrapes) { return }
+        if (!enableGrapes) {
+            return [] as URI[]
+        }
 
         boolean populateDepsInfo = (depsInfo != null)
 
@@ -673,11 +686,11 @@ class GrapeIvy implements GrapeEngine {
             def deps = report.dependencies
             deps.each { depNode ->
                 def id = depNode.id
-                depsInfo << ['group' : id.organisation, 'module' : id.name, 'revision' : id.revision]
+                depsInfo << ['group': id.organisation, 'module': id.name, 'revision': id.revision]
             }
         }
 
-        return results as URI[]
+        results as URI[]
     }
 
     @CompileStatic
@@ -688,20 +701,20 @@ class GrapeIvy implements GrapeEngine {
             localDeps = new LinkedHashSet<IvyGrabRecord>()
             loadedDeps.put(loader, localDeps)
         }
-        return localDeps
+        localDeps
     }
 
     @Override
-    Map[] listDependencies (ClassLoader classLoader) {
+    Map[] listDependencies(ClassLoader classLoader) {
         if (loadedDeps.containsKey(classLoader)) {
             List<Map> results = []
             loadedDeps[classLoader].each { IvyGrabRecord grabbed ->
-                def dep =  [
-                    group : grabbed.mrid.organisation,
-                    module : grabbed.mrid.name,
-                    version : grabbed.mrid.revision
+                def dep = [
+                        group  : grabbed.mrid.organisation,
+                        module : grabbed.mrid.name,
+                        version: grabbed.mrid.revision
                 ]
-                if (grabbed.conf != ['default']) {
+                if (grabbed.conf != GrapeIvy.DEF_CONFIG) {
                     dep.conf = grabbed.conf
                 }
                 if (grabbed.changing) {
@@ -726,13 +739,13 @@ class GrapeIvy implements GrapeEngine {
             }
             return results
         }
-        return null
+        null
     }
 
     @Override
     @CompileStatic
     void addResolver(Map<String, Object> args) {
-        ChainResolver chainResolver = (ChainResolver) settings.getResolver("downloadGrapes")
+        ChainResolver chainResolver = (ChainResolver) settings.getResolver('downloadGrapes')
 
         IBiblioResolver resolver = new IBiblioResolver(
                 name: (String) args.name,
@@ -761,13 +774,13 @@ class IvyGrabRecord {
 
     @Override
     int hashCode() {
-        return (mrid.hashCode() ^ conf.hashCode()
-            ^ (changing ? 0xaaaaaaaa : 0x55555555)
-            ^ (transitive ? 0xbbbbbbbb : 0x66666666)
-            ^ (force ? 0xcccccccc: 0x77777777)
-            ^ (classifier ? classifier.hashCode() : 0)
-            ^ (ext ? ext.hashCode() : 0)
-            ^ (type ? type.hashCode() : 0))
+        (mrid.hashCode() ^ conf.hashCode()
+                ^ (changing ? 0xaaaaaaaa : 0x55555555)
+                ^ (transitive ? 0xbbbbbbbb : 0x66666666)
+                ^ (force ? 0xcccccccc : 0x77777777)
+                ^ (classifier ? classifier.hashCode() : 0)
+                ^ (ext ? ext.hashCode() : 0)
+                ^ (type ? type.hashCode() : 0))
     }
 
     @Override
@@ -778,7 +791,7 @@ class IvyGrabRecord {
 
         IvyGrabRecord o = (IvyGrabRecord) obj
 
-        return ((changing == o.changing)
+        ((changing == o.changing)
                 && (transitive == o.transitive)
                 && (force == o.force)
                 && (mrid == o.mrid)
diff --git a/src/main/groovy/org/codehaus/groovy/ast/builder/AstBuilder.groovy b/src/main/groovy/org/codehaus/groovy/ast/builder/AstBuilder.groovy
index f181b23..e678b4b 100644
--- a/src/main/groovy/org/codehaus/groovy/ast/builder/AstBuilder.groovy
+++ b/src/main/groovy/org/codehaus/groovy/ast/builder/AstBuilder.groovy
@@ -36,23 +36,27 @@ import org.codehaus.groovy.control.CompilePhase
 class AstBuilder {
 
     /**
-     * Builds AST based on the code within the  {@link Closure}  parameter.
+     * Builds AST based on the code within the {@link Closure}  parameter.
      *
      * This method <strong>must</strong> be invoked at compile time and never at runtime, because
      * an ASTTransformation must be run to support it. If you receive an IllegalStateException then
      * you most likely need to add stronger typing. For instance, this will not work:
      * <code>
      *      def builder = new AstBuilder()
-     *      builder.buildFromCode {*             // some code
-     *}* </code>
+     *      builder.buildFromCode {
+     *             // some code
+     *      }
+     * </code>
      * While this code will:
      * <code>
-     *      new AstBuilder().buildFromCode {*             // some code
-     *}* </code>
+     *      new AstBuilder().buildFromCode {
+     *             // some code
+     *      }
+     * </code>
      *
-     * The compiler rewrites buildFromCode invocations into  {@link AstBuilder#buildFromString(CompilePhase, boolean, String)}
-     * invocations. An exception raised during AST generation will show a stack trace from  {@link AstBuilder#buildFromString(CompilePhase, boolean, String)}
-     * and not from  {@link AstBuilder#buildFromCode(CompilePhase, boolean, Closure)} .
+     * The compiler rewrites buildFromCode invocations into {@link AstBuilder#buildFromString(CompilePhase, boolean, String)}
+     * invocations. An exception raised during AST generation will show a stack trace from {@link AstBuilder#buildFromString(CompilePhase, boolean, String)}
+     * and not from {@link AstBuilder#buildFromCode(CompilePhase, boolean, Closure)} .
      *
      * The compiler saves the source code of the closure as a String within the Java class file. The String source
      * of the closure will be visible and un-obfuscated within the class file. If your Closure parameter contains
@@ -60,21 +64,21 @@ class AstBuilder {
      * Do not store sensitive data within the closure parameter.
      *
      * @param phase
-     *      the  {@link CompilePhase}  the AST will be targeted towards. Default is  {@link CompilePhase#CLASS_GENERATION}
+     *      the {@link CompilePhase} the AST will be targeted towards. Default is {@link CompilePhase#CLASS_GENERATION}
      * @param statementsOnly
      *      when true, only the script statements are returned. WHen false, you will
      *      receive back a Script class node also. Default is true.
      * @param block
      *      the code that will be converted
-     * @returns a List of  {@link ASTNode} .
-     * @throws IllegalStateException*      this method may not be invoked at runtime. It works via a compile-time transformation
-     *      of the closure source code into a String, which is sent to the  {@link AstBuilder#buildFromString(CompilePhase, boolean, String)}
-     *      method. The buildFromCode() method must be invoked against a strongly typed AstBuilder.
+     * @returns a List of {@link ASTNode}
+     * @throws IllegalStateException
+     * this method may not be invoked at runtime. It works via a compile-time transformation
+     * of the closure source code into a String, which is sent to the {@link AstBuilder#buildFromString(CompilePhase, boolean, String)}
+     * method. The buildFromCode() method must be invoked against a strongly typed AstBuilder.
      */
-    List<ASTNode> buildFromCode(CompilePhase phase = CompilePhase.CLASS_GENERATION, boolean statementsOnly = true, Closure block) {
-        throw new IllegalStateException("""AstBuilder.build(CompilePhase, boolean, Closure):List<ASTNode> should never be called at runtime.
-Are you sure you are using it correctly?
-""")
+    List<ASTNode> buildFromCode(CompilePhase ignoredPhase = CompilePhase.CLASS_GENERATION, boolean ignoredStatementsOnly = true, Closure ignoredBlock) {
+        throw new IllegalStateException('''AstBuilder.build(CompilePhase, boolean, Closure):List<ASTNode> should never be called at runtime.
+Are you sure you are using it correctly?''')
     }
 
 
@@ -89,11 +93,12 @@ Are you sure you are using it correctly?
      * @param source
      *      The source code String that will be compiled.
      * @returns a List of  {@link ASTNode} .
-     * @throws IllegalArgumentException*      if source is null or empty
+     * @throws IllegalArgumentException
+     *      if source is null or empty
      */
     List<ASTNode> buildFromString(CompilePhase phase = CompilePhase.CLASS_GENERATION, boolean statementsOnly = true, String source) {
-        if (!source || "" == source.trim()) throw new IllegalArgumentException("A source must be specified")
-        return new AstStringCompiler().compile(source, phase, statementsOnly);
+        if (!source || '' == source.trim()) throw new IllegalArgumentException('A source must be specified')
+        new AstStringCompiler().compile(source, phase, statementsOnly)
     }
 
     /**
@@ -107,11 +112,12 @@ Are you sure you are using it correctly?
      *      receive back a Script class node also. Default is true.
      * @param source
      *      The source code String that will be compiled. The string must be a block wrapped in curly braces. 
-     * @returns a List of  {@link ASTNode} .
-     * @throws IllegalArgumentException*      if source is null or empty
+     * @returns a List of {@link ASTNode}.
+     * @throws IllegalArgumentException if source is null or empty
      */
+    @SuppressWarnings('Instanceof')
     private List<ASTNode> buildFromBlock(CompilePhase phase = CompilePhase.CLASS_GENERATION, boolean statementsOnly = true, String source) {
-        if (!source || "" == source.trim()) throw new IllegalArgumentException("A source must be specified")
+        if (!source || '' == source.trim()) throw new IllegalArgumentException('A source must be specified')
         def labelledSource = "__synthesized__label__${System.currentTimeMillis()}__:" + source
         List<ASTNode> result = new AstStringCompiler().compile(labelledSource, phase, statementsOnly)
         // find the block statement from the result, and unwrap it from one level.
@@ -132,6 +138,6 @@ Are you sure you are using it correctly?
     List<ASTNode> buildFromSpec(@DelegatesTo(AstSpecificationCompiler) Closure specification) {
         if (specification == null) throw new IllegalArgumentException('Null: specification')
         def properties = new AstSpecificationCompiler(specification)
-        return properties.expression
+        properties.expression
     }
 }
diff --git a/src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy b/src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy
index 2a8db04..d6ac4aa 100644
--- a/src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy
+++ b/src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy
@@ -23,9 +23,7 @@ import org.codehaus.groovy.ast.ASTNode
 import org.codehaus.groovy.ast.AnnotationNode
 import org.codehaus.groovy.ast.ClassHelper
 import org.codehaus.groovy.ast.ClassNode
-import org.codehaus.groovy.ast.expr.ClassExpression
 import org.codehaus.groovy.ast.expr.ClosureExpression
-import org.codehaus.groovy.ast.expr.ConstantExpression
 import org.codehaus.groovy.ast.expr.Expression
 import org.codehaus.groovy.ast.expr.ListExpression
 import org.codehaus.groovy.classgen.GeneratorContext
@@ -38,6 +36,9 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass
 
 import java.lang.annotation.Annotation
 
+import static org.codehaus.groovy.ast.tools.GeneralUtils.classX
+import static org.codehaus.groovy.ast.tools.GeneralUtils.constX
+
 /**
  * This customizer allows applying an AST transformation to a source unit with
  * several strategies.
@@ -82,11 +83,11 @@ import java.lang.annotation.Annotation
  * 
  */
 class ASTTransformationCustomizer extends CompilationCustomizer implements CompilationUnitAware {
-    private final AnnotationNode annotationNode;
+    private final AnnotationNode annotationNode
     final ASTTransformation transformation
 
-    protected CompilationUnit compilationUnit;
-    private boolean applied = false; // used for global AST transformations
+    protected CompilationUnit compilationUnit
+    private boolean applied = false     // used for global AST transformations
 
     /**
      * Creates an AST transformation customizer using the specified annotation. The transformation classloader can
@@ -99,7 +100,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
      */
     ASTTransformationCustomizer(final Class<? extends Annotation> transformationAnnotation, String astTransformationClassName, ClassLoader transformationClassLoader) {
         super(findPhase(transformationAnnotation, astTransformationClassName, transformationClassLoader))
-        final Class<ASTTransformation> clazz = findASTTranformationClass(transformationAnnotation, astTransformationClassName, transformationClassLoader)
+        final Class<ASTTransformation> clazz = findASTTransformationClass(transformationAnnotation, astTransformationClassName, transformationClassLoader)
         this.transformation = clazz.newInstance()
         this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation))
     }
@@ -127,10 +128,10 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
      */
     ASTTransformationCustomizer(final Map annotationParams, final Class<? extends Annotation> transformationAnnotation, String astTransformationClassName, ClassLoader transformationClassLoader) {
         super(findPhase(transformationAnnotation, astTransformationClassName, transformationClassLoader))
-        final Class<ASTTransformation> clazz = findASTTranformationClass(transformationAnnotation, astTransformationClassName, transformationClassLoader)
+        final Class<ASTTransformation> clazz = findASTTransformationClass(transformationAnnotation, astTransformationClassName, transformationClassLoader)
         this.transformation = clazz.newInstance()
         this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation))
-        setAnnotationParameters(annotationParams)
+        this.annotationParameters = annotationParams
     }
 
     ASTTransformationCustomizer(final Map annotationParams, final Class<? extends Annotation> transformationAnnotation, String astTransformationClassName) {
@@ -145,7 +146,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
      */
     ASTTransformationCustomizer(final Class<? extends Annotation> transformationAnnotation, ClassLoader transformationClassLoader) {
         super(findPhase(transformationAnnotation, transformationClassLoader))
-        final Class<ASTTransformation> clazz = findASTTranformationClass(transformationAnnotation, transformationClassLoader)
+        final Class<ASTTransformation> clazz = findASTTransformationClass(transformationAnnotation, transformationClassLoader)
         this.transformation = clazz.newInstance()
         this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation))
     }
@@ -176,10 +177,10 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
      */
     ASTTransformationCustomizer(final Map annotationParams, final Class<? extends Annotation> transformationAnnotation, ClassLoader transformationClassLoader) {
         super(findPhase(transformationAnnotation, transformationClassLoader))
-        final Class<ASTTransformation> clazz = findASTTranformationClass(transformationAnnotation, transformationClassLoader)
+        final Class<ASTTransformation> clazz = findASTTransformationClass(transformationAnnotation, transformationClassLoader)
         this.transformation = clazz.newInstance()
         this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation))
-        setAnnotationParameters(annotationParams)
+        this.annotationParameters = annotationParams
     }
 
     ASTTransformationCustomizer(final Map annotationParams, final Class<? extends Annotation> transformationAnnotation) {
@@ -188,46 +189,48 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
 
     ASTTransformationCustomizer(final Map annotationParams, final ASTTransformation transformation) {
         this(transformation)
-        setAnnotationParameters(annotationParams)
+        this.annotationParameters = annotationParams
     }
 
     void setCompilationUnit(CompilationUnit unit) {
         compilationUnit = unit
     }
 
-    private static Class<ASTTransformation> findASTTranformationClass(Class<? extends Annotation> anAnnotationClass, ClassLoader transformationClassLoader) {
+    @SuppressWarnings('ClassForName')
+    private static Class<ASTTransformation> findASTTransformationClass(Class<? extends Annotation> anAnnotationClass, ClassLoader transformationClassLoader) {
         final GroovyASTTransformationClass annotation = anAnnotationClass.getAnnotation(GroovyASTTransformationClass)
-        if (annotation==null) throw new IllegalArgumentException("Provided class doesn't look like an AST @interface")
+        if (annotation == null) throw new IllegalArgumentException("Provided class doesn't look like an AST @interface")
 
         Class[] classes = annotation.classes()
         String[] classesAsStrings = annotation.value()
-        if (classes.length+classesAsStrings.length>1) {
+        if (classes.length + classesAsStrings.length > 1) {
             throw new IllegalArgumentException("AST transformation customizer doesn't support AST transforms with multiple classes")
         }
-        return classes?classes[0]:Class.forName(classesAsStrings[0], true, transformationClassLoader?:anAnnotationClass.classLoader)
+        classes ? classes[0] : Class.forName(classesAsStrings[0], true, transformationClassLoader ?: anAnnotationClass.classLoader)
     }
 
-    private static Class<ASTTransformation> findASTTranformationClass(Class<? extends Annotation> anAnnotationClass, String astTransformationClassName, ClassLoader transformationClassLoader) {
-        return Class.forName(astTransformationClassName, true, transformationClassLoader?:anAnnotationClass.classLoader) as Class<ASTTransformation>
+    @SuppressWarnings('ClassForName')
+    private static Class<ASTTransformation> findASTTransformationClass(Class<? extends Annotation> anAnnotationClass, String astTransformationClassName, ClassLoader transformationClassLoader) {
+        Class.forName(astTransformationClassName, true, transformationClassLoader ?: anAnnotationClass.classLoader) as Class<ASTTransformation>
     }
 
     private static CompilePhase findPhase(ASTTransformation transformation) {
-        if (transformation==null) throw new IllegalArgumentException("Provided transformation must not be null")
+        if (transformation == null) throw new IllegalArgumentException('Provided transformation must not be null')
         final Class<?> clazz = transformation.class
         final GroovyASTTransformation annotation = clazz.getAnnotation(GroovyASTTransformation)
-        if (annotation==null) throw new IllegalArgumentException("Provided ast transformation is not annotated with "+GroovyASTTransformation.name)
+        if (annotation == null) throw new IllegalArgumentException("Provided ast transformation is not annotated with $GroovyASTTransformation.name")
 
         annotation.phase()
     }
 
     private static CompilePhase findPhase(Class<? extends Annotation> annotationClass, ClassLoader transformationClassLoader) {
-        Class<ASTTransformation> clazz = findASTTranformationClass(annotationClass, transformationClassLoader);
+        Class<ASTTransformation> clazz = findASTTransformationClass(annotationClass, transformationClassLoader)
 
         findPhase(clazz.newInstance())
     }
 
     private static CompilePhase findPhase(Class<? extends Annotation> annotationClass, String astTransformationClassName, ClassLoader transformationClassLoader) {
-        Class<ASTTransformation> clazz = findASTTranformationClass(annotationClass, astTransformationClassName, transformationClassLoader);
+        Class<ASTTransformation> clazz = findASTTransformationClass(annotationClass, astTransformationClassName, transformationClassLoader)
 
         findPhase(clazz.newInstance())
     }
@@ -255,38 +258,40 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
      *
      * @since 1.8.1
      */
-    public void setAnnotationParameters(Map<String,Object> params) {
-        if (params==null || annotationNode==null) return;
+    @SuppressWarnings('Instanceof')
+    void setAnnotationParameters(Map<String, Object> params) {
+        if (params == null || annotationNode == null) return
         params.each { key, value ->
             if (!annotationNode.classNode.getMethod(key)) {
                 throw new IllegalArgumentException("${annotationNode.classNode.name} does not accept any [$key] parameter")
             }
             if (value instanceof Closure) {
-                throw new IllegalArgumentException("Direct usage of closure is not supported by the AST " +
-                "compilation customizer. Please use ClosureExpression instead.")
+                throw new IllegalArgumentException('Direct usage of closure is not supported by the AST ' +
+                        'compilation customizer. Please use ClosureExpression instead.')
             } else if (value instanceof Expression) {
                 // avoid NPEs due to missing source code
-                value.setLineNumber(0)
-                value.setLastLineNumber(0)
+                value.lineNumber = 0
+                value.lastLineNumber = 0
                 annotationNode.addMember(key, value)
             } else if (value instanceof Class) {
-                annotationNode.addMember(key, new ClassExpression(ClassHelper.make(value)))
+                annotationNode.addMember(key, classX(value))
             } else if (value instanceof List) {
                 annotationNode.addMember(key, new ListExpression(value.collect {
-                    it instanceof Class ? new ClassExpression(ClassHelper.make(it)) : new ConstantExpression(it)
+                    it instanceof Class ? classX(it) : constX(it)
                 }))
             } else {
-                annotationNode.addMember(key, new ConstantExpression(value))
+                annotationNode.addMember(key, constX(value))
             }
         }
     }
 
     @Override
+    @SuppressWarnings('Instanceof')
     void call(SourceUnit source, GeneratorContext context, ClassNode classNode) {
         if (transformation instanceof CompilationUnitAware) {
             transformation.compilationUnit = compilationUnit
         }
-        if (annotationNode!=null) {
+        if (annotationNode != null) {
             // this is a local ast transformation which is applied on every class node
             annotationNode.sourcePosition = classNode
             transformation.visit([annotationNode, classNode] as ASTNode[], source)
diff --git a/src/main/groovy/org/codehaus/groovy/tools/GrapeMain.groovy b/src/main/groovy/org/codehaus/groovy/tools/GrapeMain.groovy
index 63fe188..0b88246 100644
--- a/src/main/groovy/org/codehaus/groovy/tools/GrapeMain.groovy
+++ b/src/main/groovy/org/codehaus/groovy/tools/GrapeMain.groovy
@@ -29,44 +29,46 @@ import picocli.CommandLine.ParentCommand
 import picocli.CommandLine.RunLast
 import picocli.CommandLine.Unmatched
 
-@Command(name = "grape", description = "Allows for the inspection and management of the local grape cache.",
+@SuppressWarnings('Println')
+@Command(name = 'grape', description = 'Allows for the inspection and management of the local grape cache.',
         subcommands = [
-                Install.class,
-                Uninstall.class,
-                ListCommand.class,
-                Resolve.class,
-                picocli.CommandLine.HelpCommand.class])
+                Install,
+                Uninstall,
+                ListCommand,
+                Resolve,
+                picocli.CommandLine.HelpCommand])
 class GrapeMain implements Runnable {
-    @Option(names = ["-D", "--define"], description = "define a system property", paramLabel = "<name=value>")
-    private Map<String, String> properties = new LinkedHashMap<String, String>()
+    @Option(names = ['-D', '--define'], description = 'define a system property', paramLabel = '<name=value>')
+    private final Map<String, String> properties = new LinkedHashMap<String, String>()
 
-    @Option(names = ["-r", "--resolver"], description = "define a grab resolver (for install)", paramLabel = "<url>")
-    private List<String> resolvers = new ArrayList<String>()
+    @SuppressWarnings('UnusedPrivateField') // used in run()
+    @Option(names = ['-r', '--resolver'], description = 'define a grab resolver (for install)', paramLabel = '<url>')
+    private final List<String> resolvers = new ArrayList<String>()
 
-    @Option(names = ["-q", "--quiet"], description = "Log level 0 - only errors")
+    @Option(names = ['-q', '--quiet'], description = 'Log level 0 - only errors')
     private boolean quiet
 
-    @Option(names = ["-w", "--warn"], description = "Log level 1 - errors and warnings")
+    @Option(names = ['-w', '--warn'], description = 'Log level 1 - errors and warnings')
     private boolean warn
 
-    @Option(names = ["-i", "--info"], description = "Log level 2 - info")
+    @Option(names = ['-i', '--info'], description = 'Log level 2 - info')
     private boolean info
 
-    @Option(names = ["-V", "--verbose"], description = "Log level 3 - verbose")
+    @Option(names = ['-V', '--verbose'], description = 'Log level 3 - verbose')
     private boolean verbose
 
-    @Option(names = ["-d", "--debug"], description = "Log level 4 - debug")
+    @Option(names = ['-d', '--debug'], description = 'Log level 4 - debug')
     private boolean debug
 
     @Unmatched List<String> unmatched = new ArrayList<String>()
 
     private CommandLine parser
 
-    public static void main(String[] args) {
+    static void main(String[] args) {
         GrapeMain grape = new GrapeMain()
         def parser = new CommandLine(grape)
-        parser.addMixin("helpOptions", new HelpOptionsMixin())
-        parser.subcommands.findAll { k, v -> k != 'help' }.each { k, v -> v.addMixin("helpOptions", new HelpOptionsMixin()) }
+        parser.addMixin('helpOptions', new HelpOptionsMixin())
+        parser.subcommands.findAll { k, v -> k != 'help' }.each { k, v -> v.addMixin('helpOptions', new HelpOptionsMixin()) }
 
         grape.parser = parser
         parser.parseWithHandler(new RunLast(), args)
@@ -80,25 +82,27 @@ class GrapeMain implements Runnable {
         }
     }
 
+    @SuppressWarnings('UnusedPrivateMethod') // used in run()
     private void init() {
         properties.each { k, v ->
             System.setProperty(k, v)
         }
     }
 
+    @SuppressWarnings('UnusedPrivateMethod') // used in run()
     private void setupLogging(int defaultLevel = 2) { // = Message.MSG_INFO -> some parsing error :(
         if (quiet) {
-            Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_ERR))
+            Message.defaultLogger = new DefaultMessageLogger(Message.MSG_ERR)
         } else if (warn) {
-            Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_WARN))
+            Message.defaultLogger = new DefaultMessageLogger(Message.MSG_WARN)
         } else if (info) {
-            Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_INFO))
+            Message.defaultLogger = new DefaultMessageLogger(Message.MSG_INFO)
         } else if (verbose) {
-            Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_VERBOSE))
+            Message.defaultLogger = new DefaultMessageLogger(Message.MSG_VERBOSE)
         } else if (debug) {
-            Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_DEBUG))
+            Message.defaultLogger = new DefaultMessageLogger(Message.MSG_DEBUG)
         } else {
-            Message.setDefaultLogger(new DefaultMessageLogger(defaultLevel))
+            Message.defaultLogger = new DefaultMessageLogger(defaultLevel)
         }
     }
 
@@ -111,18 +115,18 @@ class GrapeMain implements Runnable {
     // the unix standard short option for version help is uppercase -V, while previous versions
     // of this class use lowercase -v. This custom mixin preserves option compatibility.
     @Command(versionProvider = VersionProvider, sortOptions = false,
-            parameterListHeading = "%nParameters:%n",
-            optionListHeading = "%nOptions:%n",
-            descriptionHeading = "%n")
+            parameterListHeading = '%nParameters:%n',
+            optionListHeading = '%nOptions:%n',
+            descriptionHeading = '%n')
     private static class HelpOptionsMixin {
-        @Option(names = ["-h", "--help"], usageHelp = true, description = "usage information") boolean isHelpRequested
-        @Option(names = ["-v", "--version"], versionHelp = true, description = "display the Groovy and JVM versions") boolean isVersionRequested
+        @Option(names = ['-h', '--help'], usageHelp = true, description = 'usage information') boolean isHelpRequested
+        @Option(names = ['-v', '--version'], versionHelp = true, description = 'display the Groovy and JVM versions') boolean isVersionRequested
     }
 
     private static class VersionProvider implements CommandLine.IVersionProvider {
         String[] getVersion() {
-            String version = GroovySystem.getVersion()
-            return ["Groovy Version: $version JVM: ${System.getProperty('java.version')}"]
+            String version = GroovySystem.version
+            ["Groovy Version: $version JVM: ${System.getProperty('java.version')}"]
         }
     }
 
@@ -147,7 +151,7 @@ class GrapeMain implements Runnable {
             parentCommand.init()
 
             // set the instance so we can re-set the logger
-            Grape.getInstance()
+            Grape.instance
             parentCommand.setupLogging()
 
             parentCommand.resolvers.each { String url ->
@@ -157,7 +161,7 @@ class GrapeMain implements Runnable {
             try {
                 Grape.grab(autoDownload: true, group: group, module: module, version: version, classifier: classifier, noExceptions: true)
             } catch (Exception ex) {
-                println "An error occured : $ex"
+                System.err.println "An error occured : $ex"
             }
         }
     }
@@ -171,13 +175,13 @@ class GrapeMain implements Runnable {
         void run() {
             parentCommand.init()
 
-            println ""
+            println ''
 
             int moduleCount = 0
             int versionCount = 0
 
             // set the instance so we can re-set the logger
-            Grape.getInstance()
+            Grape.instance
             parentCommand.setupLogging()
 
             Grape.enumerateGrapes().each {String groupName, Map group ->
@@ -187,14 +191,14 @@ class GrapeMain implements Runnable {
                     versionCount += versions.size()
                 }
             }
-            println ""
+            println ''
             println "$moduleCount Grape modules cached"
             println "$versionCount Grape module versions cached"
         }
     }
 
     @Command(name = 'resolve', header = 'Enumerates the jars used by a grape',
-            customSynopsis = "grape resolve [-adhisv] (<groupId> <artifactId> <version>)+",
+            customSynopsis = 'grape resolve [-adhisv] (<groupId> <artifactId> <version>)+',
             description = [
                     'Prints the file locations of the jars representing the artifcats for the specified module(s) and the respective transitive dependencies.',
                     '',
@@ -232,7 +236,7 @@ class GrapeMain implements Runnable {
             parentCommand.init()
 
             // set the instance so we can re-set the logger
-            Grape.getInstance()
+            Grape.instance
             parentCommand.setupLogging(Message.MSG_ERR)
 
             if ((args.size() % 3) != 0) {
@@ -299,8 +303,8 @@ class GrapeMain implements Runnable {
                     println 'Nothing was resolved'
                 }
             } catch (Exception e) {
-                println "Error in resolve:\n\t$e.message"
-                if (e.message =~ /unresolved dependency/) println "Perhaps the grape is not installed?"
+                System.err.println "Error in resolve:\n\t$e.message"
+                if (e.message =~ /unresolved dependency/) println 'Perhaps the grape is not installed?'
             }
         }
     }
@@ -327,7 +331,7 @@ class GrapeMain implements Runnable {
             parentCommand.init()
 
             // set the instance so we can re-set the logger
-            Grape.getInstance()
+            Grape.instance
             parentCommand.setupLogging()
 
             if (!Grape.enumerateGrapes().find {String groupName, Map g ->
diff --git a/src/main/groovy/org/codehaus/groovy/transform/ASTTestTransformation.groovy b/src/main/groovy/org/codehaus/groovy/transform/ASTTestTransformation.groovy
index 91351a0..8201d50 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/ASTTestTransformation.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/ASTTestTransformation.groovy
@@ -49,6 +49,7 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.propX
 class ASTTestTransformation extends AbstractASTTransformation implements CompilationUnitAware {
     private CompilationUnit compilationUnit
 
+    @SuppressWarnings('Instanceof')
     void visit(final ASTNode[] nodes, final SourceUnit source) {
         AnnotationNode annotationNode = nodes[0]
         def member = annotationNode.getMember('phase')
@@ -63,10 +64,10 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
         }
         member = annotationNode.getMember('value')
         if (member && !(member instanceof ClosureExpression)) {
-            throw new SyntaxException("ASTTest value must be a closure", member.getLineNumber(), member.getColumnNumber())
+            throw new SyntaxException('ASTTest value must be a closure', member.getLineNumber(), member.getColumnNumber())
         }
         if (!member && !annotationNode.getNodeMetaData(ASTTestTransformation)) {
-            throw new SyntaxException("Missing test expression", annotationNode.getLineNumber(), annotationNode.getColumnNumber())
+            throw new SyntaxException('Missing test expression', annotationNode.getLineNumber(), annotationNode.getColumnNumber())
         }
         // convert value into node metadata so that the expression doesn't mix up with other AST xforms like type checking
         annotationNode.putNodeMetaData(ASTTestTransformation, member)
@@ -74,11 +75,11 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
 
         def pcallback = compilationUnit.progressCallback
         def callback = new CompilationUnit.ProgressCallback() {
-            Binding binding = new Binding([:].withDefault {null})
+            Binding binding = new Binding([:].withDefault { null })
 
             @Override
             void call(final ProcessingUnit context, final int phaseRef) {
-                if (phase==null ||  phaseRef == phase.phaseNumber) {
+                if (phase == null || phaseRef == phase.phaseNumber) {
                     ClosureExpression testClosure = nodes[0].getNodeMetaData(ASTTestTransformation)
                     StringBuilder sb = new StringBuilder()
                     for (int i = testClosure.lineNumber; i <= testClosure.lastLineNumber; i++) {
@@ -91,7 +92,7 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
                     config.addCompilationCustomizers(customizer)
                     binding['sourceUnit'] = source
                     binding['node'] = nodes[1]
-                    binding['lookup'] = new MethodClosure(LabelFinder, "lookup").curry(nodes[1])
+                    binding['lookup'] = new MethodClosure(LabelFinder, 'lookup').curry(nodes[1])
                     binding['compilationUnit'] = compilationUnit
                     binding['compilePhase'] = CompilePhase.fromPhaseNumber(phaseRef)
 
@@ -113,16 +114,16 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
                 }
             }
         }
-        
-        if (pcallback!=null) {
+
+        if (pcallback != null) {
             if (pcallback instanceof ProgressCallbackChain) {
-                pcallback.addCallback(callback)                
+                pcallback.addCallback(callback)
             } else {
                 pcallback = new ProgressCallbackChain(pcallback, callback)
             }
             callback = pcallback
         }
-        
+
         compilationUnit.setProgressCallback(callback)
 
     }
@@ -141,28 +142,26 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
 
         @Override
         String getSample(final int line, final int column, final Janitor janitor) {
-            String sample = null;
-            String text = delegate.getLine(line, janitor);
+            String sample = null
+            String text = delegate.getLine(line, janitor)
 
             if (text != null) {
                 if (column > 0) {
-                    String marker = Utilities.repeatString(" ", column - 1) + "^";
+                    String marker = Utilities.repeatString(' ', column - 1) + '^'
 
                     if (column > 40) {
-                        int start = column - 30 - 1;
-                        int end = (column + 10 > text.length() ? text.length() : column + 10 - 1);
-                        sample = "   " + text.substring(start, end) + Utilities.eol() + "   " +
-                                marker.substring(start, marker.length());
+                        int start = column - 30 - 1
+                        int end = (column + 10 > text.length() ? text.length() : column + 10 - 1)
+                        sample = '   ' + text.substring(start, end) + Utilities.eol() + '   ' +
+                                marker.substring(start, marker.length())
                     } else {
-                        sample = "   " + text + Utilities.eol() + "   " + marker;
+                        sample = '   ' + text + Utilities.eol() + '   ' + marker
                     }
                 } else {
-                    sample = text;
+                    sample = text
                 }
             }
-
-            return sample;
-
+            sample
         }
 
     }
@@ -177,7 +176,7 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
             }
         }
 
-        public void addCallback(CompilationUnit.ProgressCallback callback) {
+        void addCallback(CompilationUnit.ProgressCallback callback) {
             chain << callback
         }
         
@@ -187,16 +186,16 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
         }
     }
 
-    public static class LabelFinder extends ClassCodeVisitorSupport {
+    static class LabelFinder extends ClassCodeVisitorSupport {
 
-        public static List<Statement> lookup(MethodNode node, String label) {
+        static List<Statement> lookup(MethodNode node, String label) {
             LabelFinder finder = new LabelFinder(label, null)
             node.code.visit(finder)
 
             finder.targets
         }
 
-        public static List<Statement> lookup(ClassNode node, String label) {
+        static List<Statement> lookup(ClassNode node, String label) {
             LabelFinder finder = new LabelFinder(label, null)
             node.methods*.code*.visit(finder)
             node.declaredConstructors*.code*.visit(finder)
@@ -207,11 +206,11 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
         private final String label
         private final SourceUnit unit
 
-        private final List<Statement> targets = new LinkedList<Statement>();
+        private final List<Statement> targets = new LinkedList<Statement>()
 
         LabelFinder(final String label, final SourceUnit unit) {
             this.label = label
-            this.unit = unit;
+            this.unit = unit
         }
 
         @Override
@@ -226,7 +225,7 @@ class ASTTestTransformation extends AbstractASTTransformation implements Compila
         }
 
         List<Statement> getTargets() {
-            return Collections.unmodifiableList(targets)
+            Collections.unmodifiableList(targets)
         }
     }
 
diff --git a/src/main/groovy/org/codehaus/groovy/transform/ConditionalInterruptibleASTTransformation.groovy b/src/main/groovy/org/codehaus/groovy/transform/ConditionalInterruptibleASTTransformation.groovy
index e634c5e..dd97512 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/ConditionalInterruptibleASTTransformation.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/ConditionalInterruptibleASTTransformation.groovy
@@ -40,103 +40,103 @@ import org.codehaus.groovy.control.CompilePhase
  * check on loops (for, while, do) and first statement of closures. By default, also adds an interrupt check
  * statement on the beginning of method calls.
  *
- * @see groovy.transform.ConditionalInterrupt
- * @since 1.8.0
+ * @see groovy.transform.ConditionalInterrupt* @since 1.8.0
  */
 @GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
-public class ConditionalInterruptibleASTTransformation extends AbstractInterruptibleASTTransformation {
+class ConditionalInterruptibleASTTransformation extends AbstractInterruptibleASTTransformation {
 
-  private static final ClassNode MY_TYPE = ClassHelper.make(ConditionalInterrupt)
+    private static final ClassNode MY_TYPE = ClassHelper.make(ConditionalInterrupt)
 
-  private ClosureExpression conditionNode
-  private String conditionMethod
-  private MethodCallExpression conditionCallExpression
-  private ClassNode currentClass
+    private ClosureExpression conditionNode
+    private String conditionMethod
+    private MethodCallExpression conditionCallExpression
+    private ClassNode currentClass
 
-  protected ClassNode type() {
-    return MY_TYPE
-  }
+    protected ClassNode type() {
+        MY_TYPE
+    }
 
-  protected void setupTransform(AnnotationNode node) {
-    super.setupTransform(node)
-    def member = node.getMember("value")
-    if (!member || !(member instanceof ClosureExpression)) internalError("Expected closure value for annotation parameter 'value'. Found $member")
-    conditionNode = member;
-    conditionMethod = 'conditionalTransform' + node.hashCode() + '$condition'
-    conditionCallExpression = new MethodCallExpression(new VariableExpression('this'), conditionMethod, new ArgumentListExpression())
-  }
+    @SuppressWarnings('Instanceof')
+    protected void setupTransform(AnnotationNode node) {
+        super.setupTransform(node)
+        def member = node.getMember('value')
+        if (!member || !(member instanceof ClosureExpression)) internalError("Expected closure value for annotation parameter 'value'. Found $member")
+        conditionNode = member
+        conditionMethod = 'conditionalTransform' + node.hashCode() + '$condition'
+        conditionCallExpression = new MethodCallExpression(new VariableExpression('this'), conditionMethod, new ArgumentListExpression())
+    }
 
-  protected String getErrorMessage() {
-    'Execution interrupted. The following condition failed: ' + convertClosureToSource(conditionNode)
-  }
+    protected String getErrorMessage() {
+        'Execution interrupted. The following condition failed: ' + convertClosureToSource(conditionNode)
+    }
 
-  void visitClass(ClassNode type) {
-    currentClass = type
-    def method = type.addMethod(conditionMethod, ACC_PRIVATE | ACC_SYNTHETIC, ClassHelper.OBJECT_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, conditionNode.code)
-    method.synthetic = true
-    if (applyToAllMembers) {
-      super.visitClass(type)
+    void visitClass(ClassNode type) {
+        currentClass = type
+        def method = type.addMethod(conditionMethod, ACC_PRIVATE | ACC_SYNTHETIC, ClassHelper.OBJECT_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, conditionNode.code)
+        method.synthetic = true
+        if (applyToAllMembers) {
+            super.visitClass(type)
+        }
     }
-  }
 
-  protected Expression createCondition() {
-    conditionCallExpression
-  }
+    protected Expression createCondition() {
+        conditionCallExpression
+    }
 
-  @Override
-  void visitAnnotations(AnnotatedNode node) {
-    // this transformation does not apply on annotation nodes
-    // visiting could lead to stack overflows
-  }
+    @Override
+    void visitAnnotations(AnnotatedNode node) {
+        // this transformation does not apply on annotation nodes
+        // visiting could lead to stack overflows
+    }
 
-  @Override
-  void visitField(FieldNode node) {
-    if (!node.isStatic() && !node.isSynthetic()) {
-      super.visitField node
+    @Override
+    void visitField(FieldNode node) {
+        if (!node.isStatic() && !node.isSynthetic()) {
+            super.visitField node
+        }
     }
-  }
 
-  @Override
-  void visitProperty(PropertyNode node) {
-    if (!node.isStatic() && !node.isSynthetic()) {
-      super.visitProperty node
+    @Override
+    void visitProperty(PropertyNode node) {
+        if (!node.isStatic() && !node.isSynthetic()) {
+            super.visitProperty node
+        }
     }
-  }
 
-  @Override
-  void visitClosureExpression(ClosureExpression closureExpr) {
-    if (closureExpr == conditionNode) return // do not visit the closure from the annotation itself
-    def code = closureExpr.code
-    closureExpr.code = wrapBlock(code)
-    super.visitClosureExpression closureExpr
-  }
+    @Override
+    void visitClosureExpression(ClosureExpression closureExpr) {
+        if (closureExpr == conditionNode) return // do not visit the closure from the annotation itself
+        def code = closureExpr.code
+        closureExpr.code = wrapBlock(code)
+        super.visitClosureExpression closureExpr
+    }
 
-  @Override
-  void visitMethod(MethodNode node) {
-    if (node.name == conditionMethod && !node.isSynthetic()) return // do not visit the generated method
-    if (node.name == 'run' && currentClass.isScript() && node.parameters.length == 0) {
-      // the run() method should not have the statement added, otherwise the script binding won't be set before
-      // the condition is actually tested
-      super.visitMethod(node)
-    } else {
-      if (checkOnMethodStart && !node.isSynthetic() && !node.isStatic() && !node.isAbstract()) {
-        def code = node.code
-        node.code = wrapBlock(code);
-      }
-      if (!node.isSynthetic() && !node.isStatic()) super.visitMethod(node)
+    @Override
+    void visitMethod(MethodNode node) {
+        if (node.name == conditionMethod && !node.isSynthetic()) return // do not visit the generated method
+        if (node.name == 'run' && currentClass.isScript() && node.parameters.length == 0) {
+            // the run() method should not have the statement added, otherwise the script binding won't be set before
+            // the condition is actually tested
+            super.visitMethod(node)
+        } else {
+            if (checkOnMethodStart && !node.isSynthetic() && !node.isStatic() && !node.isAbstract()) {
+                def code = node.code
+                node.code = wrapBlock(code)
+            }
+            if (!node.isSynthetic() && !node.isStatic()) super.visitMethod(node)
+        }
     }
-  }
 
-  /**
-   * Converts a ClosureExpression into the String source.
-   * @param expression a closure
-   * @return the source the closure was created from
-   */
-  private String convertClosureToSource(ClosureExpression expression) {
-    try {
-        return ClosureUtils.convertClosureToSource(this.source.source, expression);
-    } catch(Exception e) {
-        return e.message
+    /**
+     * Converts a ClosureExpression into the String source.
+     * @param expression a closure
+     * @return the source the closure was created from
+     */
+    private String convertClosureToSource(ClosureExpression expression) {
+        try {
+            return ClosureUtils.convertClosureToSource(this.source.source, expression)
+        } catch (Exception e) {
+            return e.message
+        }
     }
-  }
 }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy b/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
index 74f1c01..459a94b 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
@@ -41,7 +41,7 @@ import org.codehaus.groovy.control.CompilePhase
  */
 @GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
 @CompileStatic
-public class ThreadInterruptibleASTTransformation extends AbstractInterruptibleASTTransformation {
+class ThreadInterruptibleASTTransformation extends AbstractInterruptibleASTTransformation {
 
     private static final ClassNode MY_TYPE = ClassHelper.make(ThreadInterrupt)
     private static final ClassNode THREAD_TYPE = ClassHelper.make(Thread)
@@ -54,7 +54,7 @@ public class ThreadInterruptibleASTTransformation extends AbstractInterruptibleA
     }
 
     protected ClassNode type() {
-        return MY_TYPE;
+        MY_TYPE
     }
 
     protected String getErrorMessage() {
@@ -77,17 +77,17 @@ public class ThreadInterruptibleASTTransformation extends AbstractInterruptibleA
 
 
     @Override
-    public void visitClosureExpression(ClosureExpression closureExpr) {
+    void visitClosureExpression(ClosureExpression closureExpr) {
         def code = closureExpr.code
         closureExpr.code = wrapBlock(code)
         super.visitClosureExpression closureExpr
     }
 
     @Override
-    public void visitMethod(MethodNode node) {
+    void visitMethod(MethodNode node) {
         if (checkOnMethodStart && !node.isSynthetic() && !node.isAbstract()) {
             def code = node.code
-            node.code = wrapBlock(code);
+            node.code = wrapBlock(code)
         }
         super.visitMethod(node)
     }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/TimedInterruptibleASTTransformation.groovy b/src/main/groovy/org/codehaus/groovy/transform/TimedInterruptibleASTTransformation.groovy
index 5060dba..786fad9 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/TimedInterruptibleASTTransformation.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/TimedInterruptibleASTTransformation.groovy
@@ -64,16 +64,17 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.varX
  * @since 1.8.0
  */
 @GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
-public class TimedInterruptibleASTTransformation extends AbstractASTTransformation {
+class TimedInterruptibleASTTransformation extends AbstractASTTransformation {
 
     private static final ClassNode MY_TYPE = make(TimedInterrupt)
     private static final String CHECK_METHOD_START_MEMBER = 'checkOnMethodStart'
     private static final String APPLY_TO_ALL_CLASSES = 'applyToAllClasses'
     private static final String APPLY_TO_ALL_MEMBERS = 'applyToAllMembers'
-    private static final String THROWN_EXCEPTION_TYPE = "thrown"
+    private static final String THROWN_EXCEPTION_TYPE = 'thrown'
 
-    public void visit(ASTNode[] nodes, SourceUnit source) {
-        init(nodes, source);
+    @SuppressWarnings('Instanceof')
+    void visit(ASTNode[] nodes, SourceUnit source) {
+        init(nodes, source)
         AnnotationNode node = nodes[0]
         AnnotatedNode annotatedNode = nodes[1]
         if (!MY_TYPE.equals(node.getClassNode())) {
@@ -126,7 +127,8 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
         }
     }
 
-    static def getConstantAnnotationParameter(AnnotationNode node, String parameterName, Class type, defaultValue) {
+    @SuppressWarnings('Instanceof')
+    static getConstantAnnotationParameter(AnnotationNode node, String parameterName, Class type, defaultValue) {
         def member = node.getMember(parameterName)
         if (member) {
             if (member instanceof ConstantExpression) {
@@ -140,7 +142,7 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
                 internalError("Expecting boolean value for ${parameterName} annotation parameter. Found $member")
             }
         }
-        return defaultValue
+        defaultValue
     }
 
     private static void internalError(String message) {
@@ -159,6 +161,7 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
         private final ClassNode thrown
         private final String basename
 
+        @SuppressWarnings('ParameterCount')
         TimedInterruptionVisitor(source, checkOnMethodStart, applyToAllClasses, applyToAllMembers, maximum, unit, thrown, hash) {
             this.source = source
             this.checkOnMethodStart = checkOnMethodStart
@@ -177,7 +180,7 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
             ifS(
 
                     ltX(
-                            propX(varX("this"), basename + '$expireTime'),
+                            propX(varX('this'), basename + '$expireTime'),
                             callX(make(System), 'nanoTime')
                     ),
                     throwS(
@@ -190,7 +193,7 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
                                                     ),
                                                     plusX(
                                                             constX('. Start time: '),
-                                                            propX(varX("this"), basename + '$startTime')
+                                                            propX(varX('this'), basename + '$startTime')
                                                     )
                                             )
 
@@ -207,9 +210,9 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
          * second one the statement to be wrapped.
          */
         private wrapBlock(statement) {
-            def stmt = new BlockStatement();
-            stmt.addStatement(createInterruptStatement());
-            stmt.addStatement(statement);
+            def stmt = new BlockStatement()
+            stmt.addStatement(createInterruptStatement())
+            stmt.addStatement(statement)
             stmt
         }
 
@@ -249,6 +252,7 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
         }
 
         @Override
+        @SuppressWarnings('Instanceof')
         void visitClosureExpression(ClosureExpression closureExpr) {
             def code = closureExpr.code
             if (code instanceof BlockStatement) {
@@ -304,7 +308,7 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
         void visitMethod(MethodNode node) {
             if (checkOnMethodStart && !node.isSynthetic() && !node.isStatic() && !node.isAbstract()) {
                 def code = node.code
-                node.code = wrapBlock(code);
+                node.code = wrapBlock(code)
             }
             if (!node.isSynthetic() && !node.isStatic()) {
                 super.visitMethod(node)
@@ -312,7 +316,7 @@ public class TimedInterruptibleASTTransformation extends AbstractASTTransformati
         }
 
         protected SourceUnit getSourceUnit() {
-            return source;
+            source
         }
     }
 }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/AstHelper.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/AstHelper.groovy
index 15f112f..35cf13f 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/AstHelper.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/AstHelper.groovy
@@ -25,7 +25,6 @@ import org.codehaus.groovy.ast.expr.VariableExpression
 import org.codehaus.groovy.ast.stmt.ContinueStatement
 import org.codehaus.groovy.ast.stmt.ExpressionStatement
 import org.codehaus.groovy.ast.stmt.Statement
-import org.codehaus.groovy.ast.stmt.ThrowStatement
 
 import java.lang.reflect.Modifier
 
@@ -33,6 +32,7 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.classX
 import static org.codehaus.groovy.ast.tools.GeneralUtils.declS
 import static org.codehaus.groovy.ast.tools.GeneralUtils.localVarX
 import static org.codehaus.groovy.ast.tools.GeneralUtils.propX
+import static org.codehaus.groovy.ast.tools.GeneralUtils.throwS
 import static org.codehaus.groovy.ast.tools.GeneralUtils.varX
 
 /**
@@ -40,16 +40,16 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.varX
  */
 @CompileStatic
 class AstHelper {
-	static ExpressionStatement createVariableDefinition(String variableName, ClassNode variableType, Expression value, boolean variableShouldBeFinal = false ) {
+    static ExpressionStatement createVariableDefinition(String variableName, ClassNode variableType, Expression value, boolean variableShouldBeFinal = false) {
         def newVariable = localVarX(variableName, variableType)
         if (variableShouldBeFinal)
-            newVariable.setModifiers(Modifier.FINAL)
+            newVariable.modifiers = Modifier.FINAL
         (ExpressionStatement) declS(newVariable, value)
-	}
+    }
 
-	static ExpressionStatement createVariableAlias(String aliasName, ClassNode variableType, String variableName ) {
-		createVariableDefinition(aliasName, variableType, varX(variableName, variableType))
-	}
+    static ExpressionStatement createVariableAlias(String aliasName, ClassNode variableType, String variableName) {
+        createVariableDefinition(aliasName, variableType, varX(variableName, variableType))
+    }
 
     static VariableExpression createVariableReference(Map variableSpec) {
         varX((String) variableSpec.name, (ClassNode) variableSpec.type)
@@ -70,6 +70,6 @@ class AstHelper {
      */
     static Statement recurByThrowStatement() {
         // throw InWhileLoopWrapper.LOOP_EXCEPTION
-        new ThrowStatement(propX(classX(InWhileLoopWrapper), 'LOOP_EXCEPTION'))
+        throwS(propX(classX(InWhileLoopWrapper), 'LOOP_EXCEPTION'))
     }
 }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/CollectRecursiveCalls.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/CollectRecursiveCalls.groovy
index e6a40a4..3f586d8 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/CollectRecursiveCalls.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/CollectRecursiveCalls.groovy
@@ -23,7 +23,7 @@ import org.codehaus.groovy.ast.CodeVisitorSupport
 import org.codehaus.groovy.ast.MethodNode
 import org.codehaus.groovy.ast.expr.Expression
 import org.codehaus.groovy.ast.expr.MethodCallExpression
-import org.codehaus.groovy.ast.expr.StaticMethodCallExpression;
+import org.codehaus.groovy.ast.expr.StaticMethodCallExpression
 
 /**
  * Collect all recursive calls within method
@@ -33,14 +33,14 @@ class CollectRecursiveCalls extends CodeVisitorSupport {
 	MethodNode method
 	List<Expression> recursiveCalls = []
 
-	public void visitMethodCallExpression(MethodCallExpression call) {
+	void visitMethodCallExpression(MethodCallExpression call) {
 		if (isRecursive(call)) {
 			recursiveCalls << call
 		}
         super.visitMethodCallExpression(call)
     }
 
-	public void visitStaticMethodCallExpression(StaticMethodCallExpression call) {
+	void visitStaticMethodCallExpression(StaticMethodCallExpression call) {
 		if (isRecursive(call)) {
             recursiveCalls << call
         }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/InWhileLoopWrapper.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/InWhileLoopWrapper.groovy
index 5f37bbf..fb66a89 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/InWhileLoopWrapper.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/InWhileLoopWrapper.groovy
@@ -33,21 +33,25 @@ import org.codehaus.groovy.ast.stmt.Statement
 import org.codehaus.groovy.ast.stmt.TryCatchStatement
 import org.codehaus.groovy.ast.stmt.WhileStatement
 
+import static org.codehaus.groovy.ast.tools.GeneralUtils.block
+import static org.codehaus.groovy.ast.tools.GeneralUtils.boolX
+import static org.codehaus.groovy.ast.tools.GeneralUtils.constX
+import static org.codehaus.groovy.ast.tools.GeneralUtils.param
+
 /**
  * Wrap the body of a method in a while loop, nested in a try-catch.
  * This is the first step in making a tail recursive method iterative.
  *
  * There are two ways to invoke the next iteration step:
  * <ol>
- * <li>"continue _RECURE_HERE_" is used by recursive calls outside of closures</li>
+ * <li>"continue _RECUR_HERE_" is used by recursive calls outside of closures</li>
  * <li>"throw LOOP_EXCEPTION" is used by recursive calls within closures b/c you cannot invoke "continue" from there</li>
  * </ol>
  */
 @CompileStatic
 class InWhileLoopWrapper {
-	
 	static final String LOOP_LABEL = '_RECUR_HERE_'
-    static final GotoRecurHereException  LOOP_EXCEPTION = new GotoRecurHereException()
+    static final GotoRecurHereException LOOP_EXCEPTION = new GotoRecurHereException()
 
 	void wrap(MethodNode method) {
 		BlockStatement oldBody = method.code as BlockStatement
@@ -56,18 +60,18 @@ class InWhileLoopWrapper {
                 EmptyStatement.INSTANCE
         )
         tryCatchStatement.addCatch(new CatchStatement(
-                new Parameter(ClassHelper.make(GotoRecurHereException), 'ignore'),
+                param(ClassHelper.make(GotoRecurHereException), 'ignore'),
                 new ContinueStatement(InWhileLoopWrapper.LOOP_LABEL)
         ))
 
         WhileStatement whileLoop = new WhileStatement(
-                new BooleanExpression(new ConstantExpression(true)),
-                new BlockStatement([tryCatchStatement] as List<Statement>, new VariableScope(method.variableScope))
+                boolX(constX(true)),
+                block(new VariableScope(method.variableScope), tryCatchStatement)
         )
         List<Statement> whileLoopStatements = ((BlockStatement) whileLoop.loopBlock).statements
         if (whileLoopStatements.size() > 0)
             whileLoopStatements[0].statementLabel = LOOP_LABEL
-		BlockStatement newBody = new BlockStatement([] as List<Statement>, new VariableScope(method.variableScope))
+		BlockStatement newBody = block(new VariableScope(method.variableScope))
 		newBody.addStatement(whileLoop)
 		method.code = newBody
 	}
@@ -76,6 +80,6 @@ class InWhileLoopWrapper {
 /**
  * Exception will be thrown by recursive calls in closures and caught in while loop to continue to LOOP_LABEL
  */
-class GotoRecurHereException extends Throwable {
+class GotoRecurHereException extends Exception {
 
 }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/RecursivenessTester.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/RecursivenessTester.groovy
index 2255283..15e24e4 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/RecursivenessTester.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/RecursivenessTester.groovy
@@ -46,6 +46,7 @@ class RecursivenessTester {
 		isRecursive(params.method, params.call)
 	}
 
+    @SuppressWarnings('Instanceof')
 	boolean isRecursive(MethodNode method, MethodCallExpression call) {
 		if (!isCallToThis(call))
 			return false
@@ -67,21 +68,22 @@ class RecursivenessTester {
         methodParamsMatchCallArgs(method, call)
     }
 
+    @SuppressWarnings('Instanceof')
 	private boolean isCallToThis(MethodCallExpression call) {
 		if (call.objectExpression == null)
 			return call.isImplicitThis()
         if (! (call.objectExpression instanceof VariableExpression)) {
             return false
         }
-		return call.objectExpression.isThisExpression()
+		call.objectExpression.isThisExpression()
 	}
 	
 	private boolean methodParamsMatchCallArgs(method, call) {
         if (method.parameters.size() != call.arguments.expressions.size())
             return false
         def classNodePairs = [method.parameters*.type, call.arguments*.type].transpose()
-        return classNodePairs.every { ClassNode paramType, ClassNode argType  ->
-            return areTypesCallCompatible(argType, paramType)
+        classNodePairs.every { ClassNode paramType, ClassNode argType  ->
+            areTypesCallCompatible(argType, paramType)
         }
 	}
 
@@ -93,7 +95,7 @@ class RecursivenessTester {
     private areTypesCallCompatible(ClassNode argType, ClassNode paramType) {
         ClassNode boxedArg = ClassHelper.getWrapper(argType)
         ClassNode boxedParam = ClassHelper.getWrapper(paramType)
-        return boxedArg.isDerivedFrom(boxedParam) || boxedParam.isDerivedFrom(boxedArg)
+        boxedArg.isDerivedFrom(boxedParam) || boxedParam.isDerivedFrom(boxedArg)
     }
 
 }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/ReturnAdderForClosures.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/ReturnAdderForClosures.groovy
index a590660..62c4aa9 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/ReturnAdderForClosures.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/ReturnAdderForClosures.groovy
@@ -38,8 +38,8 @@ class ReturnAdderForClosures extends CodeVisitorSupport {
 
     void visitClosureExpression(ClosureExpression expression) {
         //Create a dummy method with the closure's code as the method's code. Then user ReturnAdder, which only works for methods.
-        MethodNode node = new MethodNode("dummy", 0, ClassHelper.OBJECT_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, expression.code);
-        new ReturnAdder().visitMethod(node);
+        MethodNode node = new MethodNode('dummy', 0, ClassHelper.OBJECT_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, expression.code)
+        new ReturnAdder().visitMethod(node)
         super.visitClosureExpression(expression)
     }
 
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/ReturnStatementToIterationConverter.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/ReturnStatementToIterationConverter.groovy
index 1fb165f..6ef233e 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/ReturnStatementToIterationConverter.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/ReturnStatementToIterationConverter.groovy
@@ -86,7 +86,7 @@ class ReturnStatementToIterationConverter {
         }
         result.addStatement(recurStatement)
 
-        return result
+        result
     }
 
     private ExpressionStatement createAssignmentToIterationVariable(Expression expression, int index, Map<Integer, Map> positionMapping) {
@@ -103,9 +103,10 @@ class ReturnStatementToIterationConverter {
         ExpressionStatement tempDeclaration = AstHelper.createVariableAlias(tempName, argAndTempType, argName)
         tempMapping[argName] = [name: tempName, type: argAndTempType]
         tempDeclarations[tempName] = tempDeclaration
-        return tempDeclaration
+        tempDeclaration
     }
 
+    @SuppressWarnings('Instanceof')
     private List<Expression> getArguments(Expression recursiveCall) {
         if (recursiveCall instanceof MethodCallExpression)
             return ((TupleExpression) ((MethodCallExpression) recursiveCall).arguments).expressions
@@ -124,7 +125,7 @@ class ReturnStatementToIterationConverter {
             replaceArgUsageByTempUsage((BinaryExpression) statement.expression, tempMapping, tracker)
         }
         unusedTempNames = unusedTempNames - tracker.usedVariableNames
-        return unusedTempNames
+        unusedTempNames
     }
 
     private void replaceArgUsageByTempUsage(BinaryExpression binary, Map tempMapping, UsedVariableTracker tracker) {
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/StatementReplacer.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/StatementReplacer.groovy
index 3d16c9c..8c7a55a 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/StatementReplacer.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/StatementReplacer.groovy
@@ -59,36 +59,36 @@ class StatementReplacer extends CodeVisitorSupport {
         copyOfStatements.eachWithIndex { Statement statement, int index ->
             replaceIfNecessary(statement) { Statement node -> block.statements[index] = node }
         }
-        super.visitBlockStatement(block);
+        super.visitBlockStatement(block)
     }
 
     void visitIfElse(IfStatement ifElse) {
         replaceIfNecessary(ifElse.ifBlock) { Statement s -> ifElse.ifBlock = s }
         replaceIfNecessary(ifElse.elseBlock) { Statement s -> ifElse.elseBlock = s }
-        super.visitIfElse(ifElse);
+        super.visitIfElse(ifElse)
     }
 
     void visitForLoop(ForStatement forLoop) {
         replaceIfNecessary(forLoop.loopBlock) { Statement s -> forLoop.loopBlock = s }
-        super.visitForLoop(forLoop);
+        super.visitForLoop(forLoop)
     }
 
     void visitWhileLoop(WhileStatement loop) {
         replaceIfNecessary(loop.loopBlock) { Statement s -> loop.loopBlock = s }
-        super.visitWhileLoop(loop);
+        super.visitWhileLoop(loop)
     }
 
     void visitDoWhileLoop(DoWhileStatement loop) {
         replaceIfNecessary(loop.loopBlock) { Statement s -> loop.loopBlock = s }
-        super.visitDoWhileLoop(loop);
+        super.visitDoWhileLoop(loop)
     }
 
 
     private void replaceIfNecessary(Statement nodeToCheck, Closure replacementCode) {
         if (conditionFulfilled(nodeToCheck)) {
             ASTNode replacement = replaceWith(nodeToCheck)
-            replacement.setSourcePosition(nodeToCheck);
-            replacement.copyNodeMetaData(nodeToCheck);
+            replacement.sourcePosition = nodeToCheck
+            replacement.copyNodeMetaData(nodeToCheck)
             replacementCode(replacement)
         }
     }
@@ -96,8 +96,7 @@ class StatementReplacer extends CodeVisitorSupport {
     private boolean conditionFulfilled(ASTNode nodeToCheck) {
         if (when.maximumNumberOfParameters < 2)
             return when(nodeToCheck)
-        else
-            return when(nodeToCheck, isInClosure())
+        when(nodeToCheck, isInClosure())
     }
 
     private boolean isInClosure() {
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/TailRecursiveASTTransformation.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/TailRecursiveASTTransformation.groovy
index ee62a92..05a15e6 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/TailRecursiveASTTransformation.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/TailRecursiveASTTransformation.groovy
@@ -51,7 +51,7 @@ import org.codehaus.groovy.transform.GroovyASTTransformation
 @GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS)
 class TailRecursiveASTTransformation extends AbstractASTTransformation {
 
-    private static final Class MY_CLASS = TailRecursive.class
+    private static final Class MY_CLASS = TailRecursive
     private static final ClassNode MY_TYPE = new ClassNode(MY_CLASS)
     static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage()
     private HasRecursiveCalls hasRecursiveCalls = new HasRecursiveCalls()
@@ -99,13 +99,13 @@ class TailRecursiveASTTransformation extends AbstractASTTransformation {
 
     private void transformToIteration(MethodNode method, SourceUnit source) {
         if (method.isVoidMethod()) {
-            transformVoidMethodToIteration(method, source)
+            transformVoidMethodToIteration(method)
         } else {
             transformNonVoidMethodToIteration(method, source)
         }
     }
 
-    private void transformVoidMethodToIteration(MethodNode method, SourceUnit source) {
+    private void transformVoidMethodToIteration(MethodNode method) {
         addError("Void methods are not supported by @TailRecursive yet.", method)
     }
 
@@ -127,6 +127,7 @@ class TailRecursiveASTTransformation extends AbstractASTTransformation {
         new VariableScopeVisitor(source).visitClass(method.declaringClass)
     }
 
+    @SuppressWarnings('Instanceof')
     private void replaceReturnsWithTernariesToIfStatements(MethodNode method) {
         Closure<Boolean> whenReturnWithTernary = { ASTNode node ->
             if (!(node instanceof ReturnStatement)) {
@@ -190,6 +191,7 @@ class TailRecursiveASTTransformation extends AbstractASTTransformation {
         replaceRecursiveReturnsInsideClosures(method, positionMapping)
     }
 
+    @SuppressWarnings('Instanceof')
     private void replaceRecursiveReturnsOutsideClosures(MethodNode method, Map<Integer, Map> positionMapping) {
         Closure<Boolean> whenRecursiveReturn = { Statement statement, boolean inClosure ->
             if (inClosure)
@@ -210,6 +212,7 @@ class TailRecursiveASTTransformation extends AbstractASTTransformation {
         replacer.replaceIn(method.code)
     }
 
+    @SuppressWarnings('Instanceof')
     private void replaceRecursiveReturnsInsideClosures(MethodNode method, Map<Integer, Map> positionMapping) {
         Closure<Boolean> whenRecursiveReturn = { Statement statement, boolean inClosure ->
             if (!inClosure)
@@ -250,6 +253,7 @@ class TailRecursiveASTTransformation extends AbstractASTTransformation {
         hasRecursiveCalls.test(method)
     }
 
+    @SuppressWarnings('Instanceof')
     private boolean isRecursiveIn(Expression methodCall, MethodNode method) {
         if (methodCall instanceof MethodCallExpression)
             return new RecursivenessTester().isRecursive(method, (MethodCallExpression) methodCall)
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/TernaryToIfStatementConverter.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/TernaryToIfStatementConverter.groovy
index cbfc22a..012a7c7 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/TernaryToIfStatementConverter.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/TernaryToIfStatementConverter.groovy
@@ -24,6 +24,8 @@ import org.codehaus.groovy.ast.stmt.IfStatement
 import org.codehaus.groovy.ast.stmt.ReturnStatement
 import org.codehaus.groovy.ast.stmt.Statement
 
+import static org.codehaus.groovy.ast.tools.GeneralUtils.ifElseS
+
 /**
  * Since a ternary statement has more than one exit point tail-recursiveness testing cannot be easily done.
  * Therefore this class translates a ternary statement (or Elvis operator) into the equivalent if-else statement.
@@ -31,10 +33,11 @@ import org.codehaus.groovy.ast.stmt.Statement
 @CompileStatic
 class TernaryToIfStatementConverter {
 
+    @SuppressWarnings('Instanceof')
     Statement convert(ReturnStatement statementWithInnerTernaryExpression) {
         if (!(statementWithInnerTernaryExpression.expression instanceof TernaryExpression))
             return statementWithInnerTernaryExpression
         TernaryExpression ternary = statementWithInnerTernaryExpression.expression as TernaryExpression
-        return new IfStatement(ternary.booleanExpression, new ReturnStatement(ternary.trueExpression), new ReturnStatement(ternary.falseExpression))
+        ifElseS(ternary.booleanExpression, new ReturnStatement(ternary.trueExpression), new ReturnStatement(ternary.falseExpression))
     }
 }
\ No newline at end of file
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableAccessReplacer.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableAccessReplacer.groovy
index cd9123e..115464e 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableAccessReplacer.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableAccessReplacer.groovy
@@ -45,13 +45,13 @@ class VariableAccessReplacer {
 
     void replaceIn(ASTNode root) {
         Closure<Boolean> whenParam = { VariableExpression expr ->
-            return nameAndTypeMapping.containsKey(expr.name)
+            nameAndTypeMapping.containsKey(expr.name)
         }
         Closure<VariableExpression> replaceWithLocalVariable = { VariableExpression expr ->
             Map nameAndType = nameAndTypeMapping[expr.name]
             VariableExpression newVar = AstHelper.createVariableReference(nameAndType)
             listener.variableReplaced(expr, newVar)
-            return newVar
+            newVar
         }
         new VariableExpressionReplacer(when: whenParam, replaceWith: replaceWithLocalVariable).replaceIn(root)
     }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableExpressionReplacer.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableExpressionReplacer.groovy
index 8c7bb1c..ea2d601 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableExpressionReplacer.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableExpressionReplacer.groovy
@@ -84,7 +84,7 @@ class VariableExpressionReplacer extends CodeVisitorSupport {
     void visitBinaryExpression(BinaryExpression expression) {
         //A hack: Only replace right expression b/c ReturnStatementToIterationConverter needs it that way :-/
         replaceExpressionPropertyWhenNecessary(expression, 'rightExpression')
-        expression.getRightExpression().visit(this)
+        expression.rightExpression.visit(this)
         super.visitBinaryExpression(expression)
     }
 
@@ -129,7 +129,8 @@ class VariableExpressionReplacer extends CodeVisitorSupport {
         super.visitSynchronizedStatement(statement)
     }
 
-    private void replaceExpressionPropertyWhenNecessary(ASTNode node, String propName = "expression", Class propClass = Expression) {
+    @SuppressWarnings('Instanceof')
+    private void replaceExpressionPropertyWhenNecessary(ASTNode node, String propName = 'expression', Class propClass = Expression) {
         Expression expr = getExpression(node, propName)
 
         if (expr instanceof VariableExpression) {
@@ -147,7 +148,7 @@ class VariableExpressionReplacer extends CodeVisitorSupport {
         //Use reflection to enable CompileStatic
         String setterName = 'set' + capitalizeFirst(propName)
         Method setExpressionMethod = node.class.getMethod(setterName, [propClass].toArray(new Class[1]))
-        newExpr.setSourcePosition(oldExpr)
+        newExpr.sourcePosition = oldExpr
         newExpr.copyNodeMetaData(oldExpr)
         setExpressionMethod.invoke(node, [newExpr].toArray())
     }
diff --git a/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableExpressionTransformer.groovy b/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableExpressionTransformer.groovy
index fea8d9d..9683bc9 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableExpressionTransformer.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/tailrec/VariableExpressionTransformer.groovy
@@ -33,13 +33,14 @@ class VariableExpressionTransformer implements ExpressionTransformer {
     Closure<VariableExpression> replaceWith
 
     @Override
+    @SuppressWarnings('Instanceof')
     Expression transform(Expression expr) {
         if ((expr instanceof VariableExpression) && when(expr)) {
             VariableExpression newExpr = replaceWith(expr)
-            newExpr.setSourcePosition(expr);
-            newExpr.copyNodeMetaData(expr);
+            newExpr.sourcePosition = expr
+            newExpr.copyNodeMetaData(expr)
             return newExpr
         }
-        return expr.transformExpression(this)
+        expr.transformExpression(this)
     }
 }


Mime
View raw message