Skip to content

Commit 277a725

Browse files
committed
[MPMD-391] Log what developers care about and not what they don't
* Don't log PMD/CPD version for report mojos since report output will contain it anyway. * Log PMD/CPD failures and warnings at WARNING level to draw attention. * Don't log PMD/CPD version for check mojos by default. * Integrate PMD/CPD version into failure message only. This closes #156
1 parent 7a3b2c2 commit 277a725

31 files changed

Lines changed: 144 additions & 113 deletions

File tree

src/it/MPMD-163/verify.groovy

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* Licensed to the Apache Software Foundation (ASF) under one
43
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +17,16 @@
1817
* under the License.
1918
*/
2019

20+
import groovy.xml.XmlSlurper
21+
2122
File buildLog = new File( basedir, 'build.log' )
2223
assert buildLog.exists()
2324

24-
assert 1 == buildLog.getText().count('You have 1 warning')
25-
assert 1 == buildLog.getText().count("PMD Warning: Foo:23 Rule:UnusedFormalParameter Priority:3 Avoid unused constructor parameters such as 'foo'..")
25+
File pmdXml = new File( basedir, "target/pmd.xml" )
26+
assert pmdXml.exists()
27+
28+
def pmd = new XmlSlurper().parse( pmdXml )
29+
def version = pmd.@version
30+
31+
assert buildLog.getText().contains('[WARNING] PMD ' + version + ' has issued 1 warning. For more details see:')
32+
assert buildLog.getText().contains("[WARNING] PMD Warning: Foo:23 Rule:UnusedFormalParameter Priority:3 Avoid unused constructor parameters such as 'foo'..")

src/it/MPMD-205-pmd-js-check/verify.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
File buildLog = new File( basedir, 'build.log' )
2121
assert buildLog.exists()
2222

23-
assert buildLog.getText().contains("[INFO] PMD Failure: PmdJsCheck.js:23 Rule:GlobalVariable Priority:1 Avoid using global variables.");
23+
assert buildLog.getText().contains("[WARNING] PMD Failure: PmdJsCheck.js:23 Rule:GlobalVariable Priority:1 Avoid using global variables.");

src/it/MPMD-243-excludeFromFailureFile/invoker.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@
1616
# under the License.
1717

1818
invoker.goals = clean pmd:check
19-
invoker.maven.version = 3+

src/it/MPMD-243-excludeFromFailureFile/verify.groovy

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@
1717
* under the License.
1818
*/
1919

20+
import groovy.xml.XmlSlurper
21+
2022
File buildLog = new File( basedir, 'build.log' )
2123
assert buildLog.exists()
22-
assert buildLog.text.contains( "PMD Warning: com.example.ClassWithLotsOfStaticImports" )
23-
assert buildLog.text.contains( "You have 1 warning. For more details see" )
24+
25+
File pmdXml = new File( basedir, "target/pmd.xml" )
26+
assert pmdXml.exists()
27+
28+
def pmd = new XmlSlurper().parse( pmdXml )
29+
def version = pmd.@version
30+
31+
assert buildLog.text.contains( "[WARNING] PMD Warning: com.example.ClassWithLotsOfStaticImports" )
32+
assert buildLog.text.contains( "[WARNING] PMD " + version + " has issued 1 warning. For more details see:" )

src/it/MPMD-270-325-JDK11/verify.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020

2121
File buildLog = new File( basedir, 'build.log' )
2222
assert buildLog.exists()
23-
assert buildLog.text.contains( '[INFO] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )
24-
assert !buildLog.text.contains( '[WARNING] PMD' )
23+
assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )

src/it/MPMD-280-JDK12/verify.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020

2121
File buildLog = new File( basedir, 'build.log' )
2222
assert buildLog.exists()
23-
assert buildLog.text.contains( '[INFO] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )
24-
assert !buildLog.text.contains( '[WARNING] PMD' )
23+
assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )

src/it/MPMD-290-cpd-for-csharp/invoker.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
invoker.maven.version = 3.3+
1918
invoker.goals = clean verify
2019
invoker.buildResult = failure
21-
invoker.debug = true

src/it/MPMD-290-cpd-for-csharp/verify.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* Licensed to the Apache Software Foundation (ASF) under one
43
* or more contributor license agreements. See the NOTICE file
@@ -18,15 +17,20 @@
1817
* under the License.
1918
*/
2019

20+
import groovy.xml.XmlSlurper
21+
2122
File buildLog = new File( basedir, 'build.log' )
2223
assert buildLog.exists()
2324

24-
assert buildLog.text.contains( "[INFO] CPD Failure: Found 7 lines of duplicated code at locations" )
25-
assert buildLog.text.contains( "[DEBUG] PMD failureCount: 1, warningCount: 0" )
26-
2725
File cpdXml = new File( basedir, 'target/cpd.xml' )
2826
assert cpdXml.exists()
2927

28+
def cpd = new XmlSlurper().parse( cpdXml )
29+
def pmdVersion = cpd.@pmdVersion
30+
31+
assert buildLog.text.contains( "[WARNING] CPD Failure: Found 7 lines of duplicated code at locations" )
32+
assert buildLog.text.contains( "CPD " + pmdVersion + " has found 1 duplication. For more details see:" )
33+
3034
// no duplication for the license header - if this is reported, then CPD uses the wrong language/tokenizer
3135
assert !cpdXml.text.contains( '<duplication lines="20" tokens="148">' )
3236
assert !cpdXml.text.contains( 'line="1"' )

src/it/MPMD-295-JDK13/verify.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020

2121
File buildLog = new File( basedir, 'build.log' )
2222
assert buildLog.exists()
23-
assert buildLog.text.contains( '[INFO] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )
24-
assert !buildLog.text.contains( '[WARNING] PMD' )
23+
assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )

src/it/MPMD-302-JDK14/verify.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020

2121
File buildLog = new File( basedir, 'build.log' )
2222
assert buildLog.exists()
23-
assert buildLog.text.contains( '[INFO] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )
24-
assert !buildLog.text.contains( '[WARNING] PMD' )
23+
assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' )

0 commit comments

Comments
 (0)