- CodeGuard → Code Purifier / 净码特工(displayName、命令、配置标题) - 新增 ai.maxTokens 配置项,所有 Provider 及 fixer 传入 maxTokens - AI 引擎增强:repairJsonEscapes + JSON 解析 fallback + 详细错误信息 - 设置面板规则管理改为文件级(list/delete .yaml),addRule 改为 AI 从 Markdown 生成 YAML - yaml-parser 简化:移除 config.yaml 的 enable/disable 过滤逻辑 - 审查报告面板:errorBanner 优先显示具体错误、lint 诊断显示 suggestion、移除 translatedDiagnostics 独立渲染 - merger 中 translatedDiagnostics 覆盖原始 lint 诊断 message/suggestion - HTML linter 配置项、测试用例重写、typescript-eslint 移入 dependencies
47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
import java.io.*;
|
|
import java.nio.file.*;
|
|
import net.sourceforge.pmd.*;
|
|
import net.sourceforge.pmd.renderers.*;
|
|
|
|
public class PmdRunner {
|
|
public static void main(String[] args) throws Exception {
|
|
if (args.length < 2) {
|
|
System.err.println("Usage: PmdRunner <filePath|- for stdin> <rulesetPath>");
|
|
System.exit(1);
|
|
return;
|
|
}
|
|
|
|
String filePath = args[0];
|
|
String rulesetPath = args[1];
|
|
|
|
Path tempFile = null;
|
|
if ("-".equals(filePath)) {
|
|
String code = new String(System.in.readAllBytes());
|
|
tempFile = Files.createTempFile("pmd-stdin-", ".java");
|
|
Files.writeString(tempFile, code);
|
|
filePath = tempFile.toString();
|
|
}
|
|
|
|
try {
|
|
PMDConfiguration config = new PMDConfiguration();
|
|
config.addRuleSet(rulesetPath);
|
|
|
|
Writer writer = new StringWriter();
|
|
JsonRenderer renderer = new JsonRenderer();
|
|
renderer.setWriter(writer);
|
|
|
|
try (PmdAnalysis pmd = PmdAnalysis.create(config)) {
|
|
pmd.files().addFile(Path.of(filePath));
|
|
pmd.addRenderer(renderer);
|
|
pmd.performAnalysis();
|
|
}
|
|
|
|
System.out.print(writer.toString());
|
|
} finally {
|
|
if (tempFile != null) {
|
|
Files.deleteIfExists(tempFile);
|
|
}
|
|
}
|
|
}
|
|
}
|