Merge branch 'pr-708'

This commit is contained in:
Juan Martín Sotuyo Dodero
2017-11-06 18:54:59 -03:00
55 changed files with 696 additions and 246 deletions

View File

@ -5,9 +5,9 @@ folder: pmd/rules
---
List of rulesets and rules contained in each ruleset.
* [Basic POM](pmd_rules_pom_basic.html): The Basic POM Ruleset contains a collection of good practices regarding Maven's POM files.
* [Errorprone](pmd_rules_pom_errorprone.html): Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
## Basic POM
* [InvalidDependencyTypes](pmd_rules_pom_basic.html#invaliddependencytypes): While Maven will not failed if you use an invalid type for a dependency in thedependency manageme...
* [ProjectVersionAsDependencyVersion](pmd_rules_pom_basic.html#projectversionasdependencyversion): Using that expression in dependency declarations seems like a shortcut, but it can go wrong.By fa...
## Errorprone
* [InvalidDependencyTypes](pmd_rules_pom_errorprone.html#invaliddependencytypes): If you use an invalid dependency type in the dependency management section, Maven doesn't fail. I...
* [ProjectVersionAsDependencyVersion](pmd_rules_pom_errorprone.html#projectversionasdependencyversion): Using that expression in dependency declarations seems like a shortcut, but it can go wrong.By fa...

View File

@ -1,11 +1,11 @@
---
title: Basic POM
summary: The Basic POM Ruleset contains a collection of good practices regarding Maven's POM files.
permalink: pmd_rules_pom_basic.html
title: Errorprone
summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
permalink: pmd_rules_pom_errorprone.html
folder: pmd/rules/pom
sidebaractiveurl: /pmd_rules_pom.html
editmepath: ../pmd-xml/src/main/resources/rulesets/pom/basic.xml
keywords: Basic POM, ProjectVersionAsDependencyVersion, InvalidDependencyTypes
editmepath: ../pmd-xml/src/main/resources/category/pom/errorprone.xml
keywords: Errorprone, InvalidDependencyTypes, ProjectVersionAsDependencyVersion
---
## InvalidDependencyTypes
@ -13,8 +13,10 @@ keywords: Basic POM, ProjectVersionAsDependencyVersion, InvalidDependencyTypes
**Priority:** Medium (3)
While Maven will not failed if you use an invalid type for a dependency in the
dependency management section, it will not also uses the dependency.
If you use an invalid dependency type in the dependency management section, Maven doesn't fail. Instead,
the entry is just ignored, which might have the effect, that the wrong version of the dependency is used.
The following types are considered valid: pom, jar, maven-plugin, ejb, war, ear, rar, par.
```
//dependencyManagement/dependency/type/text[not(contains('pom, jar, maven-plugin, ejb, war, ear, rar, par',@Image))]
@ -41,7 +43,7 @@ dependency management section, it will not also uses the dependency.
**Use this rule by referencing it:**
``` xml
<rule ref="category/pom/basic.xml/InvalidDependencyTypes" />
<rule ref="category/pom/errorprone.xml/InvalidDependencyTypes" />
```
## ProjectVersionAsDependencyVersion
@ -71,6 +73,6 @@ By far the most common problem is the use of 6.0.0-SNAPSHOT in a BOM or parent P
**Use this rule by referencing it:**
``` xml
<rule ref="category/pom/basic.xml/ProjectVersionAsDependencyVersion" />
<rule ref="category/pom/errorprone.xml/ProjectVersionAsDependencyVersion" />
```

View File

@ -5,8 +5,8 @@ folder: pmd/rules
---
List of rulesets and rules contained in each ruleset.
* [Basic XML](pmd_rules_xml_basic.html): The Basic XML Ruleset contains a collection of good practices which everyone should follow.
* [Errorprone](pmd_rules_xml_errorprone.html): Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
## Basic XML
* [MistypedCDATASection](pmd_rules_xml_basic.html#mistypedcdatasection): An XML CDATA section begins with a <!CDATA[ marker, which has only one [, and ends with a ]]> mar...
## Errorprone
* [MistypedCDATASection](pmd_rules_xml_errorprone.html#mistypedcdatasection): An XML CDATA section begins with a <!CDATA[ marker, which has only one [, and ends with a ]]> mar...

View File

@ -1,11 +1,11 @@
---
title: Basic XML
summary: The Basic XML Ruleset contains a collection of good practices which everyone should follow.
permalink: pmd_rules_xml_basic.html
title: Errorprone
summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
permalink: pmd_rules_xml_errorprone.html
folder: pmd/rules/xml
sidebaractiveurl: /pmd_rules_xml.html
editmepath: ../pmd-xml/src/main/resources/rulesets/xml/basic.xml
keywords: Basic XML, MistypedCDATASection
editmepath: ../pmd-xml/src/main/resources/category/xml/errorprone.xml
keywords: Errorprone, MistypedCDATASection
---
## MistypedCDATASection
@ -27,6 +27,6 @@ An extra [ looks like &lt;!CDATA[[]]&gt;, and an extra ] looks like &lt;!CDATA[]
**Use this rule by referencing it:**
``` xml
<rule ref="category/xml/basic.xml/MistypedCDATASection" />
<rule ref="category/xml/errorprone.xml/MistypedCDATASection" />
```

View File

@ -5,9 +5,12 @@ folder: pmd/rules
---
List of rulesets and rules contained in each ruleset.
* [XPath in XSL](pmd_rules_xsl_xpath.html): This ruleset regroups a collection of good practices regarding XPath querying and functions inside an XSL.
* [Codestyle](pmd_rules_xsl_codestyle.html): Rules which enforce a specific coding style.
* [Performance](pmd_rules_xsl_performance.html): Rules that flag suboptimal code.
## XPath in XSL
* [AvoidAxisNavigation](pmd_rules_xsl_xpath.html#avoidaxisnavigation): Avoid using the 'following' or 'preceeding' axes whenever possible, as these can cutthrough 100% ...
* [UseConcatOnce](pmd_rules_xsl_xpath.html#useconcatonce): The XPath concat() functions accepts as many arguments as required so you can have"concat($a,'b',...
## Codestyle
* [UseConcatOnce](pmd_rules_xsl_codestyle.html#useconcatonce): The XPath concat() functions accepts as many arguments as required so you can have"concat($a,'b',...
## Performance
* [AvoidAxisNavigation](pmd_rules_xsl_performance.html#avoidaxisnavigation): Avoid using the 'following' or 'preceeding' axes whenever possible, as these can cutthrough 100% ...

View File

@ -0,0 +1,34 @@
---
title: Codestyle
summary: Rules which enforce a specific coding style.
permalink: pmd_rules_xsl_codestyle.html
folder: pmd/rules/xsl
sidebaractiveurl: /pmd_rules_xsl.html
editmepath: ../pmd-xml/src/main/resources/category/xsl/codestyle.xml
keywords: Codestyle, UseConcatOnce
---
## UseConcatOnce
**Since:** PMD 5.0
**Priority:** Medium (3)
The XPath concat() functions accepts as many arguments as required so you can have
"concat($a,'b',$c)" rather than "concat($a,concat('b',$c)".
```
//node()[contains(substring-after(@select,'concat'),'concat')]
```
**Example(s):**
``` xsl
<xsl:variable name="var" select="concat("Welcome",concat("to you ",$name))"/>
<xsl:variable name="var" select="concat("Welcome","to you ",$name))">
```
**Use this rule by referencing it:**
``` xml
<rule ref="category/xsl/codestyle.xml/UseConcatOnce" />
```

View File

@ -1,11 +1,11 @@
---
title: XPath in XSL
summary: This ruleset regroups a collection of good practices regarding XPath querying and functions inside an XSL.
permalink: pmd_rules_xsl_xpath.html
title: Performance
summary: Rules that flag suboptimal code.
permalink: pmd_rules_xsl_performance.html
folder: pmd/rules/xsl
sidebaractiveurl: /pmd_rules_xsl.html
editmepath: ../pmd-xml/src/main/resources/rulesets/xsl/xpath.xml
keywords: XPath in XSL, UseConcatOnce, AvoidAxisNavigation
editmepath: ../pmd-xml/src/main/resources/category/xsl/performance.xml
keywords: Performance, AvoidAxisNavigation
---
## AvoidAxisNavigation
@ -49,31 +49,6 @@ cutting through 100% of the document.
**Use this rule by referencing it:**
``` xml
<rule ref="category/xsl/xpath.xml/AvoidAxisNavigation" />
```
## UseConcatOnce
**Since:** PMD 5.0
**Priority:** Medium (3)
The XPath concat() functions accepts as many arguments as required so you can have
"concat($a,'b',$c)" rather than "concat($a,concat('b',$c)".
```
//node()[contains(substring-after(@select,'concat'),'concat')]
```
**Example(s):**
``` xsl
<xsl:variable name="var" select="concat("Welcome",concat("to you ",$name))"/>
<xsl:variable name="var" select="concat("Welcome","to you ",$name))">
```
**Use this rule by referencing it:**
``` xml
<rule ref="category/xsl/xpath.xml/UseConcatOnce" />
<rule ref="category/xsl/performance.xml/AvoidAxisNavigation" />
```

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Best Practices"
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>
Rules which enforce generally accepted best practices.
</description>
</ruleset>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<ruleset name="Codestyle"
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>
Rules which enforce a specific coding style.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Design"
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>
Rules that help you discover design issues.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Documentation"
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>
Rules that are related to code documentation.
</description>
</ruleset>

View File

@ -0,0 +1,90 @@
<?xml version="1.0"?>
<ruleset name="Errorprone"
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>
Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
</description>
<rule name="InvalidDependencyTypes"
language="pom"
since="5.4"
message="By default, Maven only recognizes the following types: pom, jar, maven-plugin, ejb, war, ear, rar, par."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_pom_errorprone.html#invaliddependencytypes">
<description>
If you use an invalid dependency type in the dependency management section, Maven doesn't fail. Instead,
the entry is just ignored, which might have the effect, that the wrong version of the dependency is used.
The following types are considered valid: pom, jar, maven-plugin, ejb, war, ear, rar, par.
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//dependencyManagement/dependency/type/text[not(contains('pom, jar, maven-plugin, ejb, war, ear, rar, par',@Image))]
]]>
</value>
</property>
<!-- FIXME: property injection seems to be failing with XML.... -->
<!-- property name="validTypes" value="pom, jar, maven-plugin, ejb, war, ear, rar, par" description="Set of valid types."-->
<!-- Then use as message: "By default, Maven only recognizes the following types: $validTypes." -->
</properties>
<example>
<![CDATA[
<project...>
...
<dependencyManagement>
...
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${arquillian.version}</version>
<type>bom</type> <!-- not a valid type ! 'pom' is ! -->
<scope>import</scope>
</dependency>
...
</dependencyManagement>
</project>
]]>
</example>
</rule>
<rule name="ProjectVersionAsDependencyVersion"
language="pom"
since="5.4"
message="Do not use project's version to express a dependency's version."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_pom_errorprone.html#projectversionasdependencyversion">
<description>
Using that expression in dependency declarations seems like a shortcut, but it can go wrong.
By far the most common problem is the use of ${project.version} in a BOM or parent POM.
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//dependency/version/text[contains(@Image,'{project.version}')]
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
<project...>
...
<dependency>
...
<version>${project.dependency}</version>
</dependency>
</project>
]]>
</example>
</rule>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Multithreading"
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>
Rules that flag issues when dealing with multiple threads of execution.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Performance"
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>
Rules that flag suboptimal code.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Security"
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>
Rules that flag potential security flaws.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Best Practices"
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>
Rules which enforce generally accepted best practices.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Codestyle"
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>
Rules which enforce a specific coding style.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Design"
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>
Rules that help you discover design issues.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Documentation"
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>
Rules that are related to code documentation.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Errorprone"
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>
Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Multithreading"
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>
Rules that flag issues when dealing with multiple threads of execution.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Performance"
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>
Rules that flag suboptimal code.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Security"
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>
Rules that flag potential security flaws.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Best Practices"
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>
Rules which enforce generally accepted best practices.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Codestyle"
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>
Rules which enforce a specific coding style.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Design"
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>
Rules that help you discover design issues.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Documentation"
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>
Rules that are related to code documentation.
</description>
</ruleset>

View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<ruleset name="Errorprone"
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>
Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
</description>
<rule name="MistypedCDATASection"
language="xml"
since="5.0"
message="Potentialy mistyped CDATA section with extra [ at beginning or ] at the end."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_xml_errorprone.html#mistypedcdatasection">
<description>
An XML CDATA section begins with a &lt;!CDATA[ marker, which has only one [, and ends with a ]]&gt; marker, which has only two ].
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//cdata-section[starts-with(@Image,'[') or ends-with(@Image,']')]
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
An extra [ looks like &lt;!CDATA[[]]&gt;, and an extra ] looks like &lt;!CDATA[]]]&gt;.
]]>
</example>
</rule>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Multithreading"
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>
Rules that flag issues when dealing with multiple threads of execution.
</description>
</ruleset>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="Performance"
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>
Rules that flag suboptimal code.
</description>
</ruleset>

Some files were not shown because too many files have changed in this diff Show More