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?
1 Answer
Reset to default 1You 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…