Skip to content

Commit a709705

Browse files
authored
[EDI 5500 - Builders] Update Copilot code review docs in light of EDI audit (#56662)
1 parent 45fe37e commit a709705

File tree

11 files changed

+215
-200
lines changed

11 files changed

+215
-200
lines changed

content/code-security/trialing-github-advanced-security/explore-trial-code-scanning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ This allows you to update the configuration in a single location, but use the wo
8888
> {% data reusables.copilot.code-review.preview-note %}
8989
> * If you get a {% data variables.product.prodname_copilot_short %} subscription from an organization, you will only be able to participate in the {% data variables.release-phases.public_preview %} on the {% data variables.product.github %} website if an owner of your organization {% ifversion ghec %}or enterprise{% endif %} has enabled **Copilot in GitHub.com > Opt in to preview features** in the **{% data variables.product.prodname_copilot %} policies** page of the organization {% ifversion ghec %}or enterprise{% endif %} settings. See [AUTOTITLE](/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-policies-for-copilot-in-your-organization#enabling-copilot-features-in-your-organization){% ifversion ghec %} and [AUTOTITLE](/copilot/managing-copilot/managing-copilot-for-your-enterprise/managing-policies-and-features-for-copilot-in-your-enterprise#copilot-in-githubcom){% endif %}.
9090
91-
By default, users request a review from {% data variables.product.prodname_copilot_short %} in the same way as they do from human reviewers. However, you can update or create an organization-level branch ruleset to automatically add {% data variables.product.prodname_copilot_short %} as a reviewer to all pull requests made to selected branches in all or selected repositories. See [AUTOTITLE](/copilot/using-github-copilot/code-review/configuring-automatic-code-review-by-copilot).
91+
By default, users request a review from {% data variables.product.prodname_copilot_short %} in the same way as they do from human reviewers. However, you can update or create an organization-level branch ruleset to automatically add {% data variables.product.prodname_copilot_short %} as a reviewer to all pull requests made to selected branches in all or selected repositories. See [AUTOTITLE](/copilot/how-tos/agents/copilot-code-review/automatic-code-review).
9292

9393
{% data variables.product.prodname_copilot_short %} leaves a review comment on each pull request it reviews, without approving the pull request or requesting changes. This ensures that its review is advisory and will not block development work. Similarly, you should not enforce the resolution of suggestions made by {% data variables.product.prodname_copilot_short %} because AI suggestions have known limitations, see [AUTOTITLE](/copilot/responsible-use-of-github-copilot-features/responsible-use-of-github-copilot-code-review#limitations-of-github-copilot-code-review).
9494

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: About Copilot code review
3+
shortTitle: About code review
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Find out how {% data variables.product.prodname_copilot_short %} can review pull requests for you.'
6+
versions:
7+
feature: copilot
8+
topics:
9+
- Copilot
10+
redirect_from:
11+
- /copilot/code-review
12+
---
13+
14+
## Introduction
15+
16+
{% data variables.product.prodname_copilot %} can review your code and provide feedback. Where possible, {% data variables.product.prodname_copilot_short %}'s feedback includes suggested changes which you can apply with a couple of clicks.
17+
18+
{% data variables.product.prodname_copilot_short %} can review code written in any programming language.
19+
20+
This article provides an overview of {% data variables.copilot.copilot_code-review_short %}. For instructions on how to request a code review from {% data variables.product.prodname_copilot_short %}, see [AUTOTITLE](/copilot/how-tos/agents/copilot-code-review/using-copilot-code-review).
21+
22+
## Availability
23+
24+
{% data variables.copilot.copilot_code-review_short %} is—with one exception—a premium feature, available with the {% data variables.copilot.copilot_pro_short %}, {% data variables.copilot.copilot_pro_plus_short %}, {% data variables.copilot.copilot_business_short %}, and {% data variables.copilot.copilot_enterprise_short %} plans.
25+
26+
The exception is the review of a selection of code within a file in {% data variables.product.prodname_vscode %}. This is a standard feature available to all {% data variables.product.prodname_copilot_short %} users in {% data variables.product.prodname_vscode_shortname %}.
27+
28+
If you receive {% data variables.product.prodname_copilot_short %} from an organization then, to be able to request a pull request review from {% data variables.product.prodname_copilot_short %} on {% data variables.product.prodname_dotcom_the_website %} or in {% data variables.product.prodname_mobile %}, the **{% data variables.product.prodname_copilot_short %} in {% data variables.product.prodname_dotcom_the_website %}** option must be enabled in the {% data variables.product.prodname_copilot_short %} policy settings for the organization. See [AUTOTITLE](/copilot/how-tos/administer/organizations/managing-policies-for-copilot-in-your-organization).
29+
30+
## Code review monthly quota
31+
32+
When you assign {% data variables.product.prodname_copilot_short %} as a reviewer for a pull request—or when you request {% data variables.product.prodname_copilot_short %} to review all of your uncommitted changes in your IDE—your monthly quota of Copilot premium requests is reduced by one. For information about premium requests, see [AUTOTITLE](/copilot/managing-copilot/monitoring-usage-and-entitlements/about-premium-requests).
33+
34+
If a repository is configured to automatically request a code review from {% data variables.product.prodname_copilot_short %} for all new pull requests, the premium request usage is applied to the quota of the pull request author. If a pull request is created by {% data variables.product.prodname_actions %} or by a bot, the usage will apply to the user who triggered the workflow (if identifiable), or to a designated billing owner.
35+
36+
When you reach your monthly quota you will not be able to get a code review from {% data variables.product.prodname_copilot_short %} until your quota resets—unless you upgrade your {% data variables.product.prodname_copilot_short %} plan or enable additional premium requests.
37+
38+
## {% data variables.copilot.copilot_code-review_short %} in {% data variables.product.prodname_vscode %}
39+
40+
{% data variables.copilot.copilot_code-review_short %} in {% data variables.product.prodname_vscode %} supports two types of review:
41+
42+
* **Review selection:**
43+
* Highlight code and ask for an initial review.
44+
* Standard {% data variables.product.prodname_copilot_short %} feature. No premium requests used.
45+
* Does not support custom instructions or custom coding guidelines.
46+
* **Review changes:**
47+
* Request a deeper review of all of your uncommitted changes.
48+
* Premium feature. Uses one premium request from your monthly quota per review.
49+
* Supports custom instructions and custom coding guidelines.
50+
51+
## Validating {% data variables.product.prodname_copilot_short %} code reviews
52+
53+
{% data variables.product.prodname_copilot_short %} isn't guaranteed to spot all problems or issues in a pull request, and sometimes it will make mistakes. Always validate {% data variables.product.prodname_copilot_short %}'s feedback carefully, and supplement {% data variables.product.prodname_copilot_short %}'s feedback with a human review.
54+
55+
For more information, see [AUTOTITLE](/copilot/responsible-use-of-github-copilot-features/responsible-use-of-github-copilot-code-review).
56+
57+
## About automatic pull request reviews
58+
59+
By default, {% data variables.product.prodname_copilot_short %} will only review a pull request if it's assigned to the pull request in the same way you would assign a human reviewer. However:
60+
61+
* Individual users on the {% data variables.copilot.copilot_pro_short %} or {% data variables.copilot.copilot_pro_plus_short %} plan can configure {% data variables.product.prodname_copilot_short %} to automatically review all pull requests they create.
62+
* Repository owners can configure {% data variables.product.prodname_copilot_short %} to automatically review all pull requests in the repository that are created by people with access to {% data variables.product.prodname_copilot_short %}.
63+
* Organization owners can configure {% data variables.product.prodname_copilot_short %} to automatically review all pull requests in some or all of the repositories in the organization where the pull request is created by a {% data variables.product.prodname_copilot_short %} user.
64+
65+
### Triggering an automatic pull request review
66+
67+
After you configure automatic code review, {% data variables.product.prodname_copilot_short %} will review pull requests in the following situations:
68+
69+
* When a pull request is created as an "Open" pull request.
70+
71+
A review is not triggered if the pull request is created as a "Draft" pull request.
72+
73+
* The first time a "Draft" pull request is switched to "Open".
74+
75+
> [!NOTE]
76+
> {% data variables.product.prodname_copilot_short %} only automatically reviews a pull request once. If you make changes to the pull request after it has been automatically reviewed and you want {% data variables.product.prodname_copilot_short %} to re-review the pull request, you must request this manually. To do this, click the {% octicon "sync" aria-label="Re-request review" %} button next to {% data variables.product.prodname_copilot_short %}'s name in the **Reviewers** menu.
77+
78+
### Limits on automatic pull request reviews
79+
80+
{% data variables.copilot.copilot_code-review_short %} is a premium feature with a per-person monthly quota. When {% data variables.product.prodname_copilot_short %} carries out an automatic review, it uses one premium request from the quota of the user who created the pull request. For more information, see [AUTOTITLE](/copilot/using-github-copilot/code-review/using-copilot-code-review#code-review-monthly-quota).
81+
82+
## Configuring automatic pull request reviews
83+
84+
For details of how to configure {% data variables.product.prodname_copilot_short %} to automatically review new pull requests, see [AUTOTITLE](/copilot/how-tos/agents/copilot-code-review/configuring-automatic-code-review-by-copilot).
85+
86+
## Further reading
87+
88+
* [AUTOTITLE](/copilot/how-tos/agents/copilot-code-review/using-copilot-code-review)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: About coding guidelines for GitHub Copilot code review
3+
shortTitle: Coding guidelines
4+
allowTitleToDifferFromFilename: true
5+
intro: "Find out how you can use custom coding guidelines to improve {% data variables.product.prodname_copilot_short %}'s pull request reviews."
6+
versions:
7+
feature: copilot
8+
topics:
9+
- Copilot
10+
---
11+
12+
{% data reusables.copilot.code-review.custom-coding-guidelines-prerequisites %} See [AUTOTITLE](/copilot/how-tos/custom-instructions/adding-repository-custom-instructions-for-github-copilot?tool=webui).
13+
14+
## About coding guidelines
15+
16+
You can customize {% data variables.copilot.copilot_code-review_short %} with custom coding guidelines written in natural language. For more information on {% data variables.copilot.copilot_code-review_short %}, see [AUTOTITLE](/copilot/concepts/code-review/code-review).
17+
18+
With coding guidelines, {% data variables.product.prodname_copilot_short %} can give feedback based on your organization's specific coding style and best practices.
19+
20+
Because {% data variables.copilot.copilot_code-review_short %} is powered by a large language model, it can help with enforcing coding guidelines that are not covered by your linter or static analysis tool.
21+
22+
Coding guidelines are configured at the repository level. You can create and enable up to 6 coding guidelines per repository. See [AUTOTITLE](/copilot/how-tos/agents/copilot-code-review/configuring-coding-guidelines).
23+
24+
When you request a review from {% data variables.product.prodname_copilot_short %}, it will automatically use the repository's enabled coding guidelines to review your code.
25+
26+
Comments generated based on a coding guideline will include a message, highlighting their source.
27+
28+
> [!NOTE] Coding guidelines only apply to code reviews carried out by Copilot. The guidelines do not affect Copilot code completion suggestions, or code suggested in Copilot Chat responses.
29+
30+
## Dos and don'ts for coding guidelines
31+
32+
* **Do** use simple, clear and concise language to describe your coding guideline.
33+
* **Do** be as specific as possible about what Copilot should look for - that is, what you do or don't want to see in your code.
34+
* **Do** take a look at the [Coding guidelines examples](#coding-guidelines-examples) below for some inspiration.
35+
* **Don't** try to use coding guidelines to enforce style guidelines that can be covered by your linter or static analysis tool.
36+
* **Don't** use wording that is ambiguous or could be interpreted in different ways.
37+
* **Don't** try to fit multiple different ideas into a single coding guideline.
38+
39+
## Coding guidelines examples
40+
41+
### Example 1: Avoid using magic numbers
42+
43+
**Title:** <code>Avoid using magic numbers</code>
44+
45+
**Description:** <code>Don't use magic numbers in code. Numbers should be defined as constants or variables with meaningful names.</code>
46+
47+
**Path patterns:** `**/*.py`
48+
49+
### Example 2: Don't use `SELECT *` in SQL queries
50+
51+
**Title:** <code>Don't use &#96;SELECT \*&#96; in SQL queries</code>
52+
53+
**Description:** <code>Don't use &#96;SELECT \*&#96; in SQL queries. Always specify the columns you want to select. &#96;COUNT(\*)&#96; is allowed.</code>
54+
55+
**Path patterns:** None (applies to all file types, as SQL queries may be embedded in code).
56+
57+
### Example 3: Use `fetch` for HTTP requests
58+
59+
**Title:** <code>Use &#96;fetch&#96; for HTTP requests</code>
60+
61+
**Description:** <code>Use &#96;fetch&#96; for HTTP requests, not &#96;axios&#96; or &#96;superagent&#96; or other libraries.</code>
62+
63+
**Path patterns:** `**/*.ts`, `**/*.js`, `**/*.jsx`, `**/*.tsx`
64+
65+
### Example 4: Always tag metrics with the current environment
66+
67+
**Title:** <code>Always tag metrics with the current environment</code>
68+
69+
**Description:** <code>Always include a &#96;env&#96; tag with the current environment when emitting metrics, for example, &#96;env:prod&#96; or &#96;env:dev&#96;.</code>
70+
71+
**Path patterns:** `*/*.go`, `*/*.java`
72+
73+
## Further reading
74+
75+
* [AUTOTITLE](/copilot/how-tos/agents/copilot-code-review/configuring-coding-guidelines)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: 'Concepts for GitHub Copilot code review'
3+
shortTitle: Code review
4+
intro: 'Understand how you can use {% data variables.product.prodname_copilot_short %} to review your code.'
5+
versions:
6+
feature: copilot
7+
topics:
8+
- Copilot
9+
children:
10+
- /code-review
11+
- /coding-guidelines
12+
---
13+
14+
These articles provide an introduction to {% data variables.copilot.copilot_code-review_short %}. For instructions on configuring and using {% data variables.copilot.copilot_code-review_short %}, see the how-to articles under [AUTOTITLE](/copilot/how-tos/agents/copilot-code-review).

content/copilot/concepts/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ children:
1212
- /completions
1313
- /prompt-engineering-for-copilot-chat
1414
- /about-customizing-github-copilot-chat-responses
15+
- /about-copilot-coding-agent
16+
- /code-review
1517
- /about-github-copilot-chat
1618
- /content-exclusion-for-github-copilot
1719
- /indexing-repositories-for-copilot-chat
18-
- /about-copilot-coding-agent
1920
- /about-organizing-and-sharing-context-with-copilot-spaces
2021
- /policies
2122
- /copilot-knowledge-bases
Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
11
---
22
title: Configuring automatic code review by Copilot
33
shortTitle: Configure automatic review
4+
allowTitleToDifferFromFilename: true
45
intro: 'Learn how to configure {% data variables.product.prodname_copilot_short %} to automatically review pull requests.'
56
versions:
67
feature: copilot
78
topics:
89
- Copilot
910
redirect_from:
1011
- /copilot/using-github-copilot/code-review/configuring-automatic-code-review-by-copilot
12+
- /copilot/how-tos/agents/copilot-code-review/configuring-automatic-code-review-by-copilot
1113
---
1214

13-
## About automatic code review
15+
## Introduction
1416

15-
By default, {% data variables.product.prodname_copilot_short %} will only review a pull request if it's assigned to the pull request in the same way you would assign a human reviewer. However:
17+
This article tells you how to set up {% data variables.copilot.copilot_code-review_short %} to review pull requests automatically. For an overview of automatic pull request reviews, see [AUTOTITLE](/copilot/concepts/code-review/code-review#about-automatic-pull-request-reviews).
1618

17-
* Individual users on the {% data variables.copilot.copilot_pro_short %} or {% data variables.copilot.copilot_pro_plus_short %} plan can configure {% data variables.product.prodname_copilot_short %} to automatically review all pull requests they create.
18-
* Repository owners can configure {% data variables.product.prodname_copilot_short %} to automatically review all pull requests in the repository that are created by people with access to {% data variables.product.prodname_copilot_short %}.
19-
* Organization owners can configure {% data variables.product.prodname_copilot_short %} to automatically review all pull requests in some or all of the repositories in the organization where the pull request is created by a {% data variables.product.prodname_copilot_short %} user.
19+
The three sections in this article tell you how to configure automatic code review for:
2020

21-
### Triggering an automatic pull request review
22-
23-
After you configure automatic code review, {% data variables.product.prodname_copilot_short %} will review pull requests in the following situations:
24-
25-
* When a pull request is created as an "Open" pull request.
26-
27-
A review is not triggered if the pull request is created as a "Draft" pull request.
28-
29-
* The first time a "Draft" pull request is switched to "Open".
30-
31-
> [!NOTE]
32-
> {% data variables.product.prodname_copilot_short %} only automatically reviews a pull request once. If you make changes to the pull request after it has been automatically reviewed and you want {% data variables.product.prodname_copilot_short %} to re-review the pull request, you must request this manually. To do this, click the {% octicon "sync" aria-label="Re-request review" %} button next to {% data variables.product.prodname_copilot_short %}'s name in the **Reviewers** menu.
33-
34-
### Limits on automatic pull request reviews
35-
36-
{% data variables.copilot.copilot_code-review_short %} is a premium feature with a per-person monthly quota. When {% data variables.product.prodname_copilot_short %} carries out an automatic review, it uses one premium request from the quota of the user who created the pull request. For more information, see [AUTOTITLE](/copilot/using-github-copilot/code-review/using-copilot-code-review#code-review-monthly-quota).
21+
* [Pull requests that you create yourself](#configuring-automatic-code-review-for-all-pull-requests-you-create)
22+
* [All new pull requests in a repository](#configuring-automatic-code-review-for-a-single-repository)
23+
* [Pull requests in multiple repositories owned by an organization](#configuring-automatic-code-review-for-repositories-in-an-organization)
3724

3825
## Configuring automatic code review for all pull requests you create
3926

0 commit comments

Comments
 (0)