最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Running PMD yields empty result - Stack Overflow

programmeradmin4浏览0评论

I want to use pmd (v7.11) to calculate the cyclic complexity of a Java file. To this end, I created file ruleset.xml with this content:

<?xml version="1.0"?>

<ruleset name="Custom Rules"
    xmlns=".0.0"
    xmlns:xsi=";
    xsi:schemaLocation=".0.0 .xsd">

    <description>
        My custom rules
    </description>

    <rule ref="category/java/design.xml/CyclomaticComplexity">
    </rule>

</ruleset>

When running

pmd check -f json -R ./ruleset.xml -d Game.java

I get two (unrelated) warnings and a (basically) empty output:

{
  "formatVersion": 0,
  "pmdVersion": "7.11.0",
  "timestamp": "2025-03-07T18:30:29.815+01:00",
  "files": [],
  "suppressedViolations": [],
  "processingErrors": [],
  "configurationErrors": []
}

I would assume that at least the filename (Game.java) should appear in the files section. What am I doing wrong?

I want to use pmd (v7.11) to calculate the cyclic complexity of a Java file. To this end, I created file ruleset.xml with this content:

<?xml version="1.0"?>

<ruleset name="Custom Rules"
    xmlns="http://pmd.sourcefe/ruleset/2.0.0"
    xmlns:xsi="http://www.w3./2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourcefe/ruleset/2.0.0 https://pmd.sourcefe.io/ruleset_2_0_0.xsd">

    <description>
        My custom rules
    </description>

    <rule ref="category/java/design.xml/CyclomaticComplexity">
    </rule>

</ruleset>

When running

pmd check -f json -R ./ruleset.xml -d Game.java

I get two (unrelated) warnings and a (basically) empty output:

{
  "formatVersion": 0,
  "pmdVersion": "7.11.0",
  "timestamp": "2025-03-07T18:30:29.815+01:00",
  "files": [],
  "suppressedViolations": [],
  "processingErrors": [],
  "configurationErrors": []
}

I would assume that at least the filename (Game.java) should appear in the files section. What am I doing wrong?

Share asked Mar 7 at 17:33 Michael WahlerMichael Wahler 3873 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You are not doing anything wrong, but your expectations are incorrect.

PMD will only include under files those with violations, not all analyzed files.

You can see explicitly the analyzed files running in verbose mode (-v), or during the progress bar update (--progress) which should be enabled by default, but for a single file, probably shows for too little time to tell…

发布评论

评论列表(0)

  1. 暂无评论