PT-427: Make Findbugs to honour the exclude filters #20
Changes from all commits
c1a8ec6
ee94b48
ea385ce
86a440b
325268b
b6fbc6c
b7e7017
6696338
939a13f
8ea69ae
02ce614
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,32 +43,28 @@ class PmdConfigurator extends CodeQualityConfigurator<Pmd, PmdExtension> { | |
} | ||
|
||
@Override | ||
protected void configureAndroid(Object variants) { | ||
protected void configureAndroidProject(Object variants) { | ||
project.with { | ||
variants.all { variant -> | ||
variant.sourceSets.each { sourceSet -> | ||
def taskName = "pmd${sourceSet.name.capitalize()}" | ||
Pmd pmd = tasks.findByName(taskName) | ||
if (pmd == null) { | ||
pmd = tasks.create(taskName, Pmd) | ||
def sourceDirs = sourceSet.java.srcDirs | ||
def notEmptyDirs = sourceDirs.findAll { it.list()?.length > 0 } | ||
if (!notEmptyDirs.empty) { | ||
pmd.with { | ||
description = "Run PMD analysis for ${sourceSet.name} classes" | ||
source = sourceSet.java.srcDirs | ||
} | ||
Pmd task = tasks.findByName(taskName) | ||
if (task == null) { | ||
task = tasks.create(taskName, Pmd) | ||
task.with { | ||
description = "Run PMD analysis for ${sourceSet.name} classes" | ||
source = sourceSet.java.srcDirs | ||
} | ||
} | ||
pmd.mustRunAfter variant.javaCompile | ||
sourceFilter.applyTo(task) | ||
task.mustRunAfter variant.javaCompile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be to ensure the compiler fails first, even before the codestyle checks run, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm actually not sure this |
||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected void configureTask(Pmd pmd) { | ||
super.configureTask(pmd) | ||
protected void configureReportEvaluation(Pmd pmd) { | ||
pmd.ignoreFailures = true | ||
pmd.metaClass.getLogger = { QuietLogger.INSTANCE } | ||
pmd.doLast { | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.novoda.test; | ||
|
||
public class HighPriorityViolator { | ||
|
||
public static class Internal { | ||
|
||
public void impossibleCast() { | ||
final Object doubleValue = Double.valueOf(1.0); | ||
final Long value = (Long) doubleValue; | ||
System.out.println(" - " + value); | ||
} | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,13 +134,13 @@ class FindbugsIntegrationTest { | |
@Test | ||
public void shouldNotFailBuildWhenFindbugsConfiguredToExcludePattern() { | ||
TestProject.Result result = projectRule.newProject() | ||
.withSourceSet('debug', SOURCES_WITH_LOW_VIOLATION, SOURCES_WITH_MEDIUM_VIOLATION) | ||
.withSourceSet('release', SOURCES_WITH_HIGH_VIOLATION) | ||
.withSourceSet('debug', SOURCES_WITH_LOW_VIOLATION) | ||
.withSourceSet('release', SOURCES_WITH_HIGH_VIOLATION, SOURCES_WITH_MEDIUM_VIOLATION) | ||
.withPenalty('''{ | ||
maxErrors = 0 | ||
maxWarnings = 10 | ||
}''') | ||
.withFindbugs('findbugs { exclude "HighPriorityViolator.java" }') | ||
.withFindbugs('findbugs { exclude "com/novoda/test/HighPriorityViolator.java" }') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
.build('check') | ||
|
||
assertThat(result.logs).doesNotContainLimitExceeded() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is above comment still applicable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we are not changing the default behaviour here, instead we stack filters upon the default implementation: this method has been copied (and groovyfied) from the original
FindbugsPlugin#L189-L191
. Should we reference the source?