@@ -6,44 +6,55 @@ spotbugs {
6
6
}
7
7
8
8
// configure spotbugs for Main tasks and disable it for all other
9
- afterEvaluate {
10
- tasks. withType(spotbugsMain. class). configureEach {
11
- def name = it. name
12
- if (name. endsWith(" Main" ) || name. endsWith(" Main_java11" )) {
13
- it. ignoreFailures = false
14
- // detector documentation is in the following link:
15
- // https://spotbugs-in-kengo-toda.readthedocs.io/en/lqc-list-detectors/detectors.html
16
- it. omitVisitors = [
17
- ' DefaultEncodingDetector' ,
18
- ' DoInsideDoPrivileged' ,
19
- ' DontUseEnum' ,
20
- ' DroppedException' ,
21
- ' FindDeadLocalStores' ,
22
- ' FindHEmismatch' ,
23
- ' FindNullDeref' ,
24
- ' FindReturnRef' ,
25
- ' FindRunInvocations' ,
26
- ' FindUselessControlFlow' ,
27
- ' InitializationChain' ,
28
- ' LazyInit' ,
29
- ' LoadOfKnownNullValue' ,
30
- ' LostLoggerDueToWeakReference' ,
31
- ' MethodReturnCheck' ,
32
- ' MutableStaticFields' ,
33
- ' Naming' ,
34
- ' RuntimeExceptionCapture' ,
35
- ' SerializableIdiom' ,
36
- ' UnreadFields' ,
37
- ]
38
- it. reports {
39
- html {
40
- enabled = true
41
- destination = file(" $buildDir /reports/spotbugs/${ name} .html" )
42
- stylesheet = ' fancy-hist.xsl'
43
- }
44
- }
45
- } else {
46
- it. enabled = false
9
+ // Can't use the class here due to being different class
10
+ tasks. matching { it. name. startsWith(' spotbugs' ) }. configureEach {
11
+ it. launcher = javaToolchains. launcherFor {
12
+ it. languageVersion = JavaLanguageVersion . current()
13
+ }
14
+
15
+ def launcher = it. launcher
16
+ doFirst {
17
+ println (launcher. get(). executablePath)
18
+ }
19
+
20
+ def name = it. name
21
+ if (! (name. endsWith(" Main" ) || name. endsWith(" Main_java11" ))) {
22
+ it. enabled = false
23
+ return
24
+ }
25
+
26
+ it. showProgress = true
27
+ it. ignoreFailures = false
28
+ // detector documentation is in the following link:
29
+ // https://spotbugs-in-kengo-toda.readthedocs.io/en/lqc-list-detectors/detectors.html
30
+ it. omitVisitors = [
31
+ ' ConstructorThrow' ,
32
+ ' DefaultEncodingDetector' ,
33
+ ' DoInsideDoPrivileged' ,
34
+ ' DontUseEnum' ,
35
+ ' DroppedException' ,
36
+ ' FindDeadLocalStores' ,
37
+ ' FindHEmismatch' ,
38
+ ' FindNullDeref' ,
39
+ ' FindReturnRef' ,
40
+ ' FindRunInvocations' ,
41
+ ' FindUselessControlFlow' ,
42
+ ' InitializationChain' ,
43
+ ' LazyInit' ,
44
+ ' LoadOfKnownNullValue' ,
45
+ ' LostLoggerDueToWeakReference' ,
46
+ ' MethodReturnCheck' ,
47
+ ' MutableStaticFields' ,
48
+ ' Naming' ,
49
+ ' RuntimeExceptionCapture' ,
50
+ ' SerializableIdiom' ,
51
+ ' UnreadFields' ,
52
+ ]
53
+ it. reports {
54
+ html {
55
+ required = true
56
+ destination(file(" $buildDir /reports/spotbugs/${ name} .html" ))
57
+ stylesheet = ' fancy-hist.xsl'
47
58
}
48
59
}
49
60
}
0 commit comments