Skip to main content

Fixing code quality findings before merging your pull request

Catch quality issues before they reach your default branch and fix them with 코파일럿 자동 수정 and Copilot 코딩 에이전트.

누가 이 기능을 사용할 수 있나요?

쓰기 권한이 있는 사용자

GitHub Code Quality은 조직 소유의 리포지토리에서 GitHub Team 또는 GitHub Enterprise Cloud에서 사용 가능합니다.

참고 항목

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 코파일럿 자동 수정 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 코파일럿 자동 수정 or Copilot 코딩 에이전트 to fix findings

코파일럿 자동 수정

풀 리퀘스트에 대한 코멘트에는 풀 리퀘스트에 직접 커밋할 수 있는 제안된 자동 수정이 포함됩니다. 논리, 보안 및 스타일에 대해 제안된 자동 수정을 신중하게 검토한 다음 제안 적용을 클릭합니다.

이러한 제안을 적용하는 데는 Copilot 라이선스가 필요 없습니다.

Copilot 코딩 에이전트

또는 Copilot 라이선스가 있는 경우 수정 작업을 Copilot 코딩 에이전트에 위임할 수 있습니다. 풀 리퀘스트에 @Copilot을(를) 언급하는 주석을 달고, Copilot이 감지된 문제를 해결해달라고 요청합니다.

코필로트 코딩 에이전트를 호출한 PR 주석을 보여 주는 스크린샷

Copilot는 댓글에 눈 이모티콘(👀)으로 응답한 후, 새 에이전트 세션을 시작하고 필요한 수정 사항이 포함된 끌어오기 요청을 엽니다.

Copilot 코딩 에이전트의 작업을 추적할 수 있습니다.

  • 끌어오기 요청에서 작업이 진행됨에 따라 요약이 업데이트됩니다.
  •         [에이전트 페이지](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