5.16.0 silently drops custom PMD rulesets that point at a sibling file by relative path
还没有人认领这个 Issue。
评估
调研方向
从 Core PR #503 中描述的 PMD 流程设置开始,并使用 scanner/full.xml、scanner/subset.xml 和 code-analyzer.yml 重现。使用 5.16.0 针对示例配置运行 sf code-analyzer rules --rule-selector pmd:MyRule。当相对规则引用能够从仓库配置中加载,并且 MyRule 在没有 ruleset-resolution error 的情况下列出时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
What you see
After upgrading to @salesforce/plugin-code-analyzer 5.16.0, a scan that used to run our custom PMD rules stops running them, and nothing fails. The exit code is still 0. The only sign is one Critical violation attached to no file, with a summary like Found 1 violation(s) across 0 file(s). A CI gate that does not use --severity-threshold reads green while zero Apex rules ran.
sf code-analyzer config and sf code-analyzer rules show the cause: Cannot resolve rule/ruleset reference 'scanner/<full-ruleset>.xml/<RuleName>'.
Why it happens
Our repo has two custom rulesets: a full one that defines the rules, and a smaller one that reuses some of them with <rule ref="scanner/full-ruleset.xml/RuleName"/>, a path relative to the repo root. Up to 5.15.x, PMD resolved that path against the repo being scanned, because the PMD process was started from there.
Core PR #503 (the CWE-427 hardening) now starts the PMD process from the engine's own install folder (cwd: __dirname). The PR calls this behaviour-preserving because every argument handed to java is an absolute path. That is true for the paths the engine passes, but not for paths written inside a custom ruleset: PMD still resolves those from the process's working directory, which is now the wrong folder. The whole ruleset then fails to load, and the PMD engine drops out of the run.
The 5.16.0 release notes do not mention it.
How to reproduce
scanner/full.xmldefinesMyRule.scanner/subset.xmlcontains<rule ref="scanner/full.xml/MyRule"/>.code-analyzer.ymlin the repo root lists both files underengines.pmd.custom_rulesets.- Run
sf code-analyzer rules --rule-selector pmd:MyRule. On 5.15.x the rule is listed. On 5.16.0 the ruleset fails to load with the error above.
Seen with plugin 5.16.0 (code-analyzer-core 0.53.0, pmd-engine 0.46.0, PMD 7.26.0) on macOS. The same configuration loaded cleanly on 5.14.0 and on the release before 5.16.0.
What would fix it
Any one of these:
- Resolve paths inside custom rulesets against the config file's folder or the workspace root. One way: keep the working directory pinned, but add the workspace root to PMD's classpath, so
scanner/...resolves as a classpath resource. - Or state in the
custom_rulesetsdocs and the 5.16.0 release notes that a custom ruleset must be self-contained (no relative<rule ref>to another file).
Workaround
Generate the smaller ruleset as a self-contained copy of the rules it needs, instead of pointing at the full one. That is what we now do.
- 主要语言
- Java
- 星标
- 4
- 派生
- 8
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
[BUG] Re-subscribing the Mono returned by listTools/listResources/listResourceTemplates/listPrompts/listRoots duplicates the results可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
modelcontextprotocol/java-sdk#1174 · 1 个 reaction ·
维护者通常 2 天内回复
-
module: core
难度 2/5 1-3 小时 新手友好度 77/100
bigbluebutton/bigbluebutton#26028 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
MetricsHub/metricshub-community#1390 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
apache/rocketmq-dashboard#6331 ·
维护者通常 5 天内回复
-
status: team-only type: dependency-upgrade
难度 2/5 1-3 小时 新手友好度 68/100
spring-projects/spring-boot#52143 · 1 条评论 ·
维护者通常 1 天内回复