CodeNarc Report

Report title:Gradle-1.0-milestone-1
Date:Mar 5, 2011 10:23:49 PM
Generated with:CodeNarc v0.13

Summary by Package

PackageTotal FilesFiles with ViolationsPriority 1Priority 2Priority 3
All Packages11346-12733
src/org/gradle/api/internal11-1-
src/org/gradle/api/internal/artifacts/dsl11-11
src/org/gradle/api/internal/artifacts/dsl/dependencies21-11
src/org/gradle/api/internal/artifacts/publish/maven/deploy/groovy1----
src/org/gradle/api/internal/file41-1-
src/org/gradle/api/internal/plugins11--1
src/org/gradle/api/internal/project32-44
src/org/gradle/api/internal/tasks/compile32-2-
src/org/gradle/api/internal/tasks/scala11-1-
src/org/gradle/api/internal/tasks/testing/junit/report42-17-
src/org/gradle/api/plugins74-91
src/org/gradle/api/plugins/announce1----
src/org/gradle/api/plugins/announce/internal62-2-
src/org/gradle/api/plugins/osgi11-1-
src/org/gradle/api/plugins/quality5----
src/org/gradle/api/plugins/scala22-3-
src/org/gradle/api/tasks2----
src/org/gradle/api/tasks/application11-14-
src/org/gradle/api/tasks/bundling22-10-
src/org/gradle/api/tasks/compile71-22
src/org/gradle/api/tasks/javadoc2----
src/org/gradle/api/tasks/scala31-1-
src/org/gradle/api/tasks/testing/testng11-52
src/org/gradle/api/tasks/util11-51
src/org/gradle/configuration1----
src/org/gradle/groovy/scripts22-92
src/org/gradle/initialization31-1-
src/org/gradle/plugins/eclipse62-6-
src/org/gradle/plugins/eclipse/model194-38
src/org/gradle/plugins/eclipse/model/internal42-4-
src/org/gradle/plugins/idea43-197
src/org/gradle/plugins/idea/model103-43
src/org/gradle/profile11-1-
src/org/gradle/util1----

Package: src.org.gradle.api.internal

➥ AutoCreateDomainObjectContainerDelegate.groovy

Rule NamePriorityLine #Source Line / Message
ThreadLocalNotStaticFinal222

[SRC]private final ThreadLocal<Boolean> configuring = new Thr..l<Boolean>()

[MSG]The ThreadLocal field configuring is not static

Package: src.org.gradle.api.internal.artifacts.dsl

➥ DefaultArtifactHandler.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter254

[SRC]if (!getMetaClass().respondsTo(this, name, args.size())) {

[MSG]getMetaClass() can probably be rewritten as metaClass

UnnecessaryDefInMethodDeclaration351

[SRC]public def methodMissing(String name, args) {

[MSG]The def keyword is unneeded when a method is marked public

Package: src.org.gradle.api.internal.artifacts.dsl.dependencies

➥ DefaultDependencyHandler.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter280

[SRC]if (!getMetaClass().respondsTo(this, name, args.size())) {

[MSG]getMetaClass() can probably be rewritten as metaClass

UnnecessaryDefInMethodDeclaration377

[SRC]public def methodMissing(String name, args) {

[MSG]The def keyword is unneeded when a method is marked public

Package: src.org.gradle.api.internal.file

➥ AntFileCollectionMatchingTaskBuilder.groovy

Rule NamePriorityLine #Source Line / Message
ExplicitCallToOrMethod231

[SRC]node.or {

[MSG]Explicit call to node.or(<not implemented yet for class: org.codehaus.groovy.ast.expr.ClosureExpression>) method can be rewritten as node | (<not implemented yet for class: org.codehaus.groovy.ast.expr.ClosureExpression>)

Package: src.org.gradle.api.internal.plugins

➥ DefaultConvention.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryOverridingMethod327

[SRC]void setProperty(String property, value) {

[MSG]The method setProperty contains no logic and can be safely deleted

Package: src.org.gradle.api.internal.project

➥ DefaultAntBuilder.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter275

[SRC]antProject.setUserProperty(MagicNames.ANT_FILE, file.get..olutePath())

[MSG]getAbsolutePath() can probably be rewritten as absolutePath

UnnecessaryOverridingMethod336

[SRC]def Object invokeMethod(String methodName, Object args) {

[MSG]The method invokeMethod contains no logic and can be safely deleted

UnnecessaryDefInMethodDeclaration336

[SRC]def Object invokeMethod(String methodName, Object args) {

[MSG]The def keyword is unneeded when a method returns the Object type

UnnecessaryDefInMethodDeclaration340

[SRC]def propertyMissing(String property, Object newValue) {

[MSG]The def keyword is unneeded when a method returns the Object type

UnnecessaryDefInMethodDeclaration344

[SRC]private def doSetProperty(String property, newValue) {

[MSG]The def keyword is unneeded when a method is marked private

➥ DefaultIsolatedAntBuilder.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryObjectReferences2137

[SRC]builder.nodeCompleted(parent, node)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryObjectReferences2141

[SRC]builder.postNodeCompletion(parent, node)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryGetter291

[SRC]antBuilder.project.removeBuildListener(antBuilder.projec..teners()[0])

[MSG]getBuildListeners() can probably be rewritten as buildListeners

Package: src.org.gradle.api.internal.tasks.compile

➥ AntGroovyCompiler.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField237

[SRC]private static Logger logger = LoggerFactory.getLogger(A..ovyCompiler)

[MSG]The field logger is not used within AntGroovyCompiler.groovy

➥ AntJavaCompiler.groovy

Rule NamePriorityLine #Source Line / Message
EmptyMethod245

[SRC]void setDependencyCacheDir(File dir) {

[MSG]The method setDependencyCacheDir is both empty and not marked with @Override

Package: src.org.gradle.api.internal.tasks.scala

➥ AntScalaCompiler.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField226

[SRC]private static Logger logger = LoggerFactory.getLogger(A..alaCompiler)

[MSG]The field logger is not used within AntScalaCompiler.groovy

Package: src.org.gradle.api.internal.tasks.testing.junit.report

➥ OverviewPageRenderer.groovy

Rule NamePriorityLine #Source Line / Message
NestedBlockDepth239

[SRC]td(class: testPackage.statusClass) {

[MSG]The nested block depth is 6

NestedBlockDepth263

[SRC]tr {

[MSG]The nested block depth is 6

NestedBlockDepth264

[SRC]td(class: testClass.statusClass) {

[MSG]The nested block depth is 7

➥ PageRenderer.groovy

Rule NamePriorityLine #Source Line / Message
NestedBlockDepth2100

[SRC]tr {

[MSG]The nested block depth is 6

NestedBlockDepth2101

[SRC]td {

[MSG]The nested block depth is 7

NestedBlockDepth2102

[SRC]div(class: 'summaryGroup') {

[MSG]The nested block depth is 8

NestedBlockDepth2103

[SRC]table {

[MSG]The nested block depth is 9

NestedBlockDepth2104

[SRC]tr {

[MSG]The nested block depth is 10

NestedBlockDepth2105

[SRC]td {

[MSG]The nested block depth is 11

NestedBlockDepth2106

[SRC]div(id: 'tests', class: 'infoBox') {

[MSG]The nested block depth is 12

NestedBlockDepth2111

[SRC]td {

[MSG]The nested block depth is 11

NestedBlockDepth2112

[SRC]div(id: 'failures', class: 'infoBox') {

[MSG]The nested block depth is 12

NestedBlockDepth2117

[SRC]td {

[MSG]The nested block depth is 11

NestedBlockDepth2118

[SRC]div(id: 'duration', class: 'infoBox') {

[MSG]The nested block depth is 12

NestedBlockDepth2127

[SRC]td {

[MSG]The nested block depth is 7

NestedBlockDepth2128

[SRC]div(id: 'successRate', class: "infoBox ${results.statusClass}") {

[MSG]The nested block depth is 8

UnnecessaryGetter2141

[SRC]mkp.yield(" at ${DateFormat.getDateTimeInstance().format..w Date())}")

[MSG]getDateTimeInstance() can probably be rewritten as dateTimeInstance

Package: src.org.gradle.api.plugins

➥ ApplicationPlugin.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateMethodParameter2104

[SRC]private void configureDistZipTask(Project project, Appli.. distSpec) {

[MSG]Method parameter [applicationPluginConvention] is never referenced

UnnecessaryGetter2100

[SRC]project.getAnt().chmod(file: "${installTask.destinationD..rm: 'ugo+x')

[MSG]getAnt() can probably be rewritten as ant

UnnecessaryDefInMethodDeclaration355

[SRC]private def CopySpec createDistSpec(Project project) {

[MSG]The def keyword is unneeded when a method is marked private

➥ ApplicationPluginConvention.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter251

[SRC]JavaExec runTask = project.getTasks().withType(JavaExec...find{task ->

[MSG]getTasks() can probably be rewritten as tasks

➥ BasePlugin.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter2114

[SRC]project.tasks.add(taskName).dependsOn(configuration.getB..figuration))

[MSG]getBuildArtifacts() can probably be rewritten as buildArtifacts

UnnecessaryGetter2152

[SRC]Upload upload = project.getTasks().add(name, Upload.class)

[MSG]getTasks() can probably be rewritten as tasks

UnnecessaryGetter2155

[SRC]upload.descriptorDestination = new File(project.getBuild.., "ivy.xml")

[MSG]getBuildDir() can probably be rewritten as buildDir

UnnecessaryGetter2162

[SRC]ConfigurationContainer configurations = project.getConfigurations();

[MSG]getConfigurations() can probably be rewritten as configurations

➥ JavaPluginConvention.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateMethod2117

[SRC]private File getReportsDir() {

[MSG]The method getReportsDir is not used within JavaPluginConvention.groovy

UnnecessaryGetter2167

[SRC]return ConfigureUtil.configure(closure, new DefaultManif..eResolver));

[MSG]getProject() can probably be rewritten as project

Package: src.org.gradle.api.plugins.announce.internal

➥ NotifySend.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField231

[SRC]private static final Logger logger = LoggerFactory.getLo..(NotifySend)

[MSG]The field logger is not used within NotifySend.groovy

➥ Snarl.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter237

[SRC]with(new PrintWriter(sock.getOutputStream(), true)) { out ->

[MSG]getOutputStream() can probably be rewritten as outputStream

Package: src.org.gradle.api.plugins.osgi

➥ OsgiPlugin.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter232

[SRC]project.getPlugins().apply(JavaBasePlugin.class);

[MSG]getPlugins() can probably be rewritten as plugins

Package: src.org.gradle.api.plugins.scala

➥ ScalaBasePlugin.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateMethodParameter263

[SRC]private void configureCompileDefaults(final Project proj..avaPlugin) {

[MSG]Method parameter [javaPlugin] is never referenced

UnnecessaryGetter270

[SRC]project.getTasks().withType(ScalaDoc.class) {ScalaDoc scalaDoc ->

[MSG]getTasks() can probably be rewritten as tasks

➥ ScalaPlugin.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter237

[SRC]project.getTasks().withType(ScalaDoc.class) {ScalaDoc scalaDoc ->

[MSG]getTasks() can probably be rewritten as tasks

Package: src.org.gradle.api.tasks.application

➥ CreateStartScripts.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter271

[SRC]if (!getApplicationName()) {

[MSG]getApplicationName() can probably be rewritten as applicationName

UnnecessaryGetter274

[SRC]return "${GUtil.toConstant(getApplicationName())}_OPTS"

[MSG]getApplicationName() can probably be rewritten as applicationName

UnnecessaryGetter282

[SRC]if (!getApplicationName()) {

[MSG]getApplicationName() can probably be rewritten as applicationName

UnnecessaryGetter285

[SRC]return "${GUtil.toConstant(getApplicationName())}_EXIT_CONSOLE"

[MSG]getApplicationName() can probably be rewritten as applicationName

UnnecessaryGetter290

[SRC]getOutputDir().mkdirs();

[MSG]getOutputDir() can probably be rewritten as outputDir

UnnecessaryGetter2105

[SRC]applicationName: getApplicationName(),

[MSG]getApplicationName() can probably be rewritten as applicationName

UnnecessaryGetter2106

[SRC]optsEnvironmentVar: getOptsEnvironmentVar(),

[MSG]getOptsEnvironmentVar() can probably be rewritten as optsEnvironmentVar

UnnecessaryGetter2107

[SRC]mainClassName: getMainClassName(),

[MSG]getMainClassName() can probably be rewritten as mainClassName

UnnecessaryGetter2110

[SRC]applicationName: getApplicationName(),

[MSG]getApplicationName() can probably be rewritten as applicationName

UnnecessaryGetter2111

[SRC]optsEnvironmentVar: getOptsEnvironmentVar(),

[MSG]getOptsEnvironmentVar() can probably be rewritten as optsEnvironmentVar

UnnecessaryGetter2112

[SRC]exitEnvironmentVar: getExitEnvironmentVar(),

[MSG]getExitEnvironmentVar() can probably be rewritten as exitEnvironmentVar

UnnecessaryGetter2113

[SRC]mainClassName: getMainClassName(),

[MSG]getMainClassName() can probably be rewritten as mainClassName

UnnecessaryGetter2122

[SRC]def windowsScript = new File(getOutputDir(), "${project.name}.bat")

[MSG]getOutputDir() can probably be rewritten as outputDir

UnnecessaryGetter2133

[SRC]def unixScript = new File(getOutputDir(), project.name);

[MSG]getOutputDir() can probably be rewritten as outputDir

Package: src.org.gradle.api.tasks.bundling

➥ Jar.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter246

[SRC]Manifest manifest = getManifest() ?: new DefaultManifest(null)

[MSG]getManifest() can probably be rewritten as manifest

UnnecessaryGetter246

[SRC]Manifest manifest = getManifest() ?: new DefaultManifest(null)

[MSG]getManifest() can probably be rewritten as manifest

UnnecessaryGetter285

[SRC]if (getManifest() == null) {

[MSG]getManifest() can probably be rewritten as manifest

UnnecessaryGetter288

[SRC]ConfigureUtil.configure(configureClosure, getManifest());

[MSG]getManifest() can probably be rewritten as manifest

UnnecessaryGetter2106

[SRC]return ConfigureUtil.configure(configureClosure, getMetaInf())

[MSG]getMetaInf() can probably be rewritten as metaInf

➥ War.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter246

[SRC]def classpath = getClasspath()

[MSG]getClasspath() can probably be rewritten as classpath

UnnecessaryGetter252

[SRC]def classpath = getClasspath()

[MSG]getClasspath() can probably be rewritten as classpath

UnnecessaryGetter258

[SRC]getWebXml()

[MSG]getWebXml() can probably be rewritten as webXml

UnnecessaryGetter280

[SRC]return ConfigureUtil.configure(configureClosure, getWebInf())

[MSG]getWebInf() can probably be rewritten as webInf

UnnecessaryGetter2110

[SRC]FileCollection oldClasspath = getClasspath()

[MSG]getClasspath() can probably be rewritten as classpath

Package: src.org.gradle.api.tasks.compile

➥ AbstractOptions.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter248

[SRC]((field.getModifiers() & Modifier.STATIC) == 0) &&

[MSG]getModifiers() can probably be rewritten as modifiers

UnnecessaryGetter249

[SRC](field.getName() != "metaClass") &&

[MSG]getName() can probably be rewritten as name

UnnecessaryDefInMethodDeclaration353

[SRC]private def antProperty(String fieldName) {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration361

[SRC]private def antValue(String fieldName, def value) {

[MSG]The def keyword is unneeded when a method is marked private

Package: src.org.gradle.api.tasks.scala

➥ AntScalaDoc.groovy

Rule NamePriorityLine #Source Line / Message
UnusedPrivateField224

[SRC]private static Logger logger = LoggerFactory.getLogger(AntScalaDoc)

[MSG]The field logger is not used within AntScalaDoc.groovy

Package: src.org.gradle.api.tasks.testing.testng

➥ TestNGOptions.groovy

Rule NamePriorityLine #Source Line / Message
ExplicitHashSetInstantiation253

[SRC]Set<String> includeGroups = new HashSet<String>()

[MSG]HashSet objects are better instantiated using the form "[] as HashSet"

ExplicitHashSetInstantiation258

[SRC]Set<String> excludeGroups = new HashSet<String>()

[MSG]HashSet objects are better instantiated using the form "[] as HashSet"

SerializableClassMustDefineSerialVersionUID227

[SRC]public class TestNGOptions extends TestFrameworkOptions ..rializable {

[MSG]The class org.gradle.api.tasks.testing.testng.TestNGOptions implements Serializable but does not define a serialVersionUID

UnnecessaryGetter2199

[SRC]return suiteXmlBuilder.getMetaClass()."${name}"

[MSG]getMetaClass() can probably be rewritten as metaClass

UnnecessaryGetter2207

[SRC]return suiteXmlBuilder.getMetaClass().invokeMethod(suite..name, args);

[MSG]getMetaClass() can probably be rewritten as metaClass

UnnecessaryDefInMethodDeclaration3197

[SRC]public def propertyMissing(String name) {

[MSG]The def keyword is unneeded when a method is marked public

UnnecessaryDefInMethodDeclaration3205

[SRC]public def methodMissing(String name, args) {

[MSG]The def keyword is unneeded when a method is marked public

Package: src.org.gradle.api.tasks.util

➥ PatternSet.groovy

Rule NamePriorityLine #Source Line / Message
ExplicitCallToAndMethod2205

[SRC]node.and {

[MSG]Explicit call to node.and(<not implemented yet for class: org.codehaus.groovy.ast.expr.ClosureExpression>) method can be rewritten as node & (<not implemented yet for class: org.codehaus.groovy.ast.expr.ClosureExpression>)

ExplicitCallToAndMethod2238

[SRC]node.and {

[MSG]Explicit call to node.and(<not implemented yet for class: org.codehaus.groovy.ast.expr.ClosureExpression>) method can be rewritten as node & (<not implemented yet for class: org.codehaus.groovy.ast.expr.ClosureExpression>)

ExplicitHashSetInstantiation245

[SRC]private static final Set<String> GLOBAL_EXCLUDES = new H..et<String>()

[MSG]HashSet objects are better instantiated using the form "[] as HashSet"

UnnecessaryGetter2234

[SRC]return new AndSpec<FileTreeElement>([super.getAsSpec(), ..] as Spec[])

[MSG]getAsSpec() can probably be rewritten as asSpec

UnnecessaryGetter2234

[SRC]return new AndSpec<FileTreeElement>([super.getAsSpec(), ..] as Spec[])

[MSG]getAsSpec() can probably be rewritten as asSpec

UnnecessaryDefInMethodDeclaration357

[SRC]static def setGlobalExcludes(Collection<String> excludes) {

[MSG]The def keyword is unneeded when a method is marked static

Package: src.org.gradle.groovy.scripts

➥ BasicScript.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryDefInMethodDeclaration337

[SRC]def Object getScriptTarget() {

[MSG]The def keyword is unneeded when a method returns the Object type

UnnecessaryDefInMethodDeclaration367

[SRC]def methodMissing(String name, Object params) {

[MSG]The def keyword is unneeded when a method returns the Object type

➥ DefaultScript.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryObjectReferences2104

[SRC]fileOperations.relativePath(path)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryObjectReferences2108

[SRC]fileOperations.fileTree(baseDir)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryObjectReferences2112

[SRC]fileOperations.fileTree(args)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryObjectReferences2116

[SRC]fileOperations.fileTree(closure)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryObjectReferences2120

[SRC]fileOperations.zipTree(zipPath)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryObjectReferences2124

[SRC]fileOperations.tarTree(tarPath)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryObjectReferences2128

[SRC]fileOperations.copy(closure)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryObjectReferences2132

[SRC]fileOperations.copySpec(closure)

[MSG]The code could be more concise by using a with() or identity() block

UnnecessaryGetter280

[SRC]ConfigureUtil.configure(configureClosure, getBuildscript())

[MSG]getBuildscript() can probably be rewritten as buildscript

Package: src.org.gradle.initialization

➥ InitScript.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter223

[SRC]getBuildscript()

[MSG]getBuildscript() can probably be rewritten as buildscript

Package: src.org.gradle.plugins.eclipse

➥ EclipseJdt.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter244

[SRC]jdt.sourceCompatibility = getSourceCompatibility()

[MSG]getSourceCompatibility() can probably be rewritten as sourceCompatibility

UnnecessaryGetter245

[SRC]jdt.targetCompatibility = getTargetCompatibility()

[MSG]getTargetCompatibility() can probably be rewritten as targetCompatibility

➥ EclipsePlugin.groovy

Rule NamePriorityLine #Source Line / Message
NestedBlockDepth2121

[SRC]whenConfigured { Classpath classpath ->

[MSG]The nested block depth is 6

NestedBlockDepth2122

[SRC]for (entry in classpath.entries) {

[MSG]The nested block depth is 7

NestedBlockDepth2123

[SRC]if (entry instanceof Library) {

[MSG]The nested block depth is 8

NestedBlockDepth2168

[SRC]getMainSourceDirs(otherProject).collect { new WbResource..ePath(it)) }

[MSG]The nested block depth is 6

Package: src.org.gradle.plugins.eclipse.model

➥ AbstractClasspathEntry.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter262

[SRC]def allAttributes = attributes.findAll { it.value } + [k.. path: path]

[MSG]getKind() can probably be rewritten as kind

➥ BuildCommand.groovy

Rule NamePriorityLine #Source Line / Message
SerializableClassMustDefineSerialVersionUID221

[SRC]class BuildCommand implements Serializable {

[MSG]The class org.gradle.plugins.eclipse.model.BuildCommand implements Serializable but does not define a serialVersionUID

➥ Output.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter241

[SRC]node.appendNode('classpathentry', [kind: getKind(), path: path])

[MSG]getKind() can probably be rewritten as kind

➥ Project.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryDefInMethodDeclaration377

[SRC]private def readReferencedProjects() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration383

[SRC]private def readNatures() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration387

[SRC]private def readBuildCommands() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration397

[SRC]private def readLinks() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration3133

[SRC]private def addReferencedProjectsToXml() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration3140

[SRC]private def addNaturesToXml() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration3147

[SRC]private def addBuildSpecToXml() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration3161

[SRC]private def addLinksToXml() {

[MSG]The def keyword is unneeded when a method is marked private

Package: src.org.gradle.plugins.eclipse.model.internal

➥ ClasspathFactory.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryCollectCall245

[SRC]def sourceDirs = sourceDirSets.collect { it.srcDirs }.flatten()

[MSG]The call to collect could probably be rewritten as a spread expression: sourceDirSets*.srcDirs

UnnecessaryCollectCall275

[SRC]return getDependencies(eclipseClasspath.plusConfiguratio..ependency ->

[MSG]The call to collect could probably be rewritten as a spread expression: this.getDependencies(eclipseClasspath.plusConfigurations, eclipseClasspath.minusConfigurations, <not implemented yet for class: org.codehaus.groovy.ast.expr.ClosureExpression>)*.dependencyProject

UnnecessaryGetter233

[SRC]entries.addAll(getEntriesFromContainers(eclipseClasspath..ntainers()))

[MSG]getContainers() can probably be rewritten as containers

➥ WtpComponentFactory.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryCollectCall292

[SRC]dependencies.collect { it.resolve() }.flatten()

[MSG]The call to collect could probably be rewritten as a spread expression: dependencies*.resolve()

Package: src.org.gradle.plugins.idea

➥ IdeaModule.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter2121

[SRC]module.configure(getContentPath(), getSourcePaths(), get..ludePaths(),

[MSG]getContentPath() can probably be rewritten as contentPath

UnnecessaryGetter2121

[SRC]module.configure(getContentPath(), getSourcePaths(), get..ludePaths(),

[MSG]getSourcePaths() can probably be rewritten as sourcePaths

UnnecessaryGetter2121

[SRC]module.configure(getContentPath(), getSourcePaths(), get..ludePaths(),

[MSG]getTestSourcePaths() can probably be rewritten as testSourcePaths

UnnecessaryGetter2121

[SRC]module.configure(getContentPath(), getSourcePaths(), get..ludePaths(),

[MSG]getExcludePaths() can probably be rewritten as excludePaths

UnnecessaryGetter2122

[SRC]inheritOutputDirs, getOutputPath(), getTestOutputPath(),..javaVersion)

[MSG]getOutputPath() can probably be rewritten as outputPath

UnnecessaryGetter2122

[SRC]inheritOutputDirs, getOutputPath(), getTestOutputPath(),..javaVersion)

[MSG]getTestOutputPath() can probably be rewritten as testOutputPath

UnnecessaryGetter2122

[SRC]inheritOutputDirs, getOutputPath(), getTestOutputPath(),..javaVersion)

[MSG]getDependencies() can probably be rewritten as dependencies

UnnecessaryGetter2126

[SRC]getPath(getModuleDir())

[MSG]getModuleDir() can probably be rewritten as moduleDir

UnnecessaryGetter2130

[SRC]getOutputDir() ? getPath(getOutputDir()) : null

[MSG]getOutputDir() can probably be rewritten as outputDir

UnnecessaryGetter2130

[SRC]getOutputDir() ? getPath(getOutputDir()) : null

[MSG]getOutputDir() can probably be rewritten as outputDir

UnnecessaryGetter2134

[SRC]getTestOutputDir() ? getPath(getTestOutputDir()) : null

[MSG]getTestOutputDir() can probably be rewritten as testOutputDir

UnnecessaryGetter2134

[SRC]getTestOutputDir() ? getPath(getTestOutputDir()) : null

[MSG]getTestOutputDir() can probably be rewritten as testOutputDir

UnnecessaryGetter2138

[SRC]getSourceDirs().findAll { it.exists() }.collect { getPath(it) }

[MSG]getSourceDirs() can probably be rewritten as sourceDirs

UnnecessaryGetter2142

[SRC]getTestSourceDirs().findAll { it.exists() }.collect { getPath(it) }

[MSG]getTestSourceDirs() can probably be rewritten as testSourceDirs

UnnecessaryGetter2146

[SRC]getExcludeDirs().collect { getPath(it) }

[MSG]getExcludeDirs() can probably be rewritten as excludeDirs

UnnecessaryGetter2208

[SRC]firstLevelDependencies.addAll(configuration.getAllDepend..All(filter))

[MSG]getAllDependencies() can probably be rewritten as allDependencies

UnnecessaryGetter2211

[SRC]configuration.getAllDependencies().findAll(filter).each { minusDep ->

[MSG]getAllDependencies() can probably be rewritten as allDependencies

UnnecessaryGetter2280

[SRC]factory.addPathVariable('MODULE_DIR', getOutputFile().parentFile)

[MSG]getOutputFile() can probably be rewritten as outputFile

UnnecessaryDefInMethodDeclaration3196

[SRC]private def getSelfResolvingFiles(Collection dependencie..ing scope) {

[MSG]The def keyword is unneeded when a method is marked private

➥ IdeaPlugin.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryDefInMethodDeclaration343

[SRC]private def configureIdeaWorkspace(Project project) {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration352

[SRC]private def configureIdeaModule(Project project) {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration363

[SRC]private def configureIdeaProject(Project project) {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration375

[SRC]private def configureForJavaPlugin(Project project) {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration382

[SRC]private def configureIdeaProjectForJava(Project project) {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration390

[SRC]private def configureIdeaModuleForJava(Project project) {

[MSG]The def keyword is unneeded when a method is marked private

➥ IdeaProject.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter249

[SRC]return new Project(xmlTransformer, getPathFactory())

[MSG]getPathFactory() can probably be rewritten as pathFactory

Package: src.org.gradle.plugins.idea.model

➥ ModuleDependency.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter243

[SRC]parentNode.appendNode('orderEntry', [type: 'module', 'mo..dExported())

[MSG]getAttributeMapForScopeAndExported() can probably be rewritten as attributeMapForScopeAndExported

UnnecessaryGetter277

[SRC]result = 31 * result + getScopeHash();

[MSG]getScopeHash() can probably be rewritten as scopeHash

➥ ModuleLibrary.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryGetter261

[SRC]Node libraryNode = parentNode.appendNode('orderEntry', [..e('library')

[MSG]getAttributeMapForScopeAndExported() can probably be rewritten as attributeMapForScopeAndExported

UnnecessaryGetter2118

[SRC]result = 31 * result + getScopeHash()

[MSG]getScopeHash() can probably be rewritten as scopeHash

➥ Project.groovy

Rule NamePriorityLine #Source Line / Message
UnnecessaryDefInMethodDeclaration397

[SRC]private def findProjectRootManager() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration3101

[SRC]private def findWildcardResourcePatterns() {

[MSG]The def keyword is unneeded when a method is marked private

UnnecessaryDefInMethodDeclaration3105

[SRC]private def findModules() {

[MSG]The def keyword is unneeded when a method is marked private

Package: src.org.gradle.profile

➥ HTMLProfileReport.groovy

Rule NamePriorityLine #Source Line / Message
SimpleDateFormatMissingLocale225

[SRC]private static final SimpleDateFormat DATE_FORMAT = new .. HH:mm:ss");

[MSG]Created an instance of SimpleDateFormat without specifying a Locale

Rule Descriptions

#Rule NameDescription
1AbcComplexityChecks the ABC metric of size/complexity for methods/classes.A method (or "closure field") with an ABC complexity value (score) greater than the maxMethodComplexity property (60) causes a violation. Likewise, a class that has an (average method) ABC complexityvalue greater than the maxClassAverageMethodComplexity property (60) causes a violation.
2AddEmptyStringFinds empty string literals which are being added. This is an inefficient way to convert any type to a String.
3AssignmentInConditionalAn assignment operator (=) was used in a conditional test. This is usually a typo, and the comparison operator (==) was intended.
4BigDecimalInstantiationChecks for calls to the BigDecimal constructors that take a double parameter, which may result in an unexpected BigDecimal value.
5BooleanGetBooleanThis rule catches usages of java.lang.Boolean.getBoolean(String) which reads a boolean from the System properties. It is often mistakenly used to attempt to read user input or parse a String into a boolean. It is a poor piece of API to use; replace it with System.properties['prop̈́'].
6BooleanMethodReturnsNullMethod with Boolean return type returns explicit null. A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. This method can be invoked as though it returned a value of type boolean, and the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, this will result in a NullPointerException.
7BrokenOddnessCheckThe code uses x % 2 == 1 to check to see if a value is odd, but this won't work for negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check for oddness, consider using x & 1 == 1, or x % 2 != 0.
8BusyWaitBusy waiting (forcing a Thread.sleep() while waiting on a condition) should be avoided. Prefer using the gate and barrier objects in the java.util.concurrent package.
9ChainedTestA test method that invokes another test method is a chained test; the methods are dependent on one another. Tests should be isolated, and not be dependent on one another.
10ClassSizeChecks if the size of a class exceeds the number of lines specified by the maxLines property (1000).
11CloneableWithoutCloneA class that implements java.lang.Cloneable should define a clone() method.
12CompareToWithoutComparableIf you implement a compareTo method then you should also implement the Comparable interface. If you don't then you could possibly get an exception if the Groovy == operator is invoked on your object. This is an issue fixed in Groovy 1.8 but present in previous versions.
13ConfusingTernaryIn a ternary expression avoid negation in the test. For example, rephrase: "(x != y) ? diff : same" as: "(x == y) ? same : diff". Consistent use of this rule makes the code easier to read. Also, this resolves trivial ordering problems, such as "does the error case go first?" or "does the common case go first?".
14ConsecutiveLiteralAppendsViolations occur when method calls to append(Object) are chained together with literals as parameters. The chained calls can be joined into one invocation.
15ConsecutiveStringConcatenationCatches concatenation of two string literals on the same line. These can safely by joined.
16ConstantIfExpressionChecks for if statements with a constant value for the if expression, such as true, false, null, or a literal constant value.
17ConstantTernaryExpressionChecks for ternary expressions with a constant value for the boolean expression, such as true, false, null, or a literal constant value.
18CoupledTestCaseThis rule finds test cases that are coupled to other test cases, either by invoking static methods on another test case or by creating instances of another test case. If you require shared logic in test cases then extract that logic to a new class where it can properly be reused.
19CyclomaticComplexityChecks the cyclomatic complexity for methods/classes.A method (or "closure field") with a cyclomatic complexity value greater than the maxMethodComplexity property (20) causes a violation. Likewise, a class that has an (average method) cyclomatic complexityvalue greater than the maxClassAverageMethodComplexity property (20) causes a violation.
20DeadCodeDead code appears after a return statement or an exception is thrown. If code appears after one of these statements then it will never be executed and can be safely deleted.
21DoubleCheckedLockingThis rule detects double checked locking, where a 'lock hint' is tested for null before initializing an object within a synchronized block. Double checked locking does not guarantee correctness and is an anti-pattern.
22DoubleNegativeThere is no point in using a double negative, it is always positive. For instance !!x can always be simplified to x. And !(!x) can as well.
23DuplicateCaseStatementCheck for duplicate case statements in a switch block, such as two equal integers or strings.
24DuplicateImportDuplicate import statements are unnecessary.
25EmptyCatchBlockIn most cases, exceptions should not be caught and ignored (swallowed).
26EmptyElseBlockEmpty else blocks are confusing and serve no purpose.
27EmptyFinallyBlockEmpty finally blocks are confusing and serve no purpose.
28EmptyForStatementEmpty for statements are confusing and serve no purpose.
29EmptyIfStatementEmpty if statements are confusing and serve no purpose.
30EmptyInstanceInitializerAn empty class instance initializer was found. It is safe to remove it.
31EmptyMethodA method was found without an implementation. If the method is overriding or implementing a parent method, then mark it with the @Override annotation.
32EmptyStaticInitializerAn empty static initializer was found. It is safe to remove it.
33EmptySwitchStatementEmpty switch statements are confusing and serve no purpose.
34EmptySynchronizedStatementEmpty synchronized statements are confusing and serve no purpose.
35EmptyTryBlockEmpty try blocks are confusing and serve no purpose.
36EmptyWhileStatementEmpty while statements are confusing and serve no purpose.
37EqualsAndHashCodeIf either the boolean equals(Object) or the int hashCode() methods are overridden within a class, then both must be overridden.
38ExplicitArrayListInstantiationThis rule checks for the explicit instantiation of an ArrayList using the no-arg constructor. In Groovy, it is best to write new ArrayList() as [], which creates the same object.
39ExplicitCallToAndMethodThis rule detects when the and(Object) method is called directly in code instead of using the & operator. A groovier way to express this: a.and(b) is this: a & b
40ExplicitCallToCompareToMethodThis rule detects when the compareTo(Object) method is called directly in code instead of using the <=>, >, >=, <, and <= operators. A groovier way to express this: a.compareTo(b) is this: a <=> b, or using the other operators.
41ExplicitCallToDivMethodThis rule detects when the div(Object) method is called directly in code instead of using the / operator. A groovier way to express this: a.div(b) is this: a / b
42ExplicitCallToEqualsMethodThis rule detects when the equals(Object) method is called directly in code instead of using the == or != operator. A groovier way to express this: a.equals(b) is this: a == b and a groovier way to express : !a.equals(b) is : a != b
43ExplicitCallToGetAtMethodThis rule detects when the getAt(Object) method is called directly in code instead of using the [] index operator. A groovier way to express this: a.getAt(b) is this: a[b]
44ExplicitCallToLeftShiftMethodThis rule detects when the leftShift(Object) method is called directly in code instead of using the << operator. A groovier way to express this: a.leftShift(b) is this: a << b
45ExplicitCallToMinusMethodThis rule detects when the minus(Object) method is called directly in code instead of using the - operator. A groovier way to express this: a.minus(b) is this: a - b
46ExplicitCallToModMethodThis rule detects when the mod(Object) method is called directly in code instead of using the % operator. A groovier way to express this: a.mod(b) is this: a % b
47ExplicitCallToMultiplyMethodThis rule detects when the minus(Object) method is called directly in code instead of using the * operator. A groovier way to express this: a.multiply(b) is this: a * b
48ExplicitCallToOrMethodThis rule detects when the or(Object) method is called directly in code instead of using the | operator. A groovier way to express this: a.or(b) is this: a | b
49ExplicitCallToPlusMethodThis rule detects when the plus(Object) method is called directly in code instead of using the + operator. A groovier way to express this: a.plus(b) is this: a + b
50ExplicitCallToPowerMethodThis rule detects when the power(Object) method is called directly in code instead of using the ** operator. A groovier way to express this: a.power(b) is this: a ** b
51ExplicitCallToRightShiftMethodThis rule detects when the rightShift(Object) method is called directly in code instead of using the >> operator. A groovier way to express this: a.rightShift(b) is this: a >> b
52ExplicitCallToXorMethodThis rule detects when the xor(Object) method is called directly in code instead of using the ^ operator. A groovier way to express this: a.xor(b) is this: a ^ b
53ExplicitGarbageCollectionCalls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not. Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory leaks develop within an application, it should be dealt with JVM options rather than within the code itself.
54ExplicitHashMapInstantiationThis rule checks for the explicit instantiation of a HashMap using the no-arg constructor. In Groovy, it is best to write new HashMap() as [:], which creates the same object.
55ExplicitHashSetInstantiationThis rule checks for the explicit instantiation of a HashSet using the no-arg constructor. In Groovy, it is best to write new HashSet() as [] as Set, which creates the same object.
56ExplicitLinkedListInstantiationThis rule checks for the explicit instantiation of a LinkedList using the no-arg constructor. In Groovy, it is best to write new LinkedList() as [] as Queue, which creates the same object.
57ExplicitStackInstantiationThis rule checks for the explicit instantiation of a Stack using the no-arg constructor. In Groovy, it is best to write new Stack() as [] as Stack, which creates the same object.
58ExplicitTreeSetInstantiationThis rule checks for the explicit instantiation of a TreeSet using the no-arg constructor. In Groovy, it is best to write new TreeSet() as [] as SortedSet, which creates the same object.
59GStringAsMapKeyA GString should not be used as a map key since its hashcode is not guaranteed to be stable. Consider calling key.toString().
60GroovyLangImmutableThe groovy.lang.Immutable annotation has been deprecated and replaced by groovy.transform.Immutable. Do not use the Immutable in groovy.lang.
61ImportFromSamePackageAn import of a class that is within the same package is unnecessary.
62InconsistentPropertyLockingClass contains similarly-named get and set methods where one method of the pair is marked either @WithReadLock or @WithWriteLock and the other is not locked at all.
63InconsistentPropertySynchronizationClass contains similarly-named get and set methods where the set method is synchronized and the get method is not, or the get method is synchronized and the set method is not.
64IntegerGetIntegerThis rule catches usages of java.lang.Integer.getInteger(String, ...) which reads an Integer from the System properties. It is often mistakenly used to attempt to read user input or parse a String into an Integer. It is a poor piece of API to use; replace it with System.properties['prop'].
65InvertedIfElseAn inverted if-else statement is one in which there is a single if statement with a single else branch and the boolean test of the if is negated. For instance if (!x) false else true. It is usually clearer to write this as if (x) true else false.
66JUnitAssertAlwaysFailsChecks for JUnit assert() method calls with constant arguments such that the assertion always fails. This includes: assertTrue(false), assertFalse(true) and assertNull(CONSTANT).
67JUnitAssertAlwaysSucceedsChecks for JUnit assert() method calls with constant arguments such that the assertion always succeeds. This includes: assertTrue(true), assertFalse(false) and assertNull(null).
68JUnitFailWithoutMessageThis rule detects JUnit calling the fail() method without an argument. For better error reporting you should always provide a message.
69JUnitPublicNonTestMethodChecks if a JUnit test class contains public methods other than standard test methods, JUnit framework methods or methods with JUnit annotations.
70JUnitSetUpCallsSuperChecks that if the JUnit setUp() method is defined, that it includes a call to super.setUp().
71JUnitTearDownCallsSuperChecks that if the JUnit tearDown() method is defined, that it includes a call to super.tearDown().
72JUnitTestMethodWithoutAssertThis rule searches for test methods that do not contain assert statements. Either the test method is missing assert statements, which is an error, or the test method contains custom assert statements that do not follow a proper assert naming convention. Test methods are defined as public void methods that begin with the work test or have a @Test annotation. By default this rule applies to the default test class names, but this can be changed using the rule's applyToClassNames property.
73JUnitUnnecessarySetUpChecks for JUnit setUp() methods that contain only a call to super.setUp().
74JUnitUnnecessaryTearDownChecks for JUnit tearDown() methods that contain only a call to super.tearDown().
75MethodCountA class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.The maxMethods property (30) specifies the threshold.
76MethodSizeChecks if the size of a method exceeds the number of lines specified by the maxLines property (100).
77NestedBlockDepthChecks for blocks or closures nested more than maxNestedBlockDepth (5) levels deep.
78NestedSynchronizationNested synchronized statements should be avoided. Nested synchronized statements are either useless (if the lock objects are identical) or prone to deadlock.
79RemoveAllOnSelfDon't use removeAll to clear a collection. If you want to remove all elements from a collection c, use c.clear, not c.removeAll(c). Calling c.removeAll(c) to clear a collection is less clear, susceptible to errors from typos, less efficient and for some collections, might throw a ConcurrentModificationException.
80ReturnFromFinallyBlockReturning from a finally block is confusing and can hide the original exception.
81ReturnsNullInsteadOfEmptyArrayConsider returning a zero length array rather than null. It is often a better design to return a length zero array rather than a null reference to indicate that there are no results (i.e., an empty list of results). This way, no explicit check for null is needed by clients of the method.
82ReturnsNullInsteadOfEmptyCollectionConsider returning a zero length collection rather than null. It is often a better design to return a length zero collection rather than a null reference to indicate that there are no results (i.e., an empty list of results). This way, no explicit check for null is needed by clients of the method.
83SerialVersionUIDA serialVersionUID is normally intended to be used with Serialization. It needs to be of type long, static, and final. Also, it should have a visibility modifier such as public or private. Providing no modifier creates a Property and Groovy generates a getter, which is probably not intended.
84SerializableClassMustDefineSerialVersionUIDClasses that implement Serializable should define a serialVersionUID. If you don't define serialVersionUID, the system will make one by hashing most of your class's features. Then if you change anything, the UID will change and Java won't let you reload old data.
85SimpleDateFormatMissingLocaleBe sure to specify a Locale when creating a new instance of SimpleDateFormat; the class is locale-sensitive. If you instantiate SimpleDateFormat without a Locale parameter, it will format the date and time according to the default Locale. Both the pattern and the Locale determine the format. For the same pattern, SimpleDateFormat may format a date and time differently if the Locale varies.
86StaticCalendarFieldCalendar objects should not be used as static fields. Calendars are inherently unsafe for multihtreaded use. Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the application.
87StaticDateFormatFieldDateFormat objects should not be used as static fields. DateFormat are inherently unsafe for multithreaded use. Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the application.
88StaticMatcherFieldMatcher objects should not be used as static fields. Calendars are inherently unsafe for multithreaded use. Sharing a single instance across thread boundaries without proper synchronization will result in erratic behavior of the application.
89SynchronizedMethodThis rule reports uses of the synchronized keyword on methods. Synchronized methods are the same as synchronizing on 'this', which effectively make your synchronization policy public and modifiable by other objects. To avoid possibilities of deadlock, it is better to synchronize on internal objects.
90SynchronizedOnBoxedPrimitiveThe code synchronizes on a boxed primitive constant, such as an Integer. Since Integer objects can be cached and shared, this code could be synchronizing on the same object as other, unrelated code, leading to unresponsiveness and possible deadlock
91SynchronizedOnGetClassSynchronization on getClass rather than class literal. This instance method synchronizes on this.getClass(). If this class is subclassed, subclasses will synchronize on the class object for the subclass, which isn't likely what was intended.
92SynchronizedOnReentrantLockSynchronizing on a ReentrantLock field is almost never the intended usage. A ReentrantLock should be obtained using the lock() method and released in a finally block using the unlock() method.
93SynchronizedOnStringSynchronization on a String field can lead to deadlock because Strings are interned by the JVM and can be shared.
94SynchronizedOnThisThis rule reports uses of the synchronized blocks where the synchronization reference is 'this'. Doing this effectively makes your synchronization policy public and modifiable by other objects. To avoid possibilities of deadlock, it is better to synchronize on internal objects.
95SynchronizedReadObjectMethodCatches Serializable classes that define a synchronized readObject method. By definition, an object created by deserialization is only reachable by one thread, and thus there is no need for readObject() to be synchronized. If the readObject() method itself is causing the object to become visible to another thread, that is an example of very dubious coding style.
96SystemRunFinalizersOnExitMethod calls to System.runFinalizersOnExit() should not be allowed. This method is inherently non-thread-safe, may result in data corruption, deadlock, and may effect parts of the program far removed from it's call point. It is deprecated, and it's use strongly discouraged.
97ThreadGroupAvoid using ThreadGroup; although it is intended to be used in a threaded environment it contains methods that are not thread safe.
98ThreadLocalNotStaticFinalThreadLocal fields should be static and final. In the most common case a java.lang.ThreadLocal instance associates state with a thread. A non-static non-final java.lang.ThreadLocal field associates state with an instance-thread combination. This is seldom necessary and often a bug which can cause memory leaks and possibly incorrect behavior.
99ThreadYieldMethod calls to Thread.yield() should not be allowed. This method has no useful guaranteed semantics, and is often used by inexperienced programmers to mask race conditions.
100ThrowExceptionFromFinallyBlockThrowing an exception from a finally block is confusing and can hide the original exception.
101UnnecessaryBigDecimalInstantiationIt is unnecessary to instantiate BigDecimal objects. Instead just use the decimal literal or the 'G' identifier to force the type, such as 123.45 or 123.45G.
102UnnecessaryBigIntegerInstantiationIt is unnecessary to instantiate BigInteger objects. Instead just use the literal with the 'G' identifier to force the type, such as 8G or 42G.
103UnnecessaryBooleanExpressionChecks for unnecessary boolean expressions, including ANDing (&&) or ORing (||) with true, false, null, or a Map/List/String/Number literal. Also checks for negation (!) of true, false, null, or a Map/List/String/Number literal.
104UnnecessaryBooleanInstantiationUse Boolean.valueOf() for variable values or Boolean.TRUE and Boolean.FALSE for constant values instead of calling the Boolean() constructor directly or calling Boolean.valueOf(true) or Boolean.valueOf(false).
105UnnecessaryCallForLastElementThis rule checks for excessively verbose methods of accessing the last element of an array or list. For instance, it is possible to access the last element of an array by performing array[array.length - 1], in Groovy it is simpler to either call array.last() or array[-1]. The same is true for lists. This violation is triggered whenever a get, getAt, or array-style access is used with an object size check.
106UnnecessaryCallToSubstringCalling String.substring(0) always returns the original string. This code is meaningless.
107UnnecessaryCatchBlockViolations are triggered when a catch block does nothing but throw the original exception. In this scenario there is usually no need for a catch block, just let the exception be thrown from the original code. This condition frequently occurs when catching an exception for debugging purposes but then forgetting to take the catch statement out.
108UnnecessaryCollectCallSome method calls to Object.collect(Closure) can be replaced with the spread operator. For instance, list.collect { it.multiply(2) } can be replaced by list*.multiply(2).
109UnnecessaryCollectionCallUseless call to collections. This call doesn't make sense. For any collection c, calling c.containsAll(c) should always be true, and c.retainAll(c) should have no effect.
110UnnecessaryConstructorThis rule detects when a constructor is not necessary; i.e., when there's only one constructor, it's public, has an empty body, and takes no arguments.
111UnnecessaryDefInMethodDeclarationIf a method has a visibility modifier, then the def keyword is unneeded. For instance 'def private method() {}' is redundant and can be simplified to 'private method() {}'.
112UnnecessaryDoubleInstantiationIt is unnecessary to instantiate Double objects. Instead just use the double literal or the 'D' identifier to force the type, such as 123.45d or 0.42d.
113UnnecessaryFailIn a unit test, catching an exception and immediately calling Assert.fail() is pointless and hides the stack trace. It is better to rethrow the exception or not catch the exception at all.
114UnnecessaryFloatInstantiationIt is unnecessary to instantiate Float objects. Instead just use the float literal with the 'F' identifier to force the type, such as 123.45F or 0.42f.
115UnnecessaryGetterChecks for explicit calls to getter/accessor methods which can, for the most part, be replaced by property access. A getter is defined as a method call that matches get[A-Z] but not getClass() or get[A-Z][A-Z] such as getURL(). Getters do not take method arguments.
116UnnecessaryGroovyImportA Groovy file does not need to include an import for classes from java.lang, java.util, java.io, java.net, groovy.lang and groovy.util, as well as the classes java.math.BigDecimal and java.math.BigInteger.
117UnnecessaryIfStatementChecks for if statements where the if and else blocks are merely returning true and false constants. These cases can be replaced by a simple return statement.
118UnnecessaryInstantiationToGetClassAvoid instantiating an object just to call getClass() on it; use the .class public member instead.
119UnnecessaryIntegerInstantiationIt is unnecessary to instantiate Integer objects. Instead just use the literal with the 'I' identifier to force the type, such as 8I or 42i.
120UnnecessaryLongInstantiationIt is unnecessary to instantiate Long objects. Instead just use the literal with the 'L' identifier to force the type, such as 8L or 42L.
121UnnecessaryModOneAny expression mod 1 (exp % 1) is guaranteed to always return zero. This code is probably an error, and should be either (exp & 1) or (exp % 2).
122UnnecessaryNullCheckGroovy contains the safe dereference operator, which can be used in boolean conditional statements to safely replace explicit "x == null" tests.
123UnnecessaryNullCheckBeforeInstanceOfThere is no need to check for null before an instanceof; the instanceof keyword returns false when given a null argument.
124UnnecessaryObjectReferencesViolations are triggered when an excessive set of consecutive statements all reference the same variable. This can be made more readable by using a with or identity block.
125UnnecessaryOverridingMethodThe overriding method merely calls the same method defined in a superclass
126UnnecessarySelfAssignmentMethod contains a pointless self-assignment to a variable or property.
127UnnecessaryStringInstantiationUse a String literal (e.g., "...") instead of calling the corresponding String constructor (new String("..")) directly.
128UnnecessaryTernaryExpressionChecks for ternary expressions where the conditional expression always evaluates to a boolean and the true and false expressions are merely returning true and false constants. Also checks for ternary expressions where both expressions are the same constant or variable.
129UnnecessaryTransientModifierThe field is marked as transient, but the class isn't Serializable, so marking it as transient has no effect.
130UnusedArrayChecks for array allocations that are not assigned or used, unless it is the last statement within a block.
131UnusedImportImports for a class that is never referenced within the source file is unnecessary.
132UnusedObjectChecks for object allocations that are not assigned or used, unless it is the last statement within a block
133UnusedPrivateFieldChecks for private fields that are not referenced within the same class.
134UnusedPrivateMethodChecks for private methods that are not referenced within the same class.
135UnusedPrivateMethodParameterChecks for parameters to private methods that are not referenced within the method body.
136UnusedVariableChecks for variables that are never referenced.
137UseAssertEqualsInsteadOfAssertTrueThis rule detects JUnit assertions in object equality. These assertions should be made by more specific methods, like assertEquals.
138UseAssertFalseInsteadOfNegationIn unit tests, if a condition is expected to be false then there is no sense using assertTrue with the negation operator. For instance, assertTrue(!condition) can always be simplified to assertFalse(condition)
139UseAssertNullInsteadOfAssertEqualsThis rule detects JUnit calling assertEquals where the first or second parameter is null. These assertion should be made against the assertNull method instead.
140UseAssertSameInsteadOfAssertTrueThis rule detects JUnit calling assertTrue where the first or second parameter is an Object#is() call testing for reference equality. These assertion should be made against the assertSame method instead.
141UseAssertTrueInsteadOfAssertEqualsThis rule detects JUnit calling assertEquals where the first parameter is a boolean. These assertions should be made by more specific methods, like assertTrue or assertFalse.
142UseAssertTrueInsteadOfNegationIn unit tests, if a condition is expected to be true then there is no sense using assertFalse with the negation operator. For instance, assertFalse(!condition) can always be simplified to assertTrue(condition)
143UseOfNotifyMethodThis code calls notify() rather than notifyAll(). Java monitors are often used for multiple conditions. Calling notify() only wakes up one thread, meaning that the thread woken up might not be the one waiting for the condition that the caller just satisfied.
144VolatileArrayFieldVolatile array fields are unsafe because the contents of the array are not treated as volatile. Changing the entire array reference is visible to other threads, but changing an array element is not.
145VolatileLongOrDoubleFieldLong or double fields should not be declared as volatile. Java specifies that reads and writes from such fields are atomic, but many JVM's have violated this specification. Unless you are certain of your JVM, it is better to synchronize access to such fields rather than declare them volatile. This rule flags fields marked volatile when their type is double or long or the name of their type is "Double" or "Long".
146WaitOutsideOfWhileLoopCalls to Object.wait() must be within a while loop. Consider using the Java concurrency utilities instead of wait() and notify().