-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstatic_analysis.gradle
114 lines (94 loc) · 2.94 KB
/
static_analysis.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
apply plugin: 'checkstyle' // https://docs.gradle.org/current/userguide/checkstyle_plugin.html
apply plugin: 'findbugs' // https://docs.gradle.org/3.3/userguide/findbugs_plugin.html
apply plugin: 'pmd' // https://docs.gradle.org/current/userguide/pmd_plugin.html
final def qualityDir = buildscript.sourceFile.getParent()
final def reportsDir = "$project.buildDir/reports"
check.dependsOn 'checkFileNames', 'checkCodeStyle', 'findBugs', 'pmdCheck'
// http://checkstyle.sourceforge.net/
checkstyle {
toolVersion '8.31'
showViolations true
}
// https://pmd.github.io/
pmd {
toolVersion = '6.22.0'
}
task checkFileNames(type: Checkstyle, group: 'Verification', description: 'Check file naming convention.') {
configFile file("$qualityDir/checkstyle/naming_convention.xml")
source 'src'
include '**/*.java'
include '**/*.xml'
include '**/*.png'
include '**/*.jpg'
include '**/*.webp'
exclude '**/gen/**'
reports {
xml.enabled = true
xml {
destination file("$reportsDir/checkstyle/check_file_names.xml")
}
}
classpath = files()
}
task checkCodeStyle(type: Checkstyle, group: 'Verification', description: 'Run Checkstyle') {
configFile file("$qualityDir/checkstyle/google_checks.xml")
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = true
xml {
destination file("$reportsDir/checkstyle/check_code_style.xml")
}
}
classpath = files()
}
tasks.whenTaskAdded { task ->
if (task.name.startsWith('compile') && task.name.endsWith('Sources')) {
tasks.getByName('findBugs').dependsOn task
}
}
// http://findbugs.sourceforge.net/
task findBugs(type: FindBugs,
group: 'Verification',
description: 'Run FindBugs') {
ignoreFailures = false
effort = "max"
reportLevel = "high"
excludeFilter = new File("$qualityDir/findbugs/android-exclude-filter.xml")
classes = files("$project.buildDir/intermediates/app_classes")
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
// XML and HTML cannot be used at the same time
xml.enabled = false
html.enabled = !xml.isEnabled()
xml {
destination file("$reportsDir/findbugs/findbugs.xml")
withMessages true
}
html {
destination file("$reportsDir/findbugs/findbugs.html")
}
}
classpath = files()
}
task pmdCheck(type: Pmd, group: 'Verification', description: 'Run PMD') {
ruleSetFiles = files("$qualityDir/pmd/pmd-ruleset.xml")
ignoreFailures = false
ruleSets = []
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = true
html.enabled = true
xml {
destination file("$reportsDir/pmd/pmd.xml")
}
html {
destination file("$reportsDir/pmd/pmd.html")
}
}
}