-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathdetekt.gradle
More file actions
55 lines (45 loc) · 1.68 KB
/
detekt.gradle
File metadata and controls
55 lines (45 loc) · 1.68 KB
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
apply plugin: "io.gitlab.arturbosch.detekt"
def filterDetektFiles(String diffFiles){
ArrayList<String> filterList = new ArrayList<String>();
String [] files = diffFiles.split("\\n")
for (String file : files) {
if (file.endsWith(".kt")) {
filterList.add(file)
}
}
return filterList
}
detekt {
toolVersion = "1.23.1"
// Builds the AST in parallel. Rules are always executed in parallel.
// Can lead to speedups in larger projects. `false` by default.
parallel = true
// Define the detekt configuration(s) you want to use.
// Defaults to the default detekt configuration.
config.setFrom("${rootDir.absolutePath}/detekt-config.yml")
// Specifying a baseline file. All findings stored in this file in subsequent runs of detekt.
baseline = file("${rootDir.absolutePath}/detekt-baseline.xml")
if (project.hasProperty('commit_diff_files')) {
def ft = filterDetektFiles(project.property('commit_diff_files'))
source.from = files()
for (int i = 0; i < ft.size(); i++) {
String splitter = ft[i];
String[] fileName = splitter.split("/")
int srcIndex = 0;
for (final def name in fileName) {
if(name == "src"){
break
}
srcIndex += name.length() + 1
}
source.from += splitter.substring(srcIndex)
}
println("detekt >> check commit diff files...")
println("detekt >> " + source.from.toList())
} else {
println("detekt >> check all kt files...")
}
}
dependencies {
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1"
}