forked from magento/magento2-phpstorm-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstaticChecks.gradle
83 lines (67 loc) · 1.75 KB
/
staticChecks.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
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
import groovy.json.JsonSlurper
/**
* Static Checks
*/
checkstyle {
toolVersion = "8.31"
ignoreFailures = false
maxWarnings = 0
configFile rootProject.file("${rootDir}/gradle-tasks/checkstyle/checkstyle.xml")
}
pmd {
toolVersion = "6.21.0"
consoleOutput = true
ruleSetFiles = files("${rootDir}/gradle-tasks/pmd/ruleset.xml")
ruleSets = []
}
tasks.withType(Checkstyle) {
// Specify all files that should be checked
classpath = files()
source "${project.rootDir}"
}
// Execute Checkstyle on all files
task checkstyle(type: Checkstyle) {
}
// Execute Checkstyle on all modified files
task checkstyleCI(type: Checkstyle) {
def changedFiles = getChangedFiles()
include changedFiles
}
tasks.withType(Pmd) {
// Specify all files that should be checked
classpath = files()
source "${project.rootDir}"
}
// Execute Checkstyle on all files
task pmd(type: Pmd) {
}
// Execute Checkstyle on all modified files
task pmdCI(type: Pmd) {
def changedFiles = getChangedFiles()
include changedFiles
}
/**
* Get all files that are changed but not deleted nor renamed.
* Compares to master or the specified target branch.
*
* @return list of all changed files
*/
def getChangedFiles() {
def modifiedFilesJson = System.getenv("MODIFIED_FILES")
List<String> files = new ArrayList<>()
if (modifiedFilesJson == null) {
return files
}
println "Modified Files: ${modifiedFilesJson}"
//println "Changed files:"
def modifiedFiles = new JsonSlurper().parseText(modifiedFilesJson)
modifiedFiles.each {
files.add(it.toString())
}
// Return the list of touched files
files
}