对自托管 SonarQube 项目进行分析,获取筛选后的问题,检查 Quality Gate 并提供自动修复方案。
声纳库贝分析器 Skill.是一项面向实际任务的技能,主要用于Analisa projetos no SonarQube 自行主持, obtémissions 是一项面向实际任务的技能,主要用于Ferramentas Registradas. sonar get issues.;Obtém lista de issues de um projeto/PR.;
若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;
涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
分析自托管的 SonarQube 项目,获取 issues 并建议自动化解决方案。
sonar_get_issues获取 SonarQube 中某个项目或 PR 的 issues 列表。
参数:
projectKey(字符串,必需):项目密钥pullRequest(字符串,可选):用于指定 PR 分析的 PR 编号severities(字符串数组,可选):要过滤的严重级别(BLOCKER、CRITICAL、MAJOR、MINOR、INFO)status(字符串,可选):issues 状态(OPEN、CONFIRMED、FALSE_POSITIVE 等)limit(数字,可选):返回 issues 数量上限(默认:100)示例:
{
"projectKey": "openclaw-panel",
"pullRequest": "5",
"severities": ["CRITICAL", "MAJOR"],
"limit": 50
}
sonar_analyze_and_suggest基于 SonarQube 规则分析 issues 并提出修复建议。
参数:
projectKey(字符串,必需):项目密钥pullRequest(字符串,可选):PR 编号autoFix(布尔值,可选):是否尝试应用自动修复(默认:false)示例:
{
"projectKey": "openclaw-panel",
"pullRequest": "5",
"autoFix": false
}
sonar_quality_gate检查项目的 Quality Gate 状态。
参数:
projectKey(字符串,必需):项目密钥pullRequest(字符串,可选):PR 编号示例:
{
"projectKey": "openclaw-panel",
"pullRequest": "5"
}
该 skill 使用以下环境变量配置:
SONAR_HOST_URL=http://127.0.0.1:9000 # SonarQube 地址 SONAR_TOKEN=admin # 认证 Token
node scripts/analyze.js --project=my-project --pr=5
node scripts/report.js --project=my-project --format=markdown
node scripts/quality-gate.js --project=my-project --pr=5
{
"total": 12,
"issues": [
{
"key": "...",
"severity": "MAJOR",
"component": "apps/web/src/ui/App.tsx",
"line": 346,
"message": "Extract this nested ternary...",
"rule": "typescript:S3358",
"status": "OPEN",
"solution": "Extract nested ternary into a separate function..."
}
],
"summary": {
"BLOCKER": 0,
"CRITICAL": 0,
"MAJOR": 2,
"MINOR": 10,
"INFO": 0
}
}
{
"projectKey": "openclaw-panel",
"analysis": {
"totalIssues": 12,
"fixableAutomatically": 8,
"requiresManualFix": 4
},
"suggestions": [
{
"file": "apps/web/src/ui/App.tsx",
"line": 346,
"issue": "Nested ternary operation",
"suggestion": "Extract into independent component",
"codeExample": "...",
"autoFixable": false
}
],
"nextSteps": [
"Run lint:fix for auto-fixable issues",
"Refactor nested ternaries in App.tsx",
"Replace || with ?? operators"
]
}
| 规则 ID | 问题描述 | 自动化修复能力 |
|---|---|---|
| S6606 | 使用 || 替代 ?? |
✅ 替换为 ?? |
| S3358 | 嵌套三元表达式(Nested ternary) | ❌ 需手动重构 |
| S6749 | 冗余 Fragment | ✅ 移除 Fragment |
| S6759 | 非只读属性(Non-readonly props) | ✅ 添加 readonly 修饰符 |
| S3776 | 认知复杂度过高(Cognitive complexity) | ❌ 需提取为独立组件 |
| S6571 | 联合类型中出现 any |
✅ 移除冗余定义 |
GitHub Actions 示例用法:
- name: Analyze with SonarQube Skill
run: |
npm install -g @felipeoff/sonarqube-analyzer
sonarqube-analyzer
--project=my-project
--pr=${{ github.event.pull_request.number }}
--suggest-fixes
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134.1万人学习
共49课时 | 82.6万人学习
最新文章