blob: 2c9a87361ae13080a0242b7fd4d346154c05b84f [file] [log] [blame] [view]
brettw40e953e2017-02-08 17:49:281# Code Reviews
2
3Code reviews are a central part of developing high-quality code for Chromium.
Lei Zhang3b32caa2021-03-22 17:24:194All change lists (CLs) must be reviewed.
brettw40e953e2017-02-08 17:49:285
Daniel Cheng6bffde02020-06-12 19:10:456The general patch, upload, and land process is covered in more detail in the
Jason D. Clintonc38b61d82021-04-20 20:02:147[contributing code](contributing.md) page. To learn about the code review changes
8and OWNERS policy changes launched on March 24, 2021, see
9[Mandatory Code Review and Native OWNERS](code_review_owners.md).
brettw40e953e2017-02-08 17:49:2810
11# Code review policies
12
13Ideally the reviewer is someone who is familiar with the area of code you are
brettw2019b9e2017-02-09 06:40:2014touching. Any committer can review code, but an owner must provide a review
Lei Zhang3b32caa2021-03-22 17:24:1915for each directory you are touching. If you have doubts, look at the `git blame`
16for the file and the `OWNERS` files ([more info](#owners-files)).
brettw40e953e2017-02-08 17:49:2817
John Abd-El-Malekdfd1edc2021-02-24 22:22:4018To indicate a positive review, the reviewer provides a `Code-Review +1` in
Michael Giuffridaaf367052018-03-22 20:22:3419Gerrit, also known as an LGTM ("Looks Good To Me"). A score of "-1" indicates
20the change should not be submitted as-is.
brettw40e953e2017-02-08 17:49:2821
Michael Giuffridaaf367052018-03-22 20:22:3422If you have multiple reviewers, provide a message indicating what you expect
23from each reviewer. Otherwise people might assume their input is not required
24or waste time with redundant reviews.
brettw2019b9e2017-02-09 06:40:2025
Annie Sullivand04212e72017-10-19 21:11:3226Please also read [Respectful Changes](cl_respect.md) and
27[Respectful Code Reviews](cr_respect.md).
28
brettw2019b9e2017-02-09 06:40:2029#### Expectations for all reviewers
brettw40e953e2017-02-08 17:49:2830
31 * Aim to provide some kind of actionable response within 24 hours of receipt
Michael Giuffridaaf367052018-03-22 20:22:3432 (not counting weekends and holidays). This doesn't mean you have to do a
33 complete review, but you should be able to give some initial feedback,
34 request more time, or suggest another reviewer.
brettw40e953e2017-02-08 17:49:2835
Michael Giuffridaaf367052018-03-22 20:22:3436 * Use the status field in Gerrit settings to indicate if you're away and when
Mike Frysinger7b15bde2018-05-15 09:28:0537 you'll be back.
brettw40e953e2017-02-08 17:49:2838
39 * Don't generally discourage people from sending you code reviews. This
Michael Giuffridaaf367052018-03-22 20:22:3440 includes using a blanket "slow" in your status field.
brettw40e953e2017-02-08 17:49:2841
42## OWNERS files
43
brettw2019b9e2017-02-09 06:40:2044In various directories there are files named `OWNERS` that list the email
brettw40e953e2017-02-08 17:49:2845addresses of people qualified to review changes in that directory. You must
46get a positive review from an owner of each directory your change touches.
47
brettw2019b9e2017-02-09 06:40:2048Owners files are recursive, so each file also applies to its subdirectories.
49It's generally best to pick more specific owners. People listed in higher-level
thestig9208d8ba2017-06-09 22:05:3250directories may have less experience with the code in question. For example,
51the reviewers in the `//chrome/browser/component_name/OWNERS` file will likely
52be more familiar with code in `//chrome/browser/component_name/sub_component`
53than reviewers in the higher-level `//chrome/OWNERS` file.
54
Lei Zhang3b32caa2021-03-22 17:24:1955More detail on the owners file format is provided [here](#owners-file-details).
brettw40e953e2017-02-08 17:49:2856
Lei Zhang3b32caa2021-03-22 17:24:1957*Tip:* The `git cl owners` command can help find owners. Gerrit also provides
Jason D. Clintonc38b61d82021-04-20 20:02:1458this functionality in the Reviewers field of CLs.
brettw40e953e2017-02-08 17:49:2859
60While owners must approve all patches, any committer can contribute to the
61review. In some directories the owners can be overloaded or there might be
62people not listed as owners who are more familiar with the low-level code in
63question. In these cases it's common to request a low-level review from an
64appropriate person, and then request a high-level owner review once that's
65complete. As always, be clear what you expect of each reviewer to avoid
66duplicated work.
67
brettw2019b9e2017-02-09 06:40:2068Owners do not have to pick other owners for reviews. Since they should already
69be familiar with the code in question, a thorough review from any appropriate
70committer is sufficient.
brettw40e953e2017-02-08 17:49:2871
brettw2019b9e2017-02-09 06:40:2072#### Expectations of owners
73
74The existing owners of a directory approve additions to the list. It is
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:1175preferable to have many directories, each with a smaller number of specific
Dirk Pranke4f9740c2018-10-17 03:01:0676owners rather than large directories with many owners. Owners should:
brettw2019b9e2017-02-09 06:40:2077
Dirk Pranke3042ec92022-01-12 16:53:4078 * Demonstrate excellent judgment, teamwork and ability to uphold
79 [Chromium development principles](contributing.md).
brettw2019b9e2017-02-09 06:40:2080
81 * Be already acting as an owner, providing high-quality reviews and design
Dirk Pranke4f9740c2018-10-17 03:01:0682 feedback.
brettw2019b9e2017-02-09 06:40:2083
Dirk Pranke4f9740c2018-10-17 03:01:0684 * Be a Chromium project member with full commit access of at least three
brettw2019b9e2017-02-09 06:40:2085 months tenure.
86
87 * Have submitted a substantial number of non-trivial changes to the affected
brettw40e953e2017-02-08 17:49:2888 directory.
89
brettw2019b9e2017-02-09 06:40:2090 * Have committed or reviewed substantial work to the affected directory
Dirk Pranke4f9740c2018-10-17 03:01:0691 within the last ninety days.
brettw40e953e2017-02-08 17:49:2892
brettw2019b9e2017-02-09 06:40:2093 * Have the bandwidth to contribute to reviews in a timely manner. If the load
94 is unsustainable, work to expand the number of owners. Don't try to
95 discourage people from sending reviews, including writing "slow" or
96 "emeritus" after your name.
97
Dirk Pranke3042ec92022-01-12 16:53:4098Seldom-updated directories may have exceptions to the "substantiality" and
99"recency" requirements.
100
101Directories in `//third_party` should list those most familiar with the
102library, regardless of how often the code is updated.
103
104#### Removal of owners
105
106If a code owner is not meeting the [expectations of
107owners](#expectations-of-owners) listed above for more than one quarter (and
108they are not on a leave during that time), then they may be removed by any
109co-owner or an owner from the parent directory after a 4-week notice, using
110the following process:
111
112 * Upload a change removing the owner and copy all owners in that directory,
113 including the owner in question.
114 * If the affected owner approves the change, it may be landed immediately.
115 * Otherwise, the change author must wait five working days for feedback from
116 the other owners.
117 * After that time has elapsed, if the change has received 3 approvals
118 with no objections from anyone else, the change may be landed.
119 * If the directory does not have 4 owners, then the decision should
120 be escalated to the owners of the parent directory (or directories)
121 as necessary to provide enough of votes.
122 * If there are objections, then the decision should be escalated to
John Abd-El-Malek704bca02022-12-14 18:47:59123 the [../ATL_OWNERS](../ATL_OWNERS) for resolution.
brettw40e953e2017-02-08 17:49:28124
Kentaro Hara52294ae2022-08-12 07:37:30125Note: For the purpose of not slowing down code review, Chromium removes
126inactive owners (e.g., those who made no contributions for multiple quarters)
127on a regular basis. The script does not take into account personal situations
128like a long leave. If you were inactive only for a certain period of time
129while you were on a long leave and have been meeting the above owner's
130expectations in other times, you can create a CL to re-add yourself and land
131after getting local owner's approval (you can refer to this policy in the CL).
Yulan Lin331686622023-03-30 23:10:51132The removal script will cc the removed owner and one other owner to avoid spam.
Kentaro Hara52294ae2022-08-12 07:37:30133
brettw2019b9e2017-02-09 06:40:20134### OWNERS file details
135
Anthony Polito9ce2a482022-02-10 18:39:49136Refer to the [owners plugin](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/backend-find-owners.md)
thestig9208d8ba2017-06-09 22:05:32137for all details on the file format.
brettw2019b9e2017-02-09 06:40:20138
139This example indicates that two people are owners, in addition to any owners
140from the parent directory. `git cl owners` will list the comment after an
141owner address, so this is a good place to include restrictions or special
142instructions.
143```
144# You can include comments like this.
145a@chromium.org
146b@chromium.org # Only for the frobinator.
147```
148
149A `*` indicates that all committers are owners:
150```
151*
152```
153
brettwd040b0be2017-02-09 19:11:33154The text `set noparent` will stop owner propagation from parent directories.
Jochen Eisingerea8f92d82017-08-02 17:40:14155This should be rarely used. If you want to use `set noparent` except for IPC
John Abd-El-Malek704bca02022-12-14 18:47:59156related files, please first reach out to chrome-atls@google.com.
Jochen Eisingerea8f92d82017-08-02 17:40:14157
Jochen Eisinger8f0c8d82019-10-25 18:28:27158You have to use `set noparent` together with a reference to a file that lists
159the owners for the given use case. Approved use cases are listed in
160`//build/OWNERS.setnoparent`. Owners listed in those files are expected to
John Abd-El-Malek704bca02022-12-14 18:47:59161execute special governance functions such as ATL reviews or ipc security review.
Jochen Eisinger8f0c8d82019-10-25 18:28:27162Every set of owners should implement their own means of auditing membership. The
163minimum expectation is that membership in those files is reevaluated on
164project, or affiliation changes.
165
John Abd-El-Malek704bca02022-12-14 18:47:59166In this example, only the ATLs are owners:
brettw2019b9e2017-02-09 06:40:20167```
168set noparent
John Abd-El-Malek704bca02022-12-14 18:47:59169file://ATL_OWNERS
brettw2019b9e2017-02-09 06:40:20170```
171
172The `per-file` directive allows owners to be added that apply only to files
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:11173matching a pattern. In this example, owners from the parent directory
brettw2019b9e2017-02-09 06:40:20174apply, plus one person for some classes of files, and all committers are
175owners for the readme:
176```
177per-file foo_bar.cc=a@chromium.org
178per-file foo.*=a@chromium.org
179
180per-file readme.txt=*
181```
182
183Other `OWNERS` files can be included by reference by listing the path to the
184file with `file://...`. This example indicates that only the people listed in
185`//ipc/SECURITY_OWNERS` can review the messages files:
186```
187per-file *_messages*.h=set noparent
188per-file *_messages*.h=file://ipc/SECURITY_OWNERS
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55189```
Anthony Polito9ce2a482022-02-10 18:39:49190
191File globbing is supported using the
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55192[simple path expression](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/path-expressions.md#simple-path-expressions)
193format.
Steve Kobesf885edf2018-09-11 13:41:11194
Jason Clinton0daf7b02021-02-09 20:36:22195### Owners-Override
Steve Kobesf885edf2018-09-11 13:41:11196
John Abd-El-Malekdfd1edc2021-02-24 22:22:40197Setting the `Owners-Override +1` label will bypass OWNERS enforcement. Active
Dirk Pranke3042ec92022-01-12 16:53:40198[sheriffs](sheriffs.md), Release Program Managers,
199[Large Scale Changes](#large-scale-changes),
200[Global Approvers](#global-approvals) reviewers,
John Abd-El-Malek704bca02022-12-14 18:47:59201[Chrome ATLs](../ATL_OWNERS)
Dirk Pranke3042ec92022-01-12 16:53:40202have this capability. The power to use Owners-Override should be restricted
Kentaro Hara7e85d34a2021-10-08 15:33:16203as follows:
204
Kentaro Hara23878c62022-01-28 00:18:41205 * Active sheriffs and Release Program Managers can set Owners-Override only on
206 CLs needed for sheriffing and releasing (e.g., revert, reland, test fix,
207 cherry-pick).
Kentaro Hara0cdc6072021-10-15 00:35:16208 * Large Scale Change reviewers can set Owners-Override only on sheriffing CLs
209 and CLs about the approved Large Scale Change.
210 * Global approvers can set Owners-Override only on sheriffing CLs and
211 mechanical CLs associated with their API changes. For example,
212 //base/OWNERS can set Owners-Override on mechanical CLs associated with
213 //base/ API changes.
John Abd-El-Malek704bca02022-12-14 18:47:59214 * Chrome ATLs can set Owners-Override on any changes to help with cases that
215 cannot be handled by the above groups and expedite CLs when LSC is too
216 heavyweight. However, please use one of the above groups before asking
217 Chrome ATLs.
Kentaro Hara0cdc6072021-10-15 00:35:16218
219When you need Owners-Override on sheriffing CLs, please reach out to the
220Active Sheriffs and Release Program Managers first. If none of them is
221available, please send an email to lsc-owners-override@chromium.org for help.
222
Dirk Pranke3042ec92022-01-12 16:53:40223Note that Owners-Override by itself is not enough on your own CLs. Where this
224matters is when you are sheriffing. For example, if you want to revert or
Stephen McGruer282391a2022-08-04 16:46:55225disable a test, your Owners-Override on the CL is not enough. You also need
226either another committer to LGTM the CL or, for clean reverts, a `Bot-Commit:
227+1` from the [rubber-stamper bot](#automated-code_review).
Steve Kobesf885edf2018-09-11 13:41:11228
Jason Clinton0daf7b02021-02-09 20:36:22229## Mechanical changes
Steve Kobesf885edf2018-09-11 13:41:11230
John Abd-El-Malekdfd1edc2021-02-24 22:22:40231### Global Approvals
Lei Zhang3b32caa2021-03-22 17:24:19232For one-off CLs, API owners of `base`, `build`, `content`, `third_party/blink`
233and `url` can `Owners-Override +1` a change to their APIs to avoid waiting for
234rubberstamp +1s from affected directories' owners. This should only be used for
235mechanical updates to the affected directories.
Steve Kobesf885edf2018-09-11 13:41:11236
Dirk Pranke3042ec92022-01-12 16:53:40237If you are making one-off CLs that touch many directories and cannot be
John Abd-El-Malek704bca02022-12-14 18:47:59238handled by the global approvers, you can ask one of Chrome ATLs.
Kentaro Hara7e85d34a2021-10-08 15:33:16239
240### Large Scale Changes
241You can use the [Large Scale Changes](process/lsc/large_scale_changes.md)
242process to get approval to bypass OWNERS enforcement for large changes like
243refactoring, architectural changes, or other repetitive code changes across the
244whole codebase. This is used for work that span many dozen CLs.
245
Jason Clinton0daf7b02021-02-09 20:36:22246## Documentation updates
Steve Kobesf885edf2018-09-11 13:41:11247
Jason Clinton0daf7b02021-02-09 20:36:22248Documentation updates require code review. We may revisit this decision in the
249future.
Steve Kobesf885edf2018-09-11 13:41:11250
Jason Clinton0daf7b02021-02-09 20:36:22251## Automated code-review
Steve Kobesf885edf2018-09-11 13:41:11252
Jason Clinton0daf7b02021-02-09 20:36:22253For verifiably safe changes like translation files, clean reverts, and clean
254cherry-picks, we have automation that will vote +1 on the `Bot-Commit` label
255allowing the CL to be submitted without human code-review. Add `Rubber Stamper`
256(rubber-stamper@appspot.gserviceaccount.com) to your CL as a reviewer to
257activate this automation. It will scan the CL after about 1 minute and reply
258with its verdict. `Bot-Commit` votes are not sticky between patchsets and so
259only add the bot once the CL is finalized.
Steve Kobesf885edf2018-09-11 13:41:11260
Lei Zhang3b32caa2021-03-22 17:24:19261When combined with the [`Owners-Override`](#owners_override) power, sheriffs can
262effectively revert and reland on their own.
Steve Kobesf885edf2018-09-11 13:41:11263
Jason Clinton6026fd192021-03-24 19:58:33264Rubber Stamper never provides OWNERS approval, by design. It's intended to be
Jason D. Clintonc38b61d82021-04-20 20:02:14265used by those who have owners in the directory modified or who are sheriffs. If
266it provided both code review and OWNERS approval, that would be an abuse vector:
267that would allow anyone who can create a revert or cherry-pick to land it
268without any other person being involved (e.g. the silent revert of security
269patches).
Jason Clinton6026fd192021-03-24 19:58:33270
Jason D. Clintonc38b61d82021-04-20 20:02:14271Changes not supported by `Rubber Stamper` always need a +1 from another
Jason Clinton0daf7b02021-02-09 20:36:22272committer.