Skip to content

Commit 00ed63f

Browse files
committed
Fix findbugs exclude generated java sources and cfg package, Add excludeFilterConfig to remove all low level bugs warnings except DM_CONVERT_CASE
1 parent 5bf9bb2 commit 00ed63f

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

build.gradle

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,28 @@ subprojects { subProject ->
254254
toolVersion = '3.0.1'
255255
// for now we need to set this to low so that FindBugs will actually report the DM_CONVERT_CASE warning we care about
256256
reportLevel = 'low'
257+
// remove all low level bug warnings except DM_CONVERT_CASE
258+
excludeFilterConfig=resources.text.fromString(excludeAllLowLevelBugsExcept('DM_CONVERT_CASE'))
257259
}
258-
// exclude generated java sources - by explicitly setting the base source dir
259-
findbugsMain.source = 'src/main/java'
260260

261+
// exclude generated java sources and cfg package is a mess mainly from annotation stuff
262+
findbugsMain.doFirst {
263+
classes = classes.filter {
264+
!it.path.contains( 'org/hibernate/hql/internal/antlr' ) &&
265+
!it.path.contains( 'org/hibernate/boot/jaxb/cfg/spi' ) &&
266+
!it.path.contains( 'org/hibernate/sql/ordering/antlr/Generated' ) &&
267+
!it.path.contains( 'org/hibernate/sql/ordering/antlr/OrderByTemplateTokenTypes' ) &&
268+
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/Jaxb' ) &&
269+
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/Adapter' ) &&
270+
!it.path.contains( 'org/hibernate/boot/jaxb/hbm/spi/ObjectFactory' ) &&
271+
!it.path.contains( 'org/hibernate/cfg' ) &&
272+
!it.path.contains( '_\$logger' )
273+
}
274+
}
261275

262-
// because cfg package is a mess mainly from annotation stuff
276+
// because cfg package is a mess mainly from annotation stuff
263277
checkstyleMain.exclude '**/org/hibernate/cfg/**'
264278
checkstyleMain.exclude '**/org/hibernate/cfg/*'
265-
findbugsMain.exclude '**/org/hibernate/cfg/**'
266-
findbugsMain.exclude '**/org/hibernate/cfg/*'
267279
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268280

269281

@@ -303,3 +315,19 @@ task release(type: Task, dependsOn: 'release:release')
303315
task wrapper(type: Wrapper) {
304316
gradleVersion = expectedGradleVersion
305317
}
318+
319+
def excludeAllLowLevelBugsExcept(String[] bugTypes){
320+
def writer = new StringWriter()
321+
def xml = new groovy.xml.MarkupBuilder(writer);
322+
xml.FindBugsFilter {
323+
Match {
324+
Confidence( value: '3' )
325+
bugTypes.each { bug ->
326+
Not {
327+
Bug( pattern: "${bug}" )
328+
}
329+
}
330+
}
331+
}
332+
return writer.toString( )
333+
}

0 commit comments

Comments
 (0)