Skip to content

Commit e9e3099

Browse files
authored
Merge pull request #38 from egorklementev/master
FEATURE: style checkers & fixes
2 parents e884709 + e24cccb commit e9e3099

8 files changed

Lines changed: 911 additions & 409 deletions

File tree

build.gradle.kts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import org.gradle.jvm.tasks.Jar
55

66
plugins {
77
java
8+
jacoco
9+
pmd
10+
checkstyle
811
}
912

1013
group = "org.eolang"
@@ -48,6 +51,21 @@ val fatJar = task("fatJar", type = Jar::class) {
4851
}
4952

5053
tasks {
54+
"pmdMain" {
55+
dependsOn(classes)
56+
}
57+
"checkstyleMain" {
58+
dependsOn(classes)
59+
}
60+
"pmdTest" {
61+
dependsOn(testClasses)
62+
}
63+
"checkstyleTest" {
64+
dependsOn(testClasses)
65+
}
66+
"jacocoTestReport" {
67+
dependsOn(test)
68+
}
5169
"build" {
5270
dependsOn(fatJar)
5371
}
@@ -76,6 +94,55 @@ tasks.getByName("build") {
7694
tasks.getByName<Test>("test") {
7795
useJUnitPlatform()
7896
systemProperty("candidates", System.getProperty("candidates"))
97+
finalizedBy(tasks.getByName("jacocoTestReport"))
98+
}
99+
100+
pmd {
101+
isIgnoreFailures = true
102+
isConsoleOutput = false
103+
toolVersion = "6.40.0"
104+
rulesMinimumPriority.set(5)
105+
}
106+
107+
108+
checkstyle {
109+
toolVersion = "9.1"
110+
isShowViolations = false
111+
isIgnoreFailures = true
112+
}
113+
114+
tasks.withType<Checkstyle>().configureEach {
115+
reports {
116+
xml.required.set(false)
117+
html.required.set(true)
118+
html.stylesheet = resources.text.fromFile("config/xsl/checkstyle-simple.xsl")
119+
}
120+
}
121+
tasks.withType<JacocoCoverageVerification> {
122+
/*violationRules {
123+
rule {
124+
limit {
125+
minimum = BigDecimal(0.62)
126+
}
127+
}
128+
}*/
129+
130+
afterEvaluate {
131+
classDirectories.setFrom(files(classDirectories.files.map {
132+
fileTree(it).apply {
133+
exclude("parser/**")
134+
}
135+
}))
136+
}
137+
}
138+
tasks.withType<JacocoReport> {
139+
afterEvaluate {
140+
classDirectories.setFrom(files(classDirectories.files.map {
141+
fileTree(it).apply {
142+
exclude("parser/**")
143+
}
144+
}))
145+
}
79146
}
80147

81148
/**

config/checkstyle/checkstyle.xml

Lines changed: 361 additions & 0 deletions
Large diffs are not rendered by default.

config/xsl/checkstyle-simple.xsl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0"?>
2+
3+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4+
5+
<xsl:template match="/">
6+
<html>
7+
<head>
8+
<title>Sun Coding Style Violations</title>
9+
</head>
10+
<body bgcolor="#FFFFEF">
11+
<p><b>Coding Style Check Results</b></p>
12+
<table border="1" cellspacing="0" cellpadding="2">
13+
<tr bgcolor="#CC9966">
14+
<th colspan="2"><b>Summary</b></th>
15+
</tr>
16+
<tr bgcolor="#CCF3D0">
17+
<td>Total files checked</td>
18+
<td><xsl:number level="any" value="count(descendant::file)"/></td>
19+
</tr>
20+
<tr bgcolor="#F3F3E1">
21+
<td>Files with errors</td>
22+
<td><xsl:number level="any" value="count(descendant::file[error])"/></td>
23+
</tr>
24+
<tr bgcolor="#CCF3D0">
25+
<td>Total errors</td>
26+
<td><xsl:number level="any" value="count(descendant::error)"/></td>
27+
</tr>
28+
<tr bgcolor="#F3F3E1">
29+
<td>Errors per file</td>
30+
<td><xsl:number level="any" value="count(descendant::error) div count(descendant::file)"/></td>
31+
</tr>
32+
</table>
33+
<hr align="left" width="95%" size="1"/>
34+
<p>The following are violations of the Sun Coding-Style Standards:</p>
35+
<p/>
36+
<xsl:apply-templates/>
37+
</body>
38+
</html>
39+
</xsl:template>
40+
41+
<xsl:template match="file[error]">
42+
<table bgcolor="#AFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2">
43+
<tr>
44+
<th> File: </th>
45+
<td>
46+
<xsl:value-of select="@name"/>
47+
</td>
48+
</tr>
49+
</table>
50+
<table bgcolor="#DFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2">
51+
<tr>
52+
<th> Line Number </th>
53+
<th> Error Message </th>
54+
</tr>
55+
<xsl:apply-templates select="error"/>
56+
</table>
57+
<p/>
58+
</xsl:template>
59+
60+
<xsl:template match="error">
61+
<tr>
62+
<td>
63+
<xsl:value-of select="@line"/>
64+
</td>
65+
<td>
66+
<xsl:value-of select="@message"/>
67+
</td>
68+
</tr>
69+
</xsl:template>
70+
71+
</xsl:stylesheet>

0 commit comments

Comments
 (0)