Skip to main content

Fixing code quality findings on a pull request

Keep quality issues out of your default branch by applying autofixes, delegating remediation work to Copilot, or dismissing irrelevant findings.

谁可以使用此功能?

具有写入访问权限的用户

GitHub Team 或 GitHub Enterprise Cloud

提示

If you're new to Code Quality, see Preventing code quality issues from reaching your default branch for a guided walkthrough of how Code Quality works on pull requests.

How Code Quality works on pull requests

When you open a pull request, Code Quality runs two types of analysis and posts findings as comments on the pull request.

  1. github-code-quality[bot] findings: Code Quality uses CodeQL to perform a rule-based scan of your changes. These findings are posted as comments by github-code-quality[bot] and include a suggested autofix. Findings are labeled by severity (Error, Warning, Note), and administrators can set quality gates to block merges based on the severity of these findings.

  2. Copilot findings: If your organization has Copilot licenses and AI features are enabled for your enterprise, Code Quality uses Copilot 代码评审 to identify quality issues that rules-based analysis may not detect. These findings are posted as comments by Copilot, and include a suggested autofix. See 关于GitHub Copilot 代码评审.

Resolving a finding

  1. On GitHub, navigate to your open pull request.
  2. On the Files Changed tab, scroll to a comment left by github-code-quality[bot] or Copilot.
  3. Carefully review the comment and the suggested autofix for logic, security, and style.
  4. If you agree with the suggestion and you want to apply the fix, click Commit suggestion, or Add suggestion to batch.
  5. Alternatively, if the finding isn't relevant or actionable, you can dismiss the finding. For example, you might dismiss a finding that is in legacy code no longer maintained, is a known exception to your team's coding standards, or is a false positive that doesn't pose a real quality risk.
    • For comments left by github-code-quality[bot], click Dismiss finding.
    • For comments left by Copilot, click Resolve.

Delegating remediation work to Copilot

或者,如果你有 Copilot 许可证,则可以将修正工作委托给 Copilot云代理。 对提到 @Copilot 的拉取请求进行评论,并请求 Copilot 修复检测到的问题。

显示调用 Copilot 云智能体的 PR 注释的屏幕截图。

Copilot 使用眼睛表情符号 (👀) 响应你的批注,启动新的代理会话,并打开具有必要修复的拉取请求。

可以跟踪 Copilot云代理'工作:

你需要一个Copilot许可证来调用Copilot云代理。
注册 Copilot

Next steps