Skip to content

feat: 设置页加入 Java 代码校验,并修一批可用性问题 - #2

Merged
gsnowdrift merged 12 commits into
mainfrom
feat/java-lint
Nov 21, 2026
Merged

gsnowdrift merged 12 commits into
mainfrom
feat/java-lint

Conversation

@gsnowdrift

Copy link
Copy Markdown
Owner

概要

设置页新增「Java 代码校验」:Checkstyle / PMD / SpotBugs 三选,启用后自动下载规则包,跑完在设置页和工具返回里给出结果;顺带修了添加服务、构建输出、弹窗滚动的几个可用性问题。

包含的提交

提交 内容
d945199 新增 java_ops_lint 与设置页校验卡片,跑启用的检查器并解析报告
ed9509f 规则包从 GitHub Releases 下载,临时文件 + 魔数校验 + 原子替换;内置 google / sun / 阿里规约
8b02df8 把触发点写进系统提示词与工具描述:改文件跑 Checkstyle、功能完成跑 PMD、提交前跑 SpotBugs
32bd12d SQL 高风险改为面板内弹窗确认,不再依赖会话审批策略
21d7a51 PMD / SpotBugs 真正跑起来:解压规则包、修规则集路径、绕过 .bat、auxclasspath 走文件、CPD 独立子命令、按真实输出解析
aa8af7c maven 输出按 UTF-8 解码,修中文乱码
f740cda 编辑弹窗内滚动不再带动面板,弹窗不再上下跳
24abeb9 添加服务:下拉可选、自动填充端口与模块、校验类是否存在、必填校验

验证

  • node --check lib/index.js、node --check lib/client.js 通过
  • java_ops_lint {action:'run'}(工作区 D:/project/ctiop-cruise):Checkstyle 1017 条 / 6.5s、PMD 895 条 / 6.5s、SpotBugs 97 条 / 17.1s,三者 ok: true
  • java_ops_lint {action:'install'} 对 pmd / spotbugs 复用已下载包,只解压
  • 添加服务:不存在的类、空服务名、重复登记三种情况都按要求报错
  • 插件热重载后手动验证过启停、构建、SQL 确认与面板各页签

注意

  • 规则包从各项目的 GitHub Releases 下载,首次启用需要网络
  • 阿里规约是按《阿里巴巴 Java 开发手册》自写的 lib/lint/ali-checks.xml(官方 p3c 只提供 PMD 规则)
  • 触发点写在系统提示词里,是建议而非强制拦截

GaoJ added 12 commits November 18, 2026 17:04
Add a Java code check block to settings with Checkstyle, PMD and
SpotBugs. Enabling a checker downloads its package from the matching
GitHub release into plugin-data/lint, verifying the archive magic
before an atomic rename, and the version chip can check for a newer
release.

Running the checks resolves the source directories of the registered
services, executes each enabled checker and parses its text report into
findings; the summary and the last run are exposed in the panel and
through java_ops_lint action=run. Checkstyle also honours a report
threshold, and enabling SpotBugs forces the build switch on because it
needs compiled classes.
Add the Java code-check section to settings: enable a checker, pick a
rule set (Google / Sun / Alibaba guide / external XML), watch the download
and run the enabled checkers from the panel or java_ops_lint.

- bundle the Alibaba-style Checkstyle rules, since the p3c repo ships PMD
  rules only
- validate an external rule file (extension, existence, XML shape per tool)
  before saving and again before running
- share one save path between the panel action and the tool verb
- point the agent at the tools through a system-prompt section
Append the enabled checkers' findings to the edit result, so a violation
is in front of the model before it plans the next change.

- run the enabled checkers from a tools/post-execute listener on .java
- append the report as an extra text block, keeping the original result
- keep the system prompt honest: checkstyle is automatic, pmd/spotbugs are not
DSH answers approval prompts on its own when prompts are disabled, so the
old confirm path ran high-risk statements without asking anyone. Queue the
statement on the host and let the panel dialog decide instead; a timeout
blocks the statement rather than reporting a user cancel.

Also keep the stop spinner on its own service and stop the VM args
textarea from resizing the dialog while it scrolls.
Both checkers reported zero findings without ever running: the archives
were never unpacked, the PMD ruleset path did not exist, and SpotBugs
could not load its classpath on Windows. Each layer turned a failure into
an empty result, so the panel looked green.

- unpack the downloaded archive with tar and remember the top directory
- treat a tool as installed only when its bin directory exists
- reuse an already downloaded archive instead of fetching it again
- point PMD at rulesets/java/quickstart.xml
- fail the run when PMD prints an [ERROR] line, since it exits with 0
- call the PMD and SpotBugs classes directly instead of their .bat wrappers
- pass the SpotBugs aux classpath through -auxclasspathFromFile
- run the PMD CPD subcommand and merge its duplications into the report
- parse the real SpotBugs text output, including line ranges
javac writes its diagnostics in the console code page, so on a Chinese
Windows build every line arrived as mojibake.

- add the UTF-8 output flags to MAVEN_OPTS for the wrapper and PATH mvn
- pass them to the bundled Maven launcher as JVM arguments
Scrolling inside the VM args box also scrolled the panel behind it, and
the panel re-measured itself on every scroll event, so the centered
dialog visibly moved up and down.

- lock the wheel to the textarea that has focus
- keep the overlay from scrolling its own content
- skip the panel re-measure while a dialog is open
- ignore the dialog textarea when looking for the composer
Clicking a suggestion in the class name dropdown did nothing, because the
input's blur closed the list before the click landed. Picking a class also
left the port and the module empty, and nothing verified that the class
exists.

- choose a suggestion on mousedown so the list survives the blur
- fill the port, module and context path from the chosen application
- verify the class exists in the project before saving
- require a class name, a service name and a port
- refuse a class that is already registered
- let the dropdown overflow the dialog instead of being clipped
- 新增 src/client.js 与 scripts/build-client.mjs:esbuild 打包回 __ModuleLoader__ 形态,prepack 自动重建
- 引入 Radix Dialog / Tabs / Switch:弹窗有焦点陷阱和 Esc 关闭、页签用 aria-selected 驱动下划线、开关用 role="switch"
- 建立设计 token 层(间距 4-24、圆角 4-999、控件统一 28px 高、细边框 + 极轻阴影),四个页签统一到同一套观感
- 服务空态改为居中的引导块;服务列表改卡片式选中;六个操作按钮改为淡底 + 同色描边 + 同色文字
- 停止中把「停止」就地换成「强制停止」,跳过 30 秒优雅等待
- SQL 与接口记录表固定列宽,SQL 单元格可点开「执行详情」弹窗看完整语句
- 日志工具栏新增「跟踪最新」开关:关掉后新日志不打扰当前滚动位置
- 修掉非激活 tabpanel 被类选择器盖掉 display:none、四个面板各占四分之一高度的排版问题
- 修掉英文表头 Time 与耗时列重名
- 检查一轮要 30 秒左右,同步请求会撞上浏览器 fetch 超时,面板点了没反应
- 运行改到后台:面板传 wait:false 立即返回,靠 1.5 秒轮询看结果;工具调用仍等结论
- viewState 暴露 lintRunning 与 lintError,面板据此显示「检查中…」和失败原因
- 构建参数去掉 -q:静默模式成功时一行都不打印,面板整个构建过程都是空日志
- 失败与成功的输出都进日志,配合已有的增量读取就能实时看到进度
- stopPipeline 增加 options.force:跳过 Ctrl+C 与 30 秒等待,直接终止 JVM
- killPid 收到 force 时不再先试软 taskkill,接管遗留进程的路径同样生效
- java_ops_service_stop 新增 force 参数,工具描述同步说明
- 面板在「停止中」把停止按钮就地换成「强制停止」,避免只能干等
@gsnowdrift
gsnowdrift merged commit 085daa4 into main Nov 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant