Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pom] InvalidDependencyTypes doesn't consider dependencies at all #4388

Closed
adangel opened this issue Feb 9, 2023 · 0 comments · Fixed by #4909
Closed

[pom] InvalidDependencyTypes doesn't consider dependencies at all #4388

adangel opened this issue Feb 9, 2023 · 0 comments · Fixed by #4909
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Milestone

Comments

@adangel
Copy link
Member

adangel commented Feb 9, 2023

Affects PMD Version: any

Rule: InvalidDependencyTypes

Description:

The XPath expression won't find any invalid dependency type in valid POM files, since the tag dependency must be wrapped inside a dependencies. That means, that //dependencyManagement/dependency doesn't match. It should be //dependencyManagement/dependencies/dependency instead.

Also note, that maven supports new types via extensions (https://maven.apache.org/pom.html#Dependencies).
Current list of out-of-the box supported types: https://maven.apache.org/ref/3.9.0/maven-core/artifact-handlers.html

Code Sample demonstrating the issue:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.sourceforge.pmd</groupId>
    <artifactId>xml-pom</artifactId>
    <version>1.0.0-SNAPSHOT</version>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-bom</artifactId>
        <version>${arquillian.version}</version>
        <type>bom</type> <!-- expected violation: bom is not a valid type -->
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

Expected outcome:

PMD should report a violation at line 13, but doesn't. This is a false-negative.

Running PMD through: CLI

@adangel adangel added the a:false-negative PMD doesn't flag a problematic piece of code label Feb 9, 2023
@jsotuyod jsotuyod added the needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale label Mar 17, 2024
@jsotuyod jsotuyod removed the needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale label Apr 2, 2024
jsotuyod added a commit to Monits/pmd that referenced this issue Apr 2, 2024
jsotuyod added a commit to Monits/pmd that referenced this issue Apr 2, 2024
@jsotuyod jsotuyod added the has:pr label Apr 2, 2024
@jsotuyod jsotuyod added this to the 7.0.1 milestone Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-negative PMD doesn't flag a problematic piece of code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants