[BUG] Bundled PMD 7.25.0 cannot load custom rulesets referencing PMD 7.26.0 rules — one unresolvable ref disables the whole ruleset
Chưa có ai nhận issue này.
- #480 của @nikhil-mittal-165 — đã đóng, không merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- java, typescript
- Lĩnh vực
- devtools, testing-qa
Hướng nghiên cứu
Bắt đầu với @salesforce/code-analyzer-pmd-engine 0.43.0 và các jar PMD trong dist/java-lib/, sau đó lần theo đường dẫn tải dependency đi kèm và bộ quy tắc tùy chỉnh. Tái hiện bằng my-rules.xml, code-analyzer.yml được cung cấp và lệnh sf code-analyzer. Được xem là hoàn tất khi bản phát hành PMD được hỗ trợ là bản hiện tại và một quy tắc không thể phân giải báo cáo phiên bản đi kèm mà không âm thầm che khuất hành vi được yêu cầu còn lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
A custom PMD ruleset that references a standard rule added in PMD 7.26.0 (for example category/apex/errorprone.xml/InvocableClassNoArgConstructor, added 2026-06-29) cannot be loaded by Code Analyzer, because the plugin's bundled PMD engine is still 7.25.0 — and one unresolvable rule reference fails the load of the entire ruleset, so every other rule in the file silently stops running too.
There is currently no way for a user to fix this on their side: the PMD jars ship inside @salesforce/code-analyzer-pmd-engine (dist/java-lib/pmd-apex-7.25.0.jar in engine 0.43.0, the latest) and there is no supported way to point the pmd engine at newer jars.
Steps To Reproduce
(Prerequisites: Salesforce CLI and Java, the standard Code Analyzer requirements. Steps verified end-to-end in an empty directory.)
sf plugins install code-analyzer(installscode-analyzer 5.14.0, the current latest, which resolves@salesforce/[email protected]).- In an empty directory, create
src/Sample.cls:
public class Sample {
public static void log() {
System.debug('hello');
}
}
- Create
my-rules.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Repro"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>One rule from PMD 7.26.0 plus one custom XPath rule.</description>
<rule ref="category/apex/errorprone.xml/InvocableClassNoArgConstructor"/>
<rule name="MyOtherRule" language="apex" message="demo"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<description>demo</description>
<priority>3</priority>
<properties>
<property name="xpath"><value>//MethodCallExpression[lower-case(@FullMethodName) = 'system.debug']</value></property>
</properties>
</rule>
</ruleset>
- Create
code-analyzer.yml:
engines:
pmd:
custom_rulesets:
- my-rules.xml
sf code-analyzer run --workspace src --rule-selector pmd --config-file code-analyzer.yml
Expected Behavior
Either the reference resolves (bundled PMD current with the PMD release line), or at minimum the loadable rules still run and the failure clearly names the unresolvable rule and the bundled PMD version.
Actual Behavior
The pmd engine fails entirely; zero rules from the ruleset execute:
Error: Code Analyzer:
Failed to get rules from engine with name 'pmd' due to the following error:
PMD errored when attempting to load a custom ruleset "my-rules.xml".
Make sure the resource is a valid ruleset file on disk or on the Java classpath.
PMD Exception:
| Cannot load ruleset my-rules.xml: PMD threw an unexpected exception:
| Error at my-rules.xml:7:4
| <rule ref="category/apex/errorprone.xml/InvocableClassNoArgConstructor"/>
| ^^^^^ Unable to find referenced rule InvocableClassNoArgConstructor;
| perhaps the rule name is misspelled?
The run then reports 1 Critical severity violation(s) found across 0 files, which downstream tooling can misread as a code finding.
Control (shows the rest of the ruleset is valid): delete the single <rule ref="category/..."/> line from my-rules.xml and re-run step 5 — the scan now succeeds and pmd:MyOtherRule correctly flags Sample.cls:3. One unresolvable reference is the only difference between "everything runs" and "nothing runs".
Requests
- Bump the bundled PMD in
@salesforce/code-analyzer-pmd-engineto the current PMD release line (7.26.0 shipped 2026-06-29; the all-or-nothing ruleset load is PMD's own semantics, so currency of the bundle is what decides whether a ruleset referencing new standard rules is usable at all). - Improve the diagnostic: when a custom ruleset fails to load over an unresolvable rule reference, state the bundled PMD version in the message (for example "bundled PMD is 7.25.0;
InvocableClassNoArgConstructorrequires 7.26.0+") so users don't debug a "misspelled rule name" that is actually a version gap. (Companion request for the underlying message on the PMD side: pmd/pmd#6865.) - (Nice to have) A documented way to supply or override the PMD version the engine uses.
Workaround
Remove standard-category rule references from custom rulesets (inline the XPath equivalents or run the standalone PMD CLI >= 7.26.0 separately).
Environment
code-analyzerplugin 5.14.0 (latest),@salesforce/code-analyzer-pmd-engine0.43.0 (latest)- Bundled jars:
pmd-apex-7.25.0.jar,pmd-core-7.25.0.jar(indist/java-lib/) - Standalone PMD for comparison: 7.26.0 (2026-06-29)
- macOS 15 / Node 22
- Ngôn ngữ chính
- TypeScript
- Star
- 241
- Fork
- 52
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của forcedotcom/code-analyzer
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
forcedotcom/code-analyzer#2094 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
forcedotcom/code-analyzer#2093 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
forcedotcom/code-analyzer#2091 ·
-
[BUG][code-analyzer] sfge: calling toString() on an enum aborts the entry point (UnimplementedMethodException)Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
forcedotcom/code-analyzer#2090 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
forcedotcom/code-analyzer#2104 ·
Tất cả issue của forcedotcom/code-analyzer
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
maniator/verticopolis#1303 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
components-web-app/docs#297 ·
-
listFeatures/getFeatureExamples never return Kotlin examples for Android or server Kotlin SDKsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
appwrite/mcp-for-docs#23 · 1 bình luận ·
-
`@vanilla-extract/turbopack-plugin`: "getImageSize is not a function" with Next.js 16.4.x when a `.css.ts` file imports an imageCó thể đã có người làm @aevarOrigo đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vanilla-extract-css/vanilla-extract#1799 · 1 bình luận ·
-
native
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
prime-radiant-inc/evener#4839 ·
Maintainer thường phản hồi trong vòng 1 ngày