Skip to main content

sonar-fix-issue

Fix a specific SonarQube issue in code by rule key and location

跳到安装

来源信息

仓库
SonarSource/sonarqube-gh-agent-apps-plugin
最近来源活动
2026年6月3日 13:40
检测到的 SKILL.md 语言
英语
星标
1
分支
3

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
sonar-fix-issue
description
Fix a specific SonarQube issue in code by rule key and location
argument-hint
[rule-key] [file-path:line]
# SonarQube — Fix Issue Fix a code quality or security issue identified by SonarQube. ## Usage ``` sonar-fix-issue java:S1481 src/main/java/MyClass.java:42 sonar-fix-issue python:S2077 src/auth/login.py sonar-fix-issue Remove unused variable in MyClass.java ``` ## Prerequisites This skill requires the SonarQube MCP Server to be configured and the tool `mcp__sonarqube__show_rule` to be available in your session. If a tool fails due to authentication problems, ask the user to ensure they have given their consent for automatic token exchange through SonarQube Cloud > My Account > Access Tokens > Agent Apps. Otherwise surface the tool error verbatim and stop. ## Instructions ### Step 1: Identify the issue Parse the user-provided arguments for: - A rule key (e.g. `java:S1481`, `python:S2077`) - A file path and optional line number (e.g. `src/auth/login.py:34`) - Or a plain-language description if no rule key is given If neither a rule key nor a file path can be determined, ask: *"Which rule and file should I fix?"* ### Step 2: Look up the rule (if a key was given) Call `mcp__sonarqube__show_rule` with the rule key to retrieve the full rule description, rationale, and remediation guidance before touching any code. **Do not add extra parameters** (such as `projectKey`) unless the tool schema requires them — rule lookup usually needs only the rule key. If the call fails, surface the error verbatim and stop — do not fall back to built-in knowledge of the rule, since it may be stale or wrong for the user's SonarQube configuration. Auth and configuration issues are infrastructure problems, not user-fixable from chat. ### Step 3: Read the file Read the full file content. If a line number was given, focus analysis around that line but read the whole file to understand context. ### Step 4: Apply the fix - Make the **minimal change** that resolves the rule violation - Do not refactor surrounding code or fix unrelated issues - Preserve existing behaviour — the fix must not change what the code does ### Step 5: Explain the change After editing, briefly explain: - What the violation was - Why the rule flags it - What was changed and why it resolves the issue ### Step 6: Suggest next steps - *"Invoke the sonar-list-issues skill (add a project key only if you are not using the MCP integration default)."*
在 GitHub 查看