メモ
GitHub Code Quality は現在 パブリック プレビュー にあり、変更される可能性があります。 パブリック プレビュー の間、Code Quality は課金されませんが、Code Quality スキャンでは GitHub Actions 分が消費されます。
Introduction
This tutorial shows you how to work with GitHub Code Quality on pull requests to identify code quality issues that your changes may otherwise inadvertently introduce, and how to address and resolve code quality findings with Copilotの自動修正 and Copilot コーディング エージェント.
Benefits of catching issues early
Catching code quality issues early keeps your team's codebase in shape. GitHub Code Quality checks your code for:
- Reliability: For example, logic errors, unsafe error handling, or race conditions that could cause your app to crash or behave unpredictably. By addressing this type of issue early, you make your software more robust and dependable for users.
- Maintainability: For example, duplicated code, overly complex logic, unused variables, or violations of coding best practices. Fixing these issues makes your code cleaner and easier to read, so future changes are faster and less risky.
1. Understand how GitHub Code Quality works on pull requests
When you open a pull request, GitHub Code Quality uses CodeQL to automatically scan your changes for quality issues like those described above.
The results of the CodeQL scan are reported as comments on your pull request, left by the github-code-quality[bot]. Each comment corresponds to a specific code quality problem that was detected in your changes, and comes with a suggested autofix.
Comments are labeled by severity (Error, Warning, Note), so you can see which findings are the most critical to address.
2. Prioritize fixes based on severity
Scan through the comments and identify the findings that have the highest severity level ("Error") first.
If there are no "Error" findings, look for findings of the next severity level ("Warning"), and so on.
High severity findings indicate more serious code quality issues that are more likely to introduce reliability or maintainability problems in your codebase. By resolving high severity findings, you're doing the most impactful work to maintain the quality of your team's code.
メモ
A repository administrator may have set a code quality gate that blocks merging on your pull request, if the pull request contains Code Quality findings of a particular severity level or above. See Resolving a block on your pull request.
3. Leverage Copilotの自動修正 or Copilot コーディング エージェント to fix findings
Copilotの自動修正
pull request に関するコメントには、pull request に直接コミットできる 推奨自動修正 が含まれています。 ロジック、セキュリティ、スタイルに関して推奨される自動修正を慎重に確認し、[ 提案のコミット] をクリックします。
これらの提案を適用するためにCopilot ライセンスは必要ありません。
Copilot コーディング エージェント
または、Copilot ライセンスをお持ちの場合は、修復作業を Copilot コーディング エージェント に委任できます。
@Copilotに言及している pull request にコメントし、Copilot が検出された問題を解決することを要求します。

Copilot は、コメントに目の絵文字 (👀) で応答し、新しいエージェント セッションを開始し、必要な修正を含む pull request を開きます。
Copilot コーディング エージェントの作業を追跡できます。
- pull request では、作業の進行状況に応じて概要が更新されます。
-
[エージェント ページ](https://github.com/copilot/agents?ref_product=copilot&ref_type=engagement&ref_style=text)またはセッション ログの使用については、[AUTOTITLE](/copilot/how-tos/use-copilot-agents/coding-agent/track-copilot-sessions) を参照してください。
Copilot コーディング エージェント を呼び出すには、Copilot ライセンスが必要です。
Copilot にサインアップする
4. Dismiss irrelevant findings
コードベースのコンテキストで関連性がない場合、またはアクション可能でない場合は、結果を無視できます。 結果を無視する一般的な理由は次のとおりです。
- この結果は、管理されなくなったレガシ コードにあります。
- これは、チームのコーディング標準に対する既知の例外です。
- これは、実際の品質リスクをもたらさない偽陽性です。
無関係なアラートを無視すると、品質チェックが意味のある問題に焦点を当て続けます。
5. Push changes and wait for the scan
After fixing or dismissing findings, push your changes to the branch associated with your pull request. GitHub Code Quality will automatically re-scan your changes and update the comments on your pull request accordingly.
6. Check your repository's code quality ratings
Anyone with write access can view the overall code quality ratings for a repository, which summarize the state of the code's reliability and maintainability across the default branch.
To view your repository's ratings, navigate to the Security tab of your repository, expand コードの品質 in the sidebar, then click 標準の結果.
By resolving issues before merging your pull request, you've directly contributed to maintaining these ratings.
Next steps
- Address code quality findings in your default branch and understand your repository’s reliability and maintainability ratings. See Improving the quality of your repository's code.
- Provide feedback on GitHub Code Quality in the community discussion.