-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Have you tried to resolve this issue yourself first?
- I confirm I have gone through the above steps and still have an issue to report.
Bug Description
Starting from today, our CI engine reports erorrs on PMD validations for every single Pull Request.
I noticed that the new version of engine was released yesterday and feel like it may be related.
Release notes say that the plugin got updated to newest PMD version. Quick check at PMD release notes of 7.18 shows that there was an adjustment around the ExcessiveClassLength rule and that's exactly what does the log output inform about.
However, the message is just a warning and I think that the plugin treats it like error, which may be a wrong behavior?
Output / Logs
› Error: Code Analyzer [8:31:39.145]:
› Failed to get rules from engine with name 'pmd' due to the following
› error:
› PMD errored when attempting to load a custom ruleset
› "/__w/project/project/config/code-scanner/pmd.xml". Make sure the resource
› is a valid ruleset file on disk or on the Java classpath.
›
› PMD Exception:
› | Cannot load ruleset
› /__w/project/project/config/code-scanner/pmd.xml: PMD threw an unexpected
› exception:n | Warning at
› /__w/project/project/config/code-scanner/pmd.xml:105:5n | 103| n | 104|
› <!-- DESIGN -->n | 105| <rule
› ref="category/apex/design.xml/ExcessiveClassLength"n | ^^^^^
› Discontinue using Rule name category/apex/design.xml/ExcessiveClassLength
› as it is scheduled for removal from PMD. PMD 8.0.0 will remove support for
› this Rule.n | n | 106| message="Avoid really long classes
› (over 250 lines of code)">n | 107| <properties>
›
› If you wish to ignore this error and disable this engine, then update
› your Code Analyzer configuration with:
› engines:
› pmd:
› disable_engine: true
Violation file paths relative to '/__w/project/project/'.
=== 1. UninstantiableEngineError
severity: 1 (Critical)
engine: pmd
message: The engine with name 'pmd' could not be instantiated. Error: PMD errored when attempting to load a custom ruleset "/__w/project/project/config/code-scanner/pmd.xml". Make sure the resource is a valid ruleset file on disk or on the Java classpath.
PMD Exception:
| Cannot load ruleset /__w/project/project/config/code-scanner/pmd.xml: PMD threw an unexpected exception:n | Warning at /__w/project/project/config/code-scanner/pmd.xml:105:5n | 103| n | 104| <!-- DESIGN -->n | 105| <rule ref="category/apex/design.xml/ExcessiveClassLength"n | ^^^^^ Discontinue using Rule name category/apex/design.xml/ExcessiveClassLength as it is scheduled for removal from PMD. PMD 8.0.0 will remove support for this Rule.n | n | 106| message="Avoid really long classes (over 250 lines of code)">n | 107| <properties>
at /github/home/.local/share/sf/node_modules/@salesforce/plugin-code-analyzer/node_modules/@salesforce/code-analyzer-pmd-engine/dist/pmd-wrapper.js:36:23
at /github/home/.local/share/sf/node_modules/@salesforce/plugin-code-analyzer/node_modules/@salesforce/code-analyzer-engine-api/dist/utils/java-utils.js:33:53
at Array.map (<anonymous>)
at Socket.<anonymous> (/github/home/.local/share/sf/node_modules/@salesforce/plugin-code-analyzer/node_modules/@salesforce/code-analyzer-engine-api/dist/utils/java-utils.js:33:41)
at Socket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)
location: undefined "Undefined Code Location"
=== Summary
Found 1 violation(s) across 0 file(s):
1 Critical severity violation(s) found.
Results written to:
sfca_results.html
sfca_results.jsonSteps To Reproduce
- Get the newest version of PMD
- Configure PMD with the ExcessiveClassLength rule
- Run the scanner against any code
Expected Behavior
Assuming that the Code fulfills reqs from the pmd.xml file, the scan should result with success.
Operating System
Github Actions + Docker image of salesforce/cli:latest-full
Salesforce CLI Version
the one available at Docker image of salesforce/cli:latest-full
Code Analyzer Plugin (code-analyzer) Version
Last available from 'sf plugins install @salesforce/sfdx-scanner'
Node Version
No response
Java Version
No response
Python Version
No response
Additional Context (Screenshots, Files, etc)
No response
Workaround
No response
Urgency
Moderate