This is an automated email from the ASF dual-hosted git repository. adangel pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git
commit d1f37cef8e1a34da615ca52b42bfe506884fa810 Author: Andreas Dangel <adan...@apache.org> AuthorDate: Fri Dec 15 19:55:00 2017 +0100 [MPMD-247] Upgrade to PMD 6.0.0 * Provide a new default ruleset: maven-pmd-plugin-default.xml * Update documentation --- .../org/apache/maven/plugins/pmd/PmdReport.java | 10 +- .../rulesets/java/maven-pmd-plugin-default.xml | 94 +++++++++++++++++++ src/site/apt/examples/javascriptReport.apt.vm | 13 ++- src/site/apt/examples/jspReport.apt.vm | 14 ++- src/site/apt/examples/multi-module-config.apt.vm | 30 ++++-- .../apt/examples/upgrading-PMD-at-runtime.apt.vm | 2 +- src/site/apt/examples/usingRuleSets.apt.vm | 104 +++++++++++++++++++-- src/site/apt/index.apt.vm | 18 +++- src/site/apt/usage.apt.vm | 4 +- .../apache/maven/plugins/pmd/PmdReportTest.java | 8 +- 10 files changed, 252 insertions(+), 45 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java index 3d4abf0..7034ad0 100644 --- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java +++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java @@ -119,13 +119,13 @@ public class PmdReport /** * The PMD rulesets to use. See the - * <a href="http://pmd.github.io/pmd-5.5.1/pmd-java/rules/index.html">Stock Java Rulesets</a> for a - * list of some included. Defaults to the java-basic, java-empty, java-imports, java-unnecessary - * and java-unusedcode rulesets. + * <a href="http://pmd.github.io/latest/pmd_rules_java.html">Stock Java Rulesets</a> for a + * list of available rules. + * Defaults to a custom ruleset provided by this maven plugin + * (<code>/rulesets/java/maven-pmd-plugin-default.xml</code>). */ @Parameter - private String[] rulesets = new String[] { "java-basic", "java-empty", "java-imports", - "java-unnecessary", "java-unusedcode" }; + private String[] rulesets = new String[] { "/rulesets/java/maven-pmd-plugin-default.xml" }; /** * Controls whether the project's compile/test classpath should be passed to PMD to enable its type resolution diff --git a/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml b/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml new file mode 100644 index 0000000..aba662e --- /dev/null +++ b/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<ruleset name="Default Maven PMD Plugin Ruleset" + xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> + + <description> + The default ruleset used by the Maven PMD Plugin, when no other ruleset is specified. + It contains the rules of the old (pre PMD 6.0.0) rulesets java-basic, java-empty, java-imports, + java-unnecessary, java-unusedcode. + + This ruleset might be used as a starting point for an own customized ruleset [0]. + + [0] https://pmd.github.io/latest/pmd_userdocs_understanding_rulesets.html + </description> + + <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" /> + <rule ref="category/java/bestpractices.xml/CheckResultSet" /> + <rule ref="category/java/bestpractices.xml/UnusedImports" /> + <rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /> + <rule ref="category/java/bestpractices.xml/UnusedLocalVariable" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateField" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" /> + + <rule ref="category/java/codestyle.xml/DontImportJavaLang" /> + <rule ref="category/java/codestyle.xml/DuplicateImports" /> + <rule ref="category/java/codestyle.xml/ExtendsObject" /> + <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" /> + <rule ref="category/java/codestyle.xml/TooManyStaticImports" /> + <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" /> + <rule ref="category/java/codestyle.xml/UnnecessaryModifier" /> + <rule ref="category/java/codestyle.xml/UnnecessaryReturn" /> + <rule ref="category/java/codestyle.xml/UselessParentheses" /> + <rule ref="category/java/codestyle.xml/UselessQualifiedThis" /> + + <rule ref="category/java/design.xml/CollapsibleIfStatements" /> + <rule ref="category/java/design.xml/SimplifiedTernary" /> + <rule ref="category/java/design.xml/UselessOverridingMethod" /> + + <rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" /> + <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" /> + <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" /> + <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" /> + <rule ref="category/java/errorprone.xml/BrokenNullCheck" /> + <rule ref="category/java/errorprone.xml/CheckSkipResult" /> + <rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" /> + <rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" /> + <rule ref="category/java/errorprone.xml/EmptyCatchBlock" /> + <rule ref="category/java/errorprone.xml/EmptyFinallyBlock" /> + <rule ref="category/java/errorprone.xml/EmptyIfStmt" /> + <rule ref="category/java/errorprone.xml/EmptyInitializer" /> + <rule ref="category/java/errorprone.xml/EmptyStatementBlock" /> + <rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop" /> + <rule ref="category/java/errorprone.xml/EmptyStaticInitializer" /> + <rule ref="category/java/errorprone.xml/EmptySwitchStatements" /> + <rule ref="category/java/errorprone.xml/EmptySynchronizedBlock" /> + <rule ref="category/java/errorprone.xml/EmptyTryBlock" /> + <rule ref="category/java/errorprone.xml/EmptyWhileStmt" /> + <rule ref="category/java/errorprone.xml/ImportFromSamePackage" /> + <rule ref="category/java/errorprone.xml/JumbledIncrementer" /> + <rule ref="category/java/errorprone.xml/MisplacedNullCheck" /> + <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" /> + <rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" /> + <rule ref="category/java/errorprone.xml/UnconditionalIfStatement" /> + <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" /> + <rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" /> + <rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" /> + + <rule ref="category/java/multithreading.xml/AvoidThreadGroup" /> + <rule ref="category/java/multithreading.xml/DontCallThreadRun" /> + <rule ref="category/java/multithreading.xml/DoubleCheckedLocking" /> + + <rule ref="category/java/performance.xml/BigIntegerInstantiation" /> + <rule ref="category/java/performance.xml/BooleanInstantiation" /> + +</ruleset> \ No newline at end of file diff --git a/src/site/apt/examples/javascriptReport.apt.vm b/src/site/apt/examples/javascriptReport.apt.vm index 7adf7b4..5159d64 100644 --- a/src/site/apt/examples/javascriptReport.apt.vm +++ b/src/site/apt/examples/javascriptReport.apt.vm @@ -3,7 +3,7 @@ ------ Andreas Dangel ------ - 2012-05-23 + 2017-11-11 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one @@ -31,10 +31,13 @@ Analyzing JavaScript Code The PMD plugin analyzes Java by default. You can configure it to analyze JavaScript files instead as shown below. The example assumes that the JavaScript source code is stored in the subdirectory <<<src/main/javascript>>> and - enables three built-in rulesets (<basic>, <braces>, <unnecessary>). + enables all rules from the "Best Practices", "Codestyle", and "Error Prone" categories. Note that you have to make sure that you configure <<<compileSourceRoots>>> and <<<includes>>>, so that PMD finds the JavaScript files. + + See {{{https://pmd.github.io/pmd-${pmdVersion}/pmd_rules_ecmascript.html}JavaScript Rule Index}} for the list + of available rules. +-----+ <project> @@ -48,9 +51,9 @@ Analyzing JavaScript Code <configuration> <language>javascript</language> <rulesets> - <ruleset>ecmascript-basic</ruleset> - <ruleset>ecmascript-braces</ruleset> - <ruleset>ecmascript-unnecessary</ruleset> + <ruleset>/category/ecmascript/bestpractices.xml</ruleset> + <ruleset>/category/ecmascript/codestyle.xml</ruleset> + <ruleset>/category/ecmascript/errorprone.xml</ruleset> </rulesets> <includes> <include>**/*.js</include> diff --git a/src/site/apt/examples/jspReport.apt.vm b/src/site/apt/examples/jspReport.apt.vm index ce3d8db..c1802c8 100644 --- a/src/site/apt/examples/jspReport.apt.vm +++ b/src/site/apt/examples/jspReport.apt.vm @@ -3,7 +3,7 @@ ------ Thomas Williamson ------ - 2015-01-19 + 2017-11-11 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one @@ -31,10 +31,14 @@ Analyzing JSP Code The PMD plugin analyzes Java by default. You can configure it to analyze Java Server Pages files instead as shown below. The example assumes that the JSP source code is stored in various subdirectories under the source directory - <<<src/main/webapp>>> and enables the built-in JSP ruleset (<basic>). + <<<src/main/webapp>>> and enables all rules from the categories "Best Practices", "Codestyle", + "Design", "Error Prone" and "Security". Note that you have to make sure that you configure <<<compileSourceRoots>>> and <<<includes>>>, so that PMD finds the JSP files. + + See {{{https://pmd.github.io/pmd-${pmdVersion}/pmd_rules_jsp.html}JSP Rule Index}} for a complete list + of available rules. +-----+ <project> @@ -48,7 +52,11 @@ Analyzing JSP Code <configuration> <language>jsp</language> <rulesets> - <ruleset>jsp-basic</ruleset> + <ruleset>/category/jsp/bestpractices.xml</ruleset> + <ruleset>/category/jsp/codestyle.xml</ruleset> + <ruleset>/category/jsp/design.xml</ruleset> + <ruleset>/category/jsp/errorprone.xml</ruleset> + <ruleset>/category/jsp/security.xml</ruleset> </rulesets> <includes> <include>**/*.jsp</include> diff --git a/src/site/apt/examples/multi-module-config.apt.vm b/src/site/apt/examples/multi-module-config.apt.vm index 1b0f2c6..4856e16 100644 --- a/src/site/apt/examples/multi-module-config.apt.vm +++ b/src/site/apt/examples/multi-module-config.apt.vm @@ -2,7 +2,7 @@ Multimodule Configuration ------ ------ - 2016-09-25 + 2017-11-11 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one @@ -87,7 +87,7 @@ whizbang </project> +-----+ - A sample <<<pmd-ruleset.xml>>> could look lke this: + A sample <<<pmd-ruleset.xml>>> could look like this: +-----+ <?xml version="1.0"?> @@ -100,14 +100,30 @@ whizbang This ruleset defines the PMD rules for project "whizbang". </description> - <rule ref="rulesets/java/basic.xml"/> - <rule ref="rulesets/java/imports.xml"/> - <rule ref="rulesets/java/unnecessary.xml"/> + <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" /> + <rule ref="category/java/bestpractices.xml/CheckResultSet" /> + <rule ref="category/java/bestpractices.xml/UnusedImports" /> + <rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /> + <rule ref="category/java/bestpractices.xml/UnusedLocalVariable" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateField" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" /> + + <rule ref="category/java/codestyle.xml/DontImportJavaLang" /> + <rule ref="category/java/codestyle.xml/DuplicateImports" /> + + <rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" /> + <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" /> + <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" /> + <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" /> + <rule ref="category/java/errorprone.xml/BrokenNullCheck" /> + + <!-- many more rules are available at https://pmd.github.io/pmd-${pmdVersion}/pmd_rules_java.html --> </ruleset> +-----+ - The ruleset references the default rulesets. For more information about rulesets, see - {{{http://pmd.github.io/pmd-5.5.1/customizing/howtomakearuleset.html}How to make a new ruleset}}. + The ruleset references some built-in rules. For more information about rulesets, see + {{{https://pmd.github.io/pmd-${pmdVersion}/pmd_userdocs_understanding_rulesets.html}Understanding Rulesets}} + and {{{./usingRuleSets.html}Using Rule Sets}}. * Configure the other projects to use it diff --git a/src/site/apt/examples/upgrading-PMD-at-runtime.apt.vm b/src/site/apt/examples/upgrading-PMD-at-runtime.apt.vm index d993467..860599f 100644 --- a/src/site/apt/examples/upgrading-PMD-at-runtime.apt.vm +++ b/src/site/apt/examples/upgrading-PMD-at-runtime.apt.vm @@ -29,7 +29,7 @@ Upgrading PMD at Runtime The Maven PMD plugin comes with a default PMD version: for <<<maven-pmd-plugin ${project.version}>>>, - PMD ${pmdVersion} is used by default. + <<PMD ${pmdVersion}>> is used by default. Given that the {{{https://pmd.github.io}newer PMD version}} is compatible, you can override the PMD version, that the Maven plugin will use and benefit diff --git a/src/site/apt/examples/usingRuleSets.apt.vm b/src/site/apt/examples/usingRuleSets.apt.vm index 3ba69ee..e38d3e5 100644 --- a/src/site/apt/examples/usingRuleSets.apt.vm +++ b/src/site/apt/examples/usingRuleSets.apt.vm @@ -3,7 +3,7 @@ ------ Maria Odea Ching ------ - 2014-03-10 + 2017-11-11 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one @@ -28,21 +28,34 @@ Using Rule Sets - The PMD plugin uses five default rule sets: <basic.xml>, <empty.xml>, <imports.xml>, <unnecessary.xml> - and <unusedcode.xml>. These rule sets are bundled in the PMD code analysis tool - (see the {{{https://pmd.github.io/pmd-${pmdVersion}/pmd-java/rules/index.html}ruleset index for java}}, - the {{{https://pmd.github.io/pmd-${pmdVersion}/pmd-javascript/rules/index.html}ruleset index for javascript}} - and {{{https://pmd.github.io/pmd-${pmdVersion}/pmd-jsp/rules/index.html}ruleset index for jsp}}). - To use other rule sets, you can configure it in the plugin as shown below. + The PMD plugin ships a default rule set, that has various rules enabled. The ruleset is available + as </rulesets/java/maven-pmd-plugin-default.xml>. See below for the rules, that are enabled with + the default rule set. + + There are many more rules available and bundled in the PMD code analysis tool: + + * {{{https://pmd.github.io/pmd-${pmdVersion}/pmd_rules_java.html}Java Rule Index}} + + * {{{https://pmd.github.io/pmd-${pmdVersion}/pmd_rules_ecmascript.html}JavaScript Rule Index}} + + * {{{https://pmd.github.io/pmd-${pmdVersion}/pmd_rules_jsp.html}JSP Rule Index}} - The rule sets may reside in the classpath, filesystem or at a URL. For rule sets that are bundled with the PMD tool, - you do not need to specificy the absolute path of the file. It will be resolved by the plugin. But if the rule set is a - custom rule set, you need to specify its absolute path. + To use other rule sets, you can configure it in the plugin as shown below. + The rule sets may reside in the classpath, filesystem or at a URL. For rule sets that are bundled + with the PMD tool, you do not need to specificy the absolute path of the file. It will be resolved by + the plugin. But if the rule set is a custom rule set, you need to specify its absolute path. + + See {{{https://pmd.github.io/pmd-${pmdVersion}/pmd_userdocs_understanding_rulesets.html}Understanding Rulesets}} + if you want to create your own custom ruleset. <<Note:>> Starting with PMD 5.0 and Maven PMD Plugin 3.0 the paths to the bundled rule sets for the Java language were changed from <<</rulesets/xyz.xml>>> to <<</rulesets/java/xyz.xml>>>. So when upgrading to Maven PMD Plugin 3.0 you may need to alter your plugin configuration. + + <<Note:>> Starting with PMD 6.0.0 and Maven PMD Plugin 3.9.0, the rules have been reorganized + into categories, e.g. <<</category/java/bestpractices.xml>>>. So when upgrading to + Maven PMD Plugin 3.9.0 you should review your plugin configuration and/or custom ruleset. +-----+ <project> @@ -70,3 +83,74 @@ Using Rule Sets ... </project> +-----+ + + +The default ruleset + + This is an excerpt of the ruleset <<</rulesets/java/maven-pmd-plugin-default.xml>>>. + It contains only rules for Java. + If you use a different language, you'll need to specify your own custom ruleset. + + The current version of the ruleset can be found in version control: + {{http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-pmd-plugin/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml}} + ++-----+ + <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" /> + <rule ref="category/java/bestpractices.xml/CheckResultSet" /> + <rule ref="category/java/bestpractices.xml/UnusedImports" /> + <rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /> + <rule ref="category/java/bestpractices.xml/UnusedLocalVariable" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateField" /> + <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" /> + + <rule ref="category/java/codestyle.xml/DontImportJavaLang" /> + <rule ref="category/java/codestyle.xml/DuplicateImports" /> + <rule ref="category/java/codestyle.xml/ExtendsObject" /> + <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" /> + <rule ref="category/java/codestyle.xml/TooManyStaticImports" /> + <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" /> + <rule ref="category/java/codestyle.xml/UnnecessaryModifier" /> + <rule ref="category/java/codestyle.xml/UnnecessaryReturn" /> + <rule ref="category/java/codestyle.xml/UselessParentheses" /> + <rule ref="category/java/codestyle.xml/UselessQualifiedThis" /> + + <rule ref="category/java/design.xml/CollapsibleIfStatements" /> + <rule ref="category/java/design.xml/SimplifiedTernary" /> + <rule ref="category/java/design.xml/UselessOverridingMethod" /> + + <rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" /> + <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" /> + <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" /> + <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" /> + <rule ref="category/java/errorprone.xml/BrokenNullCheck" /> + <rule ref="category/java/errorprone.xml/CheckSkipResult" /> + <rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" /> + <rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" /> + <rule ref="category/java/errorprone.xml/EmptyCatchBlock" /> + <rule ref="category/java/errorprone.xml/EmptyFinallyBlock" /> + <rule ref="category/java/errorprone.xml/EmptyIfStmt" /> + <rule ref="category/java/errorprone.xml/EmptyInitializer" /> + <rule ref="category/java/errorprone.xml/EmptyStatementBlock" /> + <rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop" /> + <rule ref="category/java/errorprone.xml/EmptyStaticInitializer" /> + <rule ref="category/java/errorprone.xml/EmptySwitchStatements" /> + <rule ref="category/java/errorprone.xml/EmptySynchronizedBlock" /> + <rule ref="category/java/errorprone.xml/EmptyTryBlock" /> + <rule ref="category/java/errorprone.xml/EmptyWhileStmt" /> + <rule ref="category/java/errorprone.xml/ImportFromSamePackage" /> + <rule ref="category/java/errorprone.xml/JumbledIncrementer" /> + <rule ref="category/java/errorprone.xml/MisplacedNullCheck" /> + <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" /> + <rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" /> + <rule ref="category/java/errorprone.xml/UnconditionalIfStatement" /> + <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" /> + <rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" /> + <rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" /> + + <rule ref="category/java/multithreading.xml/AvoidThreadGroup" /> + <rule ref="category/java/multithreading.xml/DontCallThreadRun" /> + <rule ref="category/java/multithreading.xml/DoubleCheckedLocking" /> + + <rule ref="category/java/performance.xml/BigIntegerInstantiation" /> + <rule ref="category/java/performance.xml/BooleanInstantiation" /> ++-----+ \ No newline at end of file diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 906c3b8..e47f2e7 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -3,7 +3,7 @@ ------ Dennis Lundberg ------ - 2014-07-28 + 2017-11-11 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one @@ -44,11 +44,11 @@ ${project.name} * {{{./cpd-mojo.html}pmd:cpd}} generates a report for PMD's Copy/Paste Detector (CPD) tool. It can also generate a cpd results file in any of these formats: xml, csv or txt. - * {{{./check-mojo.html}pmd:check}} verifies that the PMD report is empty and fails the build if it is not. This goal is executed by - default when <<<pmd:pmd>>> is executed. + * {{{./check-mojo.html}pmd:check}} verifies that the PMD report is empty and fails the build if it is not. + This goal is executed by default when <<<pmd:pmd>>> is executed. - * {{{./cpd-check-mojo.html}pmd:cpd-check}} verifies that the CPD report is empty and fails the build if it is not. This goal is - executed by default when <<<pmd:cpd>>> is executed. + * {{{./cpd-check-mojo.html}pmd:cpd-check}} verifies that the CPD report is empty and fails the build if it is not. + This goal is executed by default when <<<pmd:cpd>>> is executed. * Usage @@ -68,6 +68,14 @@ ${project.name} {{{./source-repository.html}source repository}} and will find supplementary information in the {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. +* Upgrading Notes + + <<Note:>> Starting with PMD 6.0.0 and Maven PMD Plugin 3.9.0, the rules have been reorganized + into categories, e.g. <<</category/java/bestpractices.xml>>>. So when upgrading to + Maven PMD Plugin 3.9.0 you should review your plugin configuration and/or custom ruleset. + See {{{./examples/usingRuleSets.html}Using Rule Sets}} for more information. + + * Examples To provide you with better understanding of some usages of the Maven PMD Plugin, you can take a look into the diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm index bdda0bb..6bcfe52 100644 --- a/src/site/apt/usage.apt.vm +++ b/src/site/apt/usage.apt.vm @@ -3,7 +3,7 @@ ------ Maria Odea Ching ------ - 2006-06-23 + 2017-11-11 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one @@ -81,7 +81,7 @@ Configuration You can configure the minimum code size which trips the CPD. The default of <<<100>>> tokens corresponds to approximately 5-10 lines of code. - Since PMD parses the Java source, it needs to know which Java version to use. CPD's default is <<<1.8>>>. + Since PMD parses the Java source, it needs to know which Java version to use. CPD's default is <<<1.9>>>. The following is a possible configuration: +-----+ diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java index 5f337f3..22f7280 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java +++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java @@ -70,13 +70,7 @@ public class PmdReportTest assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); // check if the rulesets, that have been applied, have been copied - generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/java-basic.xml" ); - assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); - - generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/java-imports.xml" ); - assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); - - generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/java-unusedcode.xml" ); + generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/maven-pmd-plugin-default.xml" ); assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) ); generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" ); -- To stop receiving notification emails like this one, please contact "commits@maven.apache.org" <commits@maven.apache.org>.