-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcode-quality.gradle
117 lines (102 loc) · 3.8 KB
/
code-quality.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//this build file is responsible for all the configuration of code quality items, such as code coverage, syntax style checking, static bug finding, etc.
apply plugin: "jacoco"
apply plugin: "pmd"
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration/java')
}
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}
task integrationTest(type: Test, dependsOn: ["cloneConformanceSuite", "updateConformanceSuite"]) {
group "Verification"
description "Runs the integration tests."
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
//testLogging.showStandardStreams = true
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
jacocoTestReport.dependsOn integrationTest //include the integration tests in the code coverage reports
jacocoTestReport.dependsOn test //ensure the tests have run before generating a coverage report
check.dependsOn integrationTest //run the integration tests
check.dependsOn jacocoTestReport //run the code coverage reports
check.dependsOn jacocoTestCoverageVerification //make sure the minimum coverage is met
check.dependsOn javadoc //ensure javadocs are generated correctly
check.dependsOn spotbugsMain //run the spotbugs on the main source code
check.dependsOn pmdMain //run pmd and cpd on the main source code
pmdIntegrationTest.enabled = false
pmdTest.enabled = false
spotbugsIntegrationTest.enabled = false
spotbugsTest.enabled = false
//spotbugs {
// toolVersion = '4.1.3' //4.1.3 release should fix showstopper bug https://github.com/spotbugs/spotbugs/issues/878
//}
spotbugsMain {
excludeFilter = file("config/spotbugs/exclude.xml")
reports {
html {
enabled = true
destination = file("$buildDir/reports/spotbugs/main/spotbugs.html")
}
}
}
pmd {
ruleSets = [] //specifically set this to be empty, otherwise gradle includes the defaults in addition to our custom ruleset!
ruleSetConfig = resources.text.fromFile("config/pmd/ruleset.xml")
toolVersion = "7.11.0"
}
jacocoTestCoverageVerification {
violationRules {
rule {
excludes = ['com.github.jscancella.exceptions.*', //because we don't care about coverage in exceptions
'com.github.jscancella.conformance.exceptions.*',
'com.github.jscancella.internal.PathUtils', //because most of the functions are windows only
'com.github.jscancella.hash.standard.SHA384Hasher'] //because it is exactly the same as the other sha hashers
element = 'CLASS'
limit {
minimum = 0.80
}
}
}
}
jacocoTestReport {
reports {
xml.required = true // coveralls plugin depends on xml format report
html.required = true
}
afterEvaluate {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['com/github/jscancella/exceptions/**',
'com/github/jscancella/conformance/exceptions/**'])
})
}
}
cpdCheck {
source = sourceSets.main.allJava
minimumTokenCount = 60
reports {
text.required = true
xml.required = false
}
}
pitest {
//turn on to figure out why BagitProfileTest is failing
//verbose = true
//it adds dependency to org.pitest:pitest-junit5-plugin and also sets "testPlugin" to "junit5"
junit5PluginVersion = '0.12'
targetClasses = ['com.github.jscancella.*']
excludedTestClasses = ['com.github.jscancella.conformance.profile.BagitProfileTest'] //breaks due to testing all fields
useClasspathFile = true
threads = 4
outputFormats = ['XML', 'HTML']
timestampedReports = false
}