Loading...
Loading...
Validate Godot GDScript files using gdlint, gdformat, gdradon, and LSP diagnostics. Use when users want to: (1) Check code quality after making changes, (2) Validate before committing, (3) Run code metrics analysis, (4) Run export validation, (5) Get real-time LSP diagnostics. Uses command-line tools directly and MCP tools for LSP integration.
npx skill4agent add chen19007/my_skills godot-verifyaddonsaddons| 检查 | 命令/工具 | 说明 |
|---|---|---|
| Lint | | Lint GDScript 代码 |
| Format | | 格式化/检查格式 |
| Metrics | | 代码指标分析 |
| Export | | 导出验证 |
| LSP Diagnostics | | 实时语法检查(通过 MCP) |
gdradon cc <path>F <line>:<col> <function_name> - <grade> (<cc>)| 字段 | 说明 |
|---|---|
| F | 函数 (Function) |
| 行号和列号 |
| 函数名 |
| 复杂度等级: A(简单), B(中等), C(复杂), D(非常复杂), F(极复杂) |
| 圈复杂度数值 |
.\character_body_2d.gd
F 13:0 _physics_process - C (15)# Lint 检查
gdlint "D:/project/scripts/Player.gd"
# Format 检查
gdformat --check "D:/project/scripts/Player.gd"
# 代码指标
gdradon cc D:/project/scripts/
# LSP 诊断(DiagnosticsServer 为开机自启动服务)
# 调用 MCP 工具获取诊断(只需 uri 参数)
godot-lsp__diagnostics(uri="file:///D:/project/game/player.gd")
# LSP 诊断(修改代码后使用 refresh=true)
godot-lsp__diagnostics(uri="file:///D:/project/game/player.gd", refresh=true)
# 完整检查
gdlint D:/project/scripts/ && gdformat D:/project/scripts/ && gdradon cc D:/project/scripts/
# 导出验证
godot --headless --path "D:/project" --export-pack "Web" "D:/export.pck"godot-lsp__diagnosticsurifile://file:///D:/project/game/player.gdrefresh{
"uri": "file:///D:/project/game/player.gd",
"diagnostics": [
{
"range": { "start": { "line": 4, "character": 0 }, "end": { "line": 4, "character": 56 } },
"severity": 2,
"code": 9,
"source": "gdscript",
"message": "(SHADOWED_GLOBAL_IDENTIFIER): The constant \"AttackType\" has the same name as a global class..."
}
],
"cached": false // true 表示从缓存返回,false 表示新打开文件
}textrefresh=true| 级别 | 值 | 说明 |
|---|---|---|
| Error | 1 | 错误,必须修复 |
| Warning | 2 | 警告,建议修复 |
| Information | 3 | 信息 |
| Hint | 4 | 提示 |
| 代码 | 消息 | 说明 |
|---|---|---|
| 1 | | 语法错误 |
| 9 | | 常量名与全局类冲突 |
| 12 | | 静态变量类型不匹配 |
| 21 | | 返回值未使用 |
| 30 | | 不安全的函数调用 |
| 40 | | 访问未赋值的变量 |
# 获取诊断
curl "http://127.0.0.1:3457/diagnostics?path=D:/project/game/player.gd"
# 刷新诊断
curl -X POST "http://127.0.0.1:3457/refresh" -d "{\"path\":\"D:/project/game/player.gd\"}"
# 查看状态
curl "http://127.0.0.1:3457/stats"| 特性 | LSP Diagnostics | gdlint |
|---|---|---|
| 实时性 | 实时(缓存) | 需要运行 |
| 错误类型 | 语法 + 语义 | Lint 规则 |
| 与编辑器一致 | 完全一致 | 可能不同 |
| 速度 | 快(有缓存) | 慢(需解析) |
| 需要 Godot | 是 | 否 |
| Rule | Severity | Description |
|---|---|---|
| Error | Variable declared but never used |
| Error | Variable shadows member variable |
| Error | Function name violates naming convention |
| Error | Constant name violates naming convention |
| Warning | Lines have trailing whitespace |
| Warning | Function missing documentation |
| Warning | Line exceeds 120 characters |
| Error | Solution |
|---|---|
| Navigate to project root or provide absolute path |
| Install: |
| Install: |
| Add godot to PATH |
| Convert relative to absolute paths |
gdlint "D:/project/scripts/Player.gd"gdlint D:/project/scripts/ && gdformat D:/project/scripts/gdradon cc D:/project/scripts/.\character_body_2d.gd
F 13:0 _physics_process - C (15)godot --headless --path "D:/project" --export-pack "Web" "D:/export.pck"pip install gdtoolkitpip install gdradongodotfilegdformat --checkgdradon cc