A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.pmd-code.org/latest/pmd_rules_pom_errorprone.html below:

Error Prone | PMD Source Code Analyzer

Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.

Table of Contents InvalidDependencyTypes

Since: PMD 5.4

Priority: Medium (3)

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.

This rule is defined by the following XPath expression:

//dependencyManagement/dependencies/dependency/type/text[not(@Text = $validTypes)]

Example(s):

<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>

This rule has the following properties:

Name Default Value Description validTypes pom , jar , maven-plugin , ejb , war , ear , rar , par Set of valid types.

Use this rule with the default properties by just referencing it:

<rule ref="category/pom/errorprone.xml/InvalidDependencyTypes" />

Use this rule and customize it:

<rule ref="category/pom/errorprone.xml/InvalidDependencyTypes">
    <properties>
        <property name="validTypes" value="pom,jar,maven-plugin,ejb,war,ear,rar,par" />
    </properties>
</rule>
ProjectVersionAsDependencyVersion

Since: PMD 5.4

Priority: Medium (3)

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.

This rule is defined by the following XPath expression:

//dependencies/dependency
    [contains(version/text/@Text,'{project.version}')]
    [
        (/document/project/parent/groupId and groupId/text/@Text != /document/project/parent/groupId/text/@Text)
        or
        (/document/project/groupId and groupId/text/@Text != /document/project/groupId/text/@Text)
    ]/version

Example(s):

<project...>
  ...
  <dependency>
    ...
    <version>${project.version}</version>
  </dependency>
</project>

Use this rule by referencing it:

<rule ref="category/pom/errorprone.xml/ProjectVersionAsDependencyVersion" />

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4