This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git
commit 43444d65530b9daa9da1455526274a2f798c0dbc Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 25 23:06:54 2026 +0000 Format Groovy IT scripts Formatting only: the CONVERSION-phase AST of every file is unchanged. See https://github.com/apache/maven-invoker-plugin/issues/811. --- src/it/MPMD-128-xref-link/verify.groovy | 6 +- src/it/MPMD-172-no-xref-warning/verify.groovy | 2 +- src/it/MPMD-234-analysis-cache/verify.groovy | 10 +-- src/it/MPMD-244-logging/verify.groovy | 14 ++-- .../MPMD-253-xref-link-multi-module/verify.groovy | 6 +- src/it/MPMD-258-multiple-executions/verify.groovy | 6 +- .../verify.groovy | 6 +- .../verify.groovy | 12 ++-- src/it/MPMD-277-multi-module-check/verify.groovy | 6 +- src/it/MPMD-283-aggregated-pmd/verify.groovy | 50 ++++++-------- src/it/MPMD-304-toolchain-support/verify.groovy | 38 +++++------ src/it/MPMD-317-318-auxclasspath/verify.groovy | 38 +++++------ src/it/MPMD-323-multi-module-basedir/verify.groovy | 13 ++-- .../MPMD-323-ruleset-basedir-jgitver/verify.groovy | 2 +- .../verify.groovy | 8 +-- src/it/MPMD-89-232-typeresolution/verify.groovy | 2 +- .../verify.groovy | 12 ++-- .../auxclasspath-with-java-runtime-8/verify.groovy | 12 ++-- .../verify.groovy | 14 ++-- src/it/empty-rulesets/verify.groovy | 8 +-- src/it/mpmd-138-multimodule/verify.groovy | 18 ++--- .../verify.groovy | 22 +++---- src/it/mpmd-168-skip-empty-report/verify.groovy | 18 ++--- src/it/multi-module/verify.groovy | 76 +++++++++------------- src/it/targetJdk-11-MPMD-270-325/verify.groovy | 4 +- src/it/targetJdk-17-MPMD-312/verify.groovy | 4 +- src/it/targetJdk-21-MPMD-379/verify.groovy | 4 +- src/it/targetJdk-25/verify.groovy | 4 +- src/it/targetJdk-8/verify.groovy | 4 +- 29 files changed, 199 insertions(+), 220 deletions(-) diff --git a/src/it/MPMD-128-xref-link/verify.groovy b/src/it/MPMD-128-xref-link/verify.groovy index 2c64027..2acaf95 100644 --- a/src/it/MPMD-128-xref-link/verify.groovy +++ b/src/it/MPMD-128-xref-link/verify.groovy @@ -18,10 +18,10 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -File report = new File( basedir, 'target/site/pmd.html' ) +File report = new File(basedir, 'target/site/pmd.html') assert report.exists() -assert 1 == report.getText().count( 'xref/mpmd128/App.html#L32' ) +assert 1 == report.getText().count('xref/mpmd128/App.html#L32') diff --git a/src/it/MPMD-172-no-xref-warning/verify.groovy b/src/it/MPMD-172-no-xref-warning/verify.groovy index 81e979e..4aa7f69 100644 --- a/src/it/MPMD-172-no-xref-warning/verify.groovy +++ b/src/it/MPMD-172-no-xref-warning/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() // This warning should not appear in the log diff --git a/src/it/MPMD-234-analysis-cache/verify.groovy b/src/it/MPMD-234-analysis-cache/verify.groovy index 33ed1e5..72d1ec4 100644 --- a/src/it/MPMD-234-analysis-cache/verify.groovy +++ b/src/it/MPMD-234-analysis-cache/verify.groovy @@ -17,16 +17,16 @@ * under the License. */ -File cacheFile = new File( basedir, 'no-analysis-cache/target/pmd/pmd.cache' ) +File cacheFile = new File(basedir, 'no-analysis-cache/target/pmd/pmd.cache') assert !cacheFile.exists() -File defaultAnalysisCacheLocation = new File( basedir, 'default-analysis-cache/target/pmd/pmd.cache' ) +File defaultAnalysisCacheLocation = new File(basedir, 'default-analysis-cache/target/pmd/pmd.cache') assert defaultAnalysisCacheLocation.exists() -File customCacheLocation = new File( basedir, 'custom-analysis-cache/target/custom-analysis-pmd.cache' ) +File customCacheLocation = new File(basedir, 'custom-analysis-cache/target/custom-analysis-pmd.cache') assert customCacheLocation.exists() -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert !buildLog.text.contains( 'This analysis could be faster, please consider using Incremental Analysis' ) +assert !buildLog.text.contains('This analysis could be faster, please consider using Incremental Analysis') diff --git a/src/it/MPMD-244-logging/verify.groovy b/src/it/MPMD-244-logging/verify.groovy index a974937..dcb8237 100644 --- a/src/it/MPMD-244-logging/verify.groovy +++ b/src/it/MPMD-244-logging/verify.groovy @@ -17,18 +17,18 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert buildLog.text.contains( "PMD processing error" ) -assert buildLog.text.contains( "ParseException: Parse exception" ) -assert buildLog.text.contains( "at line 24, column 5: Encountered" ) +assert buildLog.text.contains("PMD processing error") +assert buildLog.text.contains("ParseException: Parse exception") +assert buildLog.text.contains("at line 24, column 5: Encountered") -String enabledPath = new File( basedir, 'logging-enabled/src/main/java/BrokenFile.java' ).getCanonicalPath() +String enabledPath = new File(basedir, 'logging-enabled/src/main/java/BrokenFile.java').getCanonicalPath() // logging enabled: the pmd exception is still output only once: through the processing error reporting (since MPMD-246) - PMD 7 doesn't log the processing error additionally -assert 1 == buildLog.text.count( "${enabledPath}: ParseException: Parse exception in" ) +assert 1 == buildLog.text.count("${enabledPath}: ParseException: Parse exception in") // build.log contains the logging from the two PMD executions // only one execution has logging enabled, so we expect only one log output -assert 1 == buildLog.text.count( "[DEBUG] Rules loaded from" ) +assert 1 == buildLog.text.count("[DEBUG] Rules loaded from") // with --debug switch or -X the logging is always enabled and can't be disabled because PMD 7 switched to slf4j diff --git a/src/it/MPMD-253-xref-link-multi-module/verify.groovy b/src/it/MPMD-253-xref-link-multi-module/verify.groovy index e92ea46..0c1bff0 100644 --- a/src/it/MPMD-253-xref-link-multi-module/verify.groovy +++ b/src/it/MPMD-253-xref-link-multi-module/verify.groovy @@ -18,10 +18,10 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -File report = new File( basedir, 'target/site/pmd.html' ) +File report = new File(basedir, 'target/site/pmd.html') assert report.exists() -assert 1 == report.getText().count( 'xref/app/App.html#L32' ) +assert 1 == report.getText().count('xref/app/App.html#L32') diff --git a/src/it/MPMD-258-multiple-executions/verify.groovy b/src/it/MPMD-258-multiple-executions/verify.groovy index d87ef19..5e557ba 100644 --- a/src/it/MPMD-258-multiple-executions/verify.groovy +++ b/src/it/MPMD-258-multiple-executions/verify.groovy @@ -17,13 +17,13 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() // we have 2 modules and for each module this should be output once // note: this is only logged in debug mode by net.sourceforge.pmd.cache.FileAnalysisCache -assert 2 == buildLog.text.count( "[DEBUG] Analysis cache created" ) +assert 2 == buildLog.text.count("[DEBUG] Analysis cache created") // since we are running clean pmd:pmd, the cache is always created, never updated // note: this is only logged in debug mode by net.sourceforge.pmd.cache.FileAnalysisCache -assert 0 == buildLog.text.count( "[DEBUG] Analysis cache updated" ) +assert 0 == buildLog.text.count("[DEBUG] Analysis cache updated") diff --git a/src/it/MPMD-259-analysis-cache-auxclasspath/verify.groovy b/src/it/MPMD-259-analysis-cache-auxclasspath/verify.groovy index 5049123..66880db 100644 --- a/src/it/MPMD-259-analysis-cache-auxclasspath/verify.groovy +++ b/src/it/MPMD-259-analysis-cache-auxclasspath/verify.groovy @@ -17,8 +17,8 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert !buildLog.text.contains( '[ERROR] Incremental analysis can\'t check auxclasspath contents' ) -assert !buildLog.text.contains( '[WARNING] Failure executing PMD: java.io.FileNotFoundException' ) +assert !buildLog.text.contains('[ERROR] Incremental analysis can\'t check auxclasspath contents') +assert !buildLog.text.contains('[WARNING] Failure executing PMD: java.io.FileNotFoundException') diff --git a/src/it/MPMD-266-typeresolution-aggregated/verify.groovy b/src/it/MPMD-266-typeresolution-aggregated/verify.groovy index da8f51f..a45cfa9 100644 --- a/src/it/MPMD-266-typeresolution-aggregated/verify.groovy +++ b/src/it/MPMD-266-typeresolution-aggregated/verify.groovy @@ -17,12 +17,12 @@ * under the License. */ -File pmdXml = new File( basedir, "target/pmd.xml" ) +File pmdXml = new File(basedir, "target/pmd.xml") assert pmdXml.exists() -assert !pmdXml.text.contains( "Avoid unused private methods such as 'doSomething(IModuleA)'." ) -assert !pmdXml.text.contains( "Avoid unused private methods such as 'aPrivateMethod(FieldElement)'." ) +assert !pmdXml.text.contains("Avoid unused private methods such as 'doSomething(IModuleA)'.") +assert !pmdXml.text.contains("Avoid unused private methods such as 'aPrivateMethod(FieldElement)'.") -File pmdHtml = new File( basedir, "target/site/pmd.html" ) +File pmdHtml = new File(basedir, "target/site/pmd.html") assert pmdHtml.exists() -assert !pmdHtml.text.contains( "Avoid unused private methods such as 'doSomething(IModuleA)'." ) -assert !pmdHtml.text.contains( "Avoid unused private methods such as 'aPrivateMethod(FieldElement)'." ) +assert !pmdHtml.text.contains("Avoid unused private methods such as 'doSomething(IModuleA)'.") +assert !pmdHtml.text.contains("Avoid unused private methods such as 'aPrivateMethod(FieldElement)'.") diff --git a/src/it/MPMD-277-multi-module-check/verify.groovy b/src/it/MPMD-277-multi-module-check/verify.groovy index ac95dd7..a38dead 100644 --- a/src/it/MPMD-277-multi-module-check/verify.groovy +++ b/src/it/MPMD-277-multi-module-check/verify.groovy @@ -17,7 +17,7 @@ * under the License. */ -File pmdXml = new File( basedir, "target/pmd.xml" ) +File pmdXml = new File(basedir, "target/pmd.xml") assert pmdXml.exists() -assert !pmdXml.text.contains( "Avoid unused private methods such as 'doSomething(IModuleA)'." ) -assert !pmdXml.text.contains( "Avoid unused private methods such as 'aPrivateMethod(FieldElement)'." ) +assert !pmdXml.text.contains("Avoid unused private methods such as 'doSomething(IModuleA)'.") +assert !pmdXml.text.contains("Avoid unused private methods such as 'aPrivateMethod(FieldElement)'.") diff --git a/src/it/MPMD-283-aggregated-pmd/verify.groovy b/src/it/MPMD-283-aggregated-pmd/verify.groovy index f6d1d28..879c63b 100644 --- a/src/it/MPMD-283-aggregated-pmd/verify.groovy +++ b/src/it/MPMD-283-aggregated-pmd/verify.groovy @@ -17,45 +17,35 @@ * under the License. */ -def paths = [ - "target/site/pmd.html", - "target/site/cpd.html", - "target/pmd.xml", - "target/cpd.xml", -] +def paths = ["target/site/pmd.html", "target/site/cpd.html", "target/pmd.xml", "target/cpd.xml",] // aggregated reports must exist -for ( String path : paths ) -{ - File file = new File( basedir, path ) - System.out.println( "Checking for existence of " + file ) - if ( !file.isFile() ) - { - throw new RuntimeException( "Missing: " + file ) +for (String path : paths) { + File file = new File(basedir, path) + System.out.println("Checking for existence of " + file) + if (!file.isFile()) { + throw new RuntimeException("Missing: " + file) } } // double check violations: these violations only appear, if type resolution didn't work // in case the modules have not been compiled before -File pmdXml = new File( basedir, "target/pmd.xml" ) -assert !pmdXml.text.contains( "Avoid unused private methods such as 'doSomething(IModuleA)'." ) -assert !pmdXml.text.contains( "Avoid unused private methods such as 'aPrivateMethod(FieldElement)'." ) +File pmdXml = new File(basedir, "target/pmd.xml") +assert !pmdXml.text.contains("Avoid unused private methods such as 'doSomething(IModuleA)'.") +assert !pmdXml.text.contains("Avoid unused private methods such as 'aPrivateMethod(FieldElement)'.") -File pmdHtml = new File( basedir, "target/site/pmd.html" ) -assert !pmdHtml.text.contains( "Avoid unused private methods such as 'doSomething(IModuleA)'." ) -assert !pmdHtml.text.contains( "Avoid unused private methods such as 'aPrivateMethod(FieldElement)'." ) +File pmdHtml = new File(basedir, "target/site/pmd.html") +assert !pmdHtml.text.contains("Avoid unused private methods such as 'doSomething(IModuleA)'.") +assert !pmdHtml.text.contains("Avoid unused private methods such as 'aPrivateMethod(FieldElement)'.") // no individual module reports -def modules = [ "module-a", "module-b" ] -for ( String module : modules ) -{ - for ( String path : paths ) - { - File file = new File( basedir, "${module}/${path}" ) - System.out.println( "Checking for absence of " + file ) - if ( file.exists() ) - { - throw new RuntimeException( "Banned: " + file ) +def modules = ["module-a", "module-b"] +for (String module : modules) { + for (String path : paths) { + File file = new File(basedir, "${module}/${path}") + System.out.println("Checking for absence of " + file) + if (file.exists()) { + throw new RuntimeException("Banned: " + file) + } } - } } diff --git a/src/it/MPMD-304-toolchain-support/verify.groovy b/src/it/MPMD-304-toolchain-support/verify.groovy index d73cba8..7d206c5 100644 --- a/src/it/MPMD-304-toolchain-support/verify.groovy +++ b/src/it/MPMD-304-toolchain-support/verify.groovy @@ -19,41 +19,41 @@ import groovy.xml.XmlSlurper -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -File pmdXml = new File( basedir, "target/pmd.xml" ) +File pmdXml = new File(basedir, "target/pmd.xml") assert pmdXml.exists() -def pmd = new XmlSlurper().parse( pmdXml ) +def pmd = new XmlSlurper().parse(pmdXml) def version = pmd.@version -File cpdXml = new File( basedir, 'target/cpd.xml' ) +File cpdXml = new File(basedir, 'target/cpd.xml') assert cpdXml.exists() -def cpd = new XmlSlurper().parse( cpdXml ) +def cpd = new XmlSlurper().parse(cpdXml) def pmdVersion = cpd.@pmdVersion -assert buildLog.text.contains( '[INFO] Toolchain in maven-pmd-plugin: JDK[' ) -assert buildLog.text.contains( '[WARNING] PMD Failure: sample.Sample:24 Rule:ExtendsObject' ) -assert buildLog.text.contains( '[WARNING] PMD Failure: sample.Sample:36 Rule:DontCallThreadRun' ) +assert buildLog.text.contains('[INFO] Toolchain in maven-pmd-plugin: JDK[') +assert buildLog.text.contains('[WARNING] PMD Failure: sample.Sample:24 Rule:ExtendsObject') +assert buildLog.text.contains('[WARNING] PMD Failure: sample.Sample:36 Rule:DontCallThreadRun') assert buildLog.text.contains('[WARNING] PMD ' + version + ' has found 2 violations. For more details see:') assert buildLog.text.contains('[WARNING] CPD ' + pmdVersion + ' has found 1 duplication. For more details see:') -assert pmdXml.text.contains( '<violation beginline="24" endline="24" begincolumn="29" endcolumn="35" rule="ExtendsObject"' ) -assert pmdXml.text.contains( '<violation beginline="36" endline="36" begincolumn="9" endcolumn="32" rule="DontCallThreadRun"' ) +assert pmdXml.text.contains('<violation beginline="24" endline="24" begincolumn="29" endcolumn="35" rule="ExtendsObject"') +assert pmdXml.text.contains('<violation beginline="36" endline="36" begincolumn="9" endcolumn="32" rule="DontCallThreadRun"') -File pmdHtmlReport = new File( basedir, 'target/reports/pmd.html' ) +File pmdHtmlReport = new File(basedir, 'target/reports/pmd.html') assert pmdHtmlReport.exists() -assert pmdHtmlReport.text.contains( 'Sample.java' ) -assert pmdHtmlReport.text.contains( 'ExtendsObject' ) -assert pmdHtmlReport.text.contains( 'DontCallThreadRun' ) +assert pmdHtmlReport.text.contains('Sample.java') +assert pmdHtmlReport.text.contains('ExtendsObject') +assert pmdHtmlReport.text.contains('DontCallThreadRun') -assert cpdXml.text.contains( 'Name.java' ) -assert cpdXml.text.contains( 'Name2.java' ) +assert cpdXml.text.contains('Name.java') +assert cpdXml.text.contains('Name2.java') -File cpdHtmlReport = new File( basedir, 'target/reports/cpd.html' ) +File cpdHtmlReport = new File(basedir, 'target/reports/cpd.html') assert cpdHtmlReport.exists() -assert cpdHtmlReport.text.contains( 'Name.java' ) -assert cpdHtmlReport.text.contains( 'Name2.java' ) +assert cpdHtmlReport.text.contains('Name.java') +assert cpdHtmlReport.text.contains('Name2.java') diff --git a/src/it/MPMD-317-318-auxclasspath/verify.groovy b/src/it/MPMD-317-318-auxclasspath/verify.groovy index 76bee03..e5236d6 100644 --- a/src/it/MPMD-317-318-auxclasspath/verify.groovy +++ b/src/it/MPMD-317-318-auxclasspath/verify.groovy @@ -17,15 +17,15 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() // build.log holds all four invocations, in order def auxclasspathLines = [] -for ( String line : buildLog.readLines() ) { - if ( line.contains( 'aux classpath:' ) ) { - // convert windows path names - auxclasspathLines << line.replaceAll( '\\\\', '/' ) +for (String line : buildLog.readLines()) { + if (line.contains('aux classpath:')) { + // convert windows path names + auxclasspathLines << line.replaceAll('\\\\', '/') } } @@ -35,28 +35,28 @@ def auxAggregated = auxclasspathLines[1] def auxIncludeTests = auxclasspathLines[2] def auxAggregatedIncludeTests = auxclasspathLines[3] -assert aux.contains( '[DEBUG] Using aux classpath:' ) -assert auxAggregated.contains( '[DEBUG] Using aggregated aux classpath:' ) -assert auxIncludeTests.contains( '[DEBUG] Using aux classpath:' ) -assert auxAggregatedIncludeTests.contains( '[DEBUG] Using aggregated aux classpath:' ) +assert aux.contains('[DEBUG] Using aux classpath:') +assert auxAggregated.contains('[DEBUG] Using aggregated aux classpath:') +assert auxIncludeTests.contains('[DEBUG] Using aux classpath:') +assert auxAggregatedIncludeTests.contains('[DEBUG] Using aggregated aux classpath:') -for ( String line : auxclasspathLines ) { - assert line.contains( 'module-a/target/classes' ) +for (String line : auxclasspathLines) { + assert line.contains('module-a/target/classes') // compile - assert line.contains( 'org/apache/commons/commons-lang3/3.18.0/commons-lang3-3.18.0.jar' ) + assert line.contains('org/apache/commons/commons-lang3/3.18.0/commons-lang3-3.18.0.jar') // provided - assert line.contains( 'javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar' ) + assert line.contains('javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar') } // includeTests is off -for ( String line : [ aux, auxAggregated ] ) { - assert !line.contains( 'module-a/target/test-classes' ) - assert !line.contains( 'commons-io/commons-io/2.14.0/commons-io-2.14.0.jar' ) +for (String line : [aux, auxAggregated]) { + assert !line.contains('module-a/target/test-classes') + assert !line.contains('commons-io/commons-io/2.14.0/commons-io-2.14.0.jar') } // includeTests is on -for ( String line : [ auxIncludeTests, auxAggregatedIncludeTests ] ) { - assert line.contains( 'module-a/target/test-classes' ) +for (String line : [auxIncludeTests, auxAggregatedIncludeTests]) { + assert line.contains('module-a/target/test-classes') // test - assert line.contains( 'commons-io/commons-io/2.14.0/commons-io-2.14.0.jar' ) + assert line.contains('commons-io/commons-io/2.14.0/commons-io-2.14.0.jar') } diff --git a/src/it/MPMD-323-multi-module-basedir/verify.groovy b/src/it/MPMD-323-multi-module-basedir/verify.groovy index 998f44c..c401d83 100644 --- a/src/it/MPMD-323-multi-module-basedir/verify.groovy +++ b/src/it/MPMD-323-multi-module-basedir/verify.groovy @@ -17,12 +17,15 @@ * under the License. */ -String[] files = [ "module-a/target/pmd.xml", "module-a/target/pmd/rulesets/001-ruleset.xml", - "module-b/target/pmd.xml", "module-b/target/pmd/rulesets/001-ruleset.xml" ] +String[] files = [ + "module-a/target/pmd.xml", + "module-a/target/pmd/rulesets/001-ruleset.xml", + "module-b/target/pmd.xml", + "module-b/target/pmd/rulesets/001-ruleset.xml" +] -files.each -{ - File f = new File( basedir, it ) +files.each { + File f = new File(basedir, it) assert f.exists() } diff --git a/src/it/MPMD-323-ruleset-basedir-jgitver/verify.groovy b/src/it/MPMD-323-ruleset-basedir-jgitver/verify.groovy index 4326fc2..b441903 100644 --- a/src/it/MPMD-323-ruleset-basedir-jgitver/verify.groovy +++ b/src/it/MPMD-323-ruleset-basedir-jgitver/verify.groovy @@ -17,5 +17,5 @@ * under the License. */ -File pmdXml = new File( basedir, "target/pmd.xml" ) +File pmdXml = new File(basedir, "target/pmd.xml") assert pmdXml.exists() diff --git a/src/it/MPMD-335-aggregate-classpath-repositories/verify.groovy b/src/it/MPMD-335-aggregate-classpath-repositories/verify.groovy index 4274014..e4d9b22 100644 --- a/src/it/MPMD-335-aggregate-classpath-repositories/verify.groovy +++ b/src/it/MPMD-335-aggregate-classpath-repositories/verify.groovy @@ -17,8 +17,8 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert !buildLog.text.contains( 'pmd failed: org.apache.maven.reporting.MavenReportException' ) -assert !buildLog.text.contains( 'org.eclipse.aether.resolution.DependencyResolutionException' ) -assert !buildLog.text.contains( 'Could not find artifact org.apache.maven.plugins.pmd.it:mpmd335-dependency1:pom:1.0.0-SNAPSHOT' ) +assert !buildLog.text.contains('pmd failed: org.apache.maven.reporting.MavenReportException') +assert !buildLog.text.contains('org.eclipse.aether.resolution.DependencyResolutionException') +assert !buildLog.text.contains('Could not find artifact org.apache.maven.plugins.pmd.it:mpmd335-dependency1:pom:1.0.0-SNAPSHOT') diff --git a/src/it/MPMD-89-232-typeresolution/verify.groovy b/src/it/MPMD-89-232-typeresolution/verify.groovy index bf80a29..b441903 100644 --- a/src/it/MPMD-89-232-typeresolution/verify.groovy +++ b/src/it/MPMD-89-232-typeresolution/verify.groovy @@ -17,5 +17,5 @@ * under the License. */ -File pmdXml = new File( basedir, "target/pmd.xml" ); +File pmdXml = new File(basedir, "target/pmd.xml") assert pmdXml.exists() diff --git a/src/it/auxclasspath-with-java-runtime-11/verify.groovy b/src/it/auxclasspath-with-java-runtime-11/verify.groovy index 21af998..b7034aa 100644 --- a/src/it/auxclasspath-with-java-runtime-11/verify.groovy +++ b/src/it/auxclasspath-with-java-runtime-11/verify.groovy @@ -17,18 +17,18 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() def auxclasspathLog = '' -for ( String line : buildLog.readLines() ) { - if ( line.contains( 'aux classpath' ) ) { - auxclasspathLog += line + '\n'; +for (String line : buildLog.readLines()) { + if (line.contains('aux classpath')) { + auxclasspathLog += line + '\n' } } // convert windows path names auxclasspathLog = auxclasspathLog.replaceAll('\\\\', '/') -assert 1 == auxclasspathLog.count( '[DEBUG] Using aux classpath:' ) -assert 1 == auxclasspathLog.count( 'lib/jrt-fs.jar to aux classpath' ) +assert 1 == auxclasspathLog.count('[DEBUG] Using aux classpath:') +assert 1 == auxclasspathLog.count('lib/jrt-fs.jar to aux classpath') diff --git a/src/it/auxclasspath-with-java-runtime-8/verify.groovy b/src/it/auxclasspath-with-java-runtime-8/verify.groovy index d1bb8b7..3f880ec 100644 --- a/src/it/auxclasspath-with-java-runtime-8/verify.groovy +++ b/src/it/auxclasspath-with-java-runtime-8/verify.groovy @@ -17,18 +17,18 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() def auxclasspathLog = '' -for ( String line : buildLog.readLines() ) { - if ( line.contains( 'aux classpath' ) ) { - auxclasspathLog += line + '\n'; +for (String line : buildLog.readLines()) { + if (line.contains('aux classpath')) { + auxclasspathLog += line + '\n' } } // convert windows path names auxclasspathLog = auxclasspathLog.replaceAll('\\\\', '/') -assert 1 == auxclasspathLog.count( '[DEBUG] Using aux classpath:' ) -assert 1 == auxclasspathLog.count( 'lib/rt.jar to aux classpath' ) +assert 1 == auxclasspathLog.count('[DEBUG] Using aux classpath:') +assert 1 == auxclasspathLog.count('lib/rt.jar to aux classpath') diff --git a/src/it/auxclasspath-with-java-runtime-missing/verify.groovy b/src/it/auxclasspath-with-java-runtime-missing/verify.groovy index 643a7a6..d3f9999 100644 --- a/src/it/auxclasspath-with-java-runtime-missing/verify.groovy +++ b/src/it/auxclasspath-with-java-runtime-missing/verify.groovy @@ -17,19 +17,19 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() def auxclasspathLog = '' -for ( String line : buildLog.readLines() ) { - if ( line.contains( 'aux classpath' ) ) { - auxclasspathLog += line + '\n'; +for (String line : buildLog.readLines()) { + if (line.contains('aux classpath')) { + auxclasspathLog += line + '\n' } } // convert windows path names auxclasspathLog = auxclasspathLog.replaceAll('\\\\', '/') -assert 1 == auxclasspathLog.count( '[DEBUG] Using aux classpath:' ) -assert 1 == auxclasspathLog.count( '[WARNING] Adding current java runtime' ) -assert 1 == auxclasspathLog.count( 'lib/jrt-fs.jar to aux classpath' ) +assert 1 == auxclasspathLog.count('[DEBUG] Using aux classpath:') +assert 1 == auxclasspathLog.count('[WARNING] Adding current java runtime') +assert 1 == auxclasspathLog.count('lib/jrt-fs.jar to aux classpath') diff --git a/src/it/empty-rulesets/verify.groovy b/src/it/empty-rulesets/verify.groovy index aecbec8..674b4ab 100644 --- a/src/it/empty-rulesets/verify.groovy +++ b/src/it/empty-rulesets/verify.groovy @@ -18,11 +18,11 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() // <rulesets/> configures no rule at all: Foo.java has an unused constructor parameter, which the default ruleset reports -File pmdXml = new File( basedir, 'target/pmd.xml' ) +File pmdXml = new File(basedir, 'target/pmd.xml') assert pmdXml.exists() -assert pmdXml.getText( 'UTF-8' ).contains( '</pmd>' ) -assert !pmdXml.getText( 'UTF-8' ).contains( '<violation' ) +assert pmdXml.getText('UTF-8').contains('</pmd>') +assert !pmdXml.getText('UTF-8').contains('<violation') diff --git a/src/it/mpmd-138-multimodule/verify.groovy b/src/it/mpmd-138-multimodule/verify.groovy index bf338a7..393b365 100644 --- a/src/it/mpmd-138-multimodule/verify.groovy +++ b/src/it/mpmd-138-multimodule/verify.groovy @@ -19,14 +19,14 @@ import groovy.xml.XmlSlurper -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() // Module 1 -File pmdXml = new File( basedir, "mod-1/target/pmd.xml" ) +File pmdXml = new File(basedir, "mod-1/target/pmd.xml") assert pmdXml.exists() -def pmd = new XmlSlurper().parse( pmdXml ) +def pmd = new XmlSlurper().parse(pmdXml) def version = pmd.@version assert buildLog.getText().contains('[WARNING] PMD Failure: test.MyClass:27 Rule:UnnecessarySemicolon Priority:3 Unnecessary semicolon') @@ -34,30 +34,30 @@ assert buildLog.getText().contains('[WARNING] PMD Failure: test.MyClass:28 Rule: assert buildLog.getText().contains('[WARNING] PMD ' + version + ' has found 2 violations. For more details see:') // Module 2 -pmdXml = new File( basedir, "mod-2/target/pmd.xml" ) +pmdXml = new File(basedir, "mod-2/target/pmd.xml") assert pmdXml.exists() -pmd = new XmlSlurper().parse( pmdXml ) +pmd = new XmlSlurper().parse(pmdXml) version = pmd.@version assert buildLog.getText().contains('[WARNING] PMD Failure: test.MyClass:24 Rule:UnusedPrivateField Priority:3 Avoid unused private fields such as \'x\'') assert buildLog.getText().contains('[WARNING] PMD ' + version + ' has found 1 violation. For more details see:') // Module 3 -File cpdXml = new File( basedir, "mod-3/target/cpd.xml" ) +File cpdXml = new File(basedir, "mod-3/target/cpd.xml") assert cpdXml.exists() -def cpd = new XmlSlurper().parse( cpdXml ) +def cpd = new XmlSlurper().parse(cpdXml) def pmdVersion = cpd.@pmdVersion assert buildLog.getText().contains('[WARNING] CPD Failure: Found 37 lines of duplicated code at locations:') assert buildLog.getText().contains('[WARNING] CPD ' + pmdVersion + ' has found 1 duplication. For more details see:') // Module 4 -cpdXml = new File( basedir, "mod-4/target/cpd.xml" ) +cpdXml = new File(basedir, "mod-4/target/cpd.xml") assert cpdXml.exists() -cpd = new XmlSlurper().parse( cpdXml ) +cpd = new XmlSlurper().parse(cpdXml) pmdVersion = cpd.@pmdVersion assert buildLog.getText().contains('[WARNING] CPD Failure: Found 35 lines of duplicated code at locations:') diff --git a/src/it/mpmd-168-do-not-skip-empty-report/verify.groovy b/src/it/mpmd-168-do-not-skip-empty-report/verify.groovy index 6ee06d2..b285618 100644 --- a/src/it/mpmd-168-do-not-skip-empty-report/verify.groovy +++ b/src/it/mpmd-168-do-not-skip-empty-report/verify.groovy @@ -17,23 +17,23 @@ * under the License. */ -File targetDir = new File( basedir, "target" ); -File siteDir = new File( targetDir, "site" ); +File targetDir = new File(basedir, "target") +File siteDir = new File(targetDir, "site") -File projectReports = new File( siteDir, "project-reports.html" ) -assert projectReports.getText( "UTF-8" ).contains( "pmd.html" ) -assert projectReports.getText( "UTF-8" ).contains( "cpd.html" ) +File projectReports = new File(siteDir, "project-reports.html") +assert projectReports.getText("UTF-8").contains("pmd.html") +assert projectReports.getText("UTF-8").contains("cpd.html") -File pmdReportInSite = new File( siteDir, "pmd.html" ) +File pmdReportInSite = new File(siteDir, "pmd.html") assert pmdReportInSite.exists() -assert pmdReportInSite.getText( "UTF-8" ).contains( "PMD found no problems in your source code." ) +assert pmdReportInSite.getText("UTF-8").contains("PMD found no problems in your source code.") -File pmdXmlInTarget = new File( targetDir, "pmd.xml" ) +File pmdXmlInTarget = new File(targetDir, "pmd.xml") assert pmdXmlInTarget.exists() -File cpdReportInSite = new File( siteDir, "cpd.html" ) +File cpdReportInSite = new File(siteDir, "cpd.html") assert cpdReportInSite.exists() -assert cpdReportInSite.getText( "UTF-8" ).contains( "CPD found no problems in your source code." ) +assert cpdReportInSite.getText("UTF-8").contains("CPD found no problems in your source code.") -File cpdXmlInTarget = new File( targetDir, "cpd.xml" ) +File cpdXmlInTarget = new File(targetDir, "cpd.xml") assert cpdXmlInTarget.exists() diff --git a/src/it/mpmd-168-skip-empty-report/verify.groovy b/src/it/mpmd-168-skip-empty-report/verify.groovy index f506966..ced01fc 100644 --- a/src/it/mpmd-168-skip-empty-report/verify.groovy +++ b/src/it/mpmd-168-skip-empty-report/verify.groovy @@ -17,21 +17,21 @@ * under the License. */ -File targetDir = new File( basedir, "target" ); -File siteDir = new File( targetDir, "site" ); +File targetDir = new File(basedir, "target") +File siteDir = new File(targetDir, "site") -File projectReports = new File( siteDir, "project-reports.html" ) -assert !projectReports.getText( "UTF-8" ).contains( "pmd.html" ) -assert !projectReports.getText( "UTF-8" ).contains( "cpd.html" ) +File projectReports = new File(siteDir, "project-reports.html") +assert !projectReports.getText("UTF-8").contains("pmd.html") +assert !projectReports.getText("UTF-8").contains("cpd.html") -File pmdReportInSite = new File( siteDir, "pmd.html" ) +File pmdReportInSite = new File(siteDir, "pmd.html") assert !pmdReportInSite.exists() -File pmdXmlInTarget = new File( targetDir, "pmd.xml" ) +File pmdXmlInTarget = new File(targetDir, "pmd.xml") assert pmdXmlInTarget.exists() -File cpdReportInSite = new File( siteDir, "cpd.html" ) +File cpdReportInSite = new File(siteDir, "cpd.html") assert !cpdReportInSite.exists() -File cpdXmlInTarget = new File( targetDir, "cpd.xml" ) +File cpdXmlInTarget = new File(targetDir, "cpd.xml") assert cpdXmlInTarget.exists() diff --git a/src/it/multi-module/verify.groovy b/src/it/multi-module/verify.groovy index c7cc52a..fc00f5c 100644 --- a/src/it/multi-module/verify.groovy +++ b/src/it/multi-module/verify.groovy @@ -19,69 +19,55 @@ import groovy.transform.Field -String[] modules = [ "mod-1", "mod-2", "mod-3" ] as String[]; -@Field String[] paths = [ - "target/site/pmd.html", - "target/site/cpd.html", - "target/pmd.xml", - "target/cpd.xml", -] as String[]; +String[] modules = ["mod-1", "mod-2", "mod-3"] as String[] +@Field String[] paths = ["target/site/pmd.html", "target/site/cpd.html", "target/pmd.xml", "target/cpd.xml",] as String[] // files must exist in every module -for ( String module : modules ) -{ +for (String module : modules) { // PMD and CPD reports - for ( String path : paths ) - { - File file = new File( basedir, module + '/' + path ); - System.out.println( "Checking for existence of " + file ); - if ( !file.isFile() ) - { - throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() ); + for (String path : paths) { + File file = new File(basedir, module + '/' + path) + System.out.println("Checking for existence of " + file) + if (!file.isFile()) { + throw new FileNotFoundException("Missing: " + file.getAbsolutePath()) } } } // files must not exist in parent -for ( String path : paths ) -{ - File file = new File( basedir, path ); - System.out.println( "Checking for absence of " + file ); - if ( file.exists() ) - { - throw new IOException( "Banned: " + file.getAbsolutePath() ); +for (String path : paths) { + File file = new File(basedir, path) + System.out.println("Checking for absence of " + file) + if (file.exists()) { + throw new IOException("Banned: " + file.getAbsolutePath()) } } // check PMD rulesets target copy -File rule = new File( basedir, "mod-1/target/pmd/rulesets/002-latin-1.xml" ); -String nonascii = "-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF\u00BC\u00BD\u00BE\u00A4"; -String content = rule.getText( "ISO-8859-1" ); -assert content.contains( nonascii ) : "non-ascii content corrupted in Latin1." -rule = new File( basedir, "mod-1/target/pmd/rulesets/001-utf-8.xml" ); -content = rule.getText( "UTF-8" ); +File rule = new File(basedir, "mod-1/target/pmd/rulesets/002-latin-1.xml") +String nonascii = "-CHARS: \u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF\u00BC\u00BD\u00BE\u00A4" +String content = rule.getText("ISO-8859-1") +assert content.contains(nonascii) : "non-ascii content corrupted in Latin1." +rule = new File( basedir, "mod-1/target/pmd/rulesets/001-utf-8.xml" ) +content = rule.getText( "UTF-8" ) assert content.contains( nonascii ) : "non-ascii content corrupted in UTF-8." // check xml files encoding -void checkEncoding( String module, String encoding ) -{ - for ( String path : paths ) - { - if ( !path.endsWith( ".xml" ) ) - { - continue; +void checkEncoding( String module, String encoding ) { + for ( String path : paths ) { + if ( !path.endsWith( ".xml" ) ) { + continue } - File file = new File( basedir, module + '/' + path ); - String content = file.getText( encoding ); - if ( !content.startsWith( "<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>" ) ) - { - throw new IOException( "wrong XML encoding declaration for " + file ); + File file = new File( basedir, module + '/' + path ) + String content = file.getText( encoding ) + if ( !content.startsWith( "<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>" ) ) { + throw new IOException( "wrong XML encoding declaration for " + file ) } } } -checkEncoding( "mod-1", "ISO-8859-1" ); -checkEncoding( "mod-2", "UTF-8" ); -checkEncoding( "mod-3", "UTF-8" ); +checkEncoding( "mod-1", "ISO-8859-1" ) +checkEncoding( "mod-2", "UTF-8" ) +checkEncoding( "mod-3", "UTF-8" ) -return true; +return true diff --git a/src/it/targetJdk-11-MPMD-270-325/verify.groovy b/src/it/targetJdk-11-MPMD-270-325/verify.groovy index ab39fcd..0b31ab3 100644 --- a/src/it/targetJdk-11-MPMD-270-325/verify.groovy +++ b/src/it/targetJdk-11-MPMD-270-325/verify.groovy @@ -18,6 +18,6 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' ) +assert buildLog.text.contains('[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3') diff --git a/src/it/targetJdk-17-MPMD-312/verify.groovy b/src/it/targetJdk-17-MPMD-312/verify.groovy index ab39fcd..0b31ab3 100644 --- a/src/it/targetJdk-17-MPMD-312/verify.groovy +++ b/src/it/targetJdk-17-MPMD-312/verify.groovy @@ -18,6 +18,6 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' ) +assert buildLog.text.contains('[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3') diff --git a/src/it/targetJdk-21-MPMD-379/verify.groovy b/src/it/targetJdk-21-MPMD-379/verify.groovy index ab39fcd..0b31ab3 100644 --- a/src/it/targetJdk-21-MPMD-379/verify.groovy +++ b/src/it/targetJdk-21-MPMD-379/verify.groovy @@ -18,6 +18,6 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' ) +assert buildLog.text.contains('[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3') diff --git a/src/it/targetJdk-25/verify.groovy b/src/it/targetJdk-25/verify.groovy index ab39fcd..0b31ab3 100644 --- a/src/it/targetJdk-25/verify.groovy +++ b/src/it/targetJdk-25/verify.groovy @@ -18,6 +18,6 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' ) +assert buildLog.text.contains('[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3') diff --git a/src/it/targetJdk-8/verify.groovy b/src/it/targetJdk-8/verify.groovy index ab39fcd..0b31ab3 100644 --- a/src/it/targetJdk-8/verify.groovy +++ b/src/it/targetJdk-8/verify.groovy @@ -18,6 +18,6 @@ * under the License. */ -File buildLog = new File( basedir, 'build.log' ) +File buildLog = new File(basedir, 'build.log') assert buildLog.exists() -assert buildLog.text.contains( '[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3' ) +assert buildLog.text.contains('[WARNING] PMD Failure: com.mycompany.app.Foo:26 Rule:UnusedFormalParameter Priority:3')
