Примечание.
GitHub Code Quality в настоящее время находится в public preview и может быть изменен. Во время public preview, 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 Автофикс второго пилота 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[бот]. 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 Автофикс второго пилота or Агент кодирования Copilot to fix findings
Автофикс второго пилота
Комментарии к запросу pull включают предлагаемое автоисправление , которое вы можете зафиксировать непосредственно в своем запросе pull. Внимательно изучите предложенное автоисправление на предмет логики, безопасности и стиля, затем нажмите «Предложить фиксацию».
Вам не нужна лицензия Copilot, чтобы применить эти предложения.
Агент кодирования Copilot
В качестве альтернативы, если у вас есть лицензия Copilot, вы можете делегировать работу по исправлению Агент кодирования Copilot. Прокомментируйте запрос на вытягивание с упоминанием @Copilot и попросите Copilot исправить обнаруженные проблемы.

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.