blob: e090b0672b76e0c45a74c79cab13ed62cfe96704 [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
Vincent Scheib66fc2d42024-10-30 02:55:036This page documents policy rules regarding code changes.
7
8See also:
9- The general patch, upload, and land process in [contributing code](contributing.md#code-review)
10- [Code of conduct](../CODE_OF_CONDUCT.md)
11- [Respectful Changes](cl_respect.md)
12- [Respectful Code Reviews](cr_respect.md)
13- The code review changes and OWNERS policy changes launched on March 24, 2021, see
Jason D. Clintonc38b61d82021-04-20 20:02:1414[Mandatory Code Review and Native OWNERS](code_review_owners.md).
brettw40e953e2017-02-08 17:49:2815
16# Code review policies
17
Ramzi Nbe25013d2023-11-02 00:47:5318Any [committer](https://www.chromium.org/getting-involved/become-a-committer/#what-is-a-committer) can review code, but
19an owner must provide a review for each directory you are touching. Ideally you should choose
20reviewers who are familiar with the area of code you are touching. If you have doubts, look
21at the `git blame` for the file and the `OWNERS` files ([more info](#owners-files)).
brettw40e953e2017-02-08 17:49:2822
John Abd-El-Malekdfd1edc2021-02-24 22:22:4023To indicate a positive review, the reviewer provides a `Code-Review +1` in
Michael Giuffridaaf367052018-03-22 20:22:3424Gerrit, also known as an LGTM ("Looks Good To Me"). A score of "-1" indicates
25the change should not be submitted as-is.
brettw40e953e2017-02-08 17:49:2826
Ramzi Nbe25013d2023-11-02 00:47:5327Submissions to the chromium/src repository by a change contributor who is not a Chromium
28committer require two committers to Code-Review+1 the submission. If the owner of the CL
29is already a committer, then only one other committer is needed to review.
30
Michael Giuffridaaf367052018-03-22 20:22:3431If you have multiple reviewers, provide a message indicating what you expect
32from each reviewer. Otherwise people might assume their input is not required
33or waste time with redundant reviews.
brettw2019b9e2017-02-09 06:40:2034
Annie Sullivand04212e72017-10-19 21:11:3235Please also read [Respectful Changes](cl_respect.md) and
36[Respectful Code Reviews](cr_respect.md).
37
Robert Seseka8ee4a92023-07-13 23:04:3038There are also a [collection of tips](cl_tips.md) for productive reviews, though
39these are advisory and not policy.
40
brettw2019b9e2017-02-09 06:40:2041#### Expectations for all reviewers
brettw40e953e2017-02-08 17:49:2842
Erik Chenb3d9310f2025-01-07 19:41:3543* As a reviewer, aim to provide actionable feedback 3 times per work day. The
44 expectation is that if you're in the same time zone as the CL author, there
45 are 3 review iterations. If there is a time zone divide, aim for 2 review
46 iterations.
brettw40e953e2017-02-08 17:49:2847
Erik Chenb3d9310f2025-01-07 19:41:3548* Use the status field in Gerrit settings to indicate if you're away and when
Mike Frysinger7b15bde2018-05-15 09:28:0549 you'll be back.
brettw40e953e2017-02-08 17:49:2850
Erik Chenb3d9310f2025-01-07 19:41:3551* Don't generally discourage people from sending you code reviews. This
Michael Giuffridaaf367052018-03-22 20:22:3452 includes using a blanket "slow" in your status field.
brettw40e953e2017-02-08 17:49:2853
Erik Chen8bda7ba2025-02-26 21:30:2954#### Expectations for all authors
55
56* If a reviewer does not respond within 2 works days, add another
57 reviewer onto the CL. Do not remove the initial reviewer.
58
brettw40e953e2017-02-08 17:49:2859## OWNERS files
60
brettw2019b9e2017-02-09 06:40:2061In various directories there are files named `OWNERS` that list the email
brettw40e953e2017-02-08 17:49:2862addresses of people qualified to review changes in that directory. You must
63get a positive review from an owner of each directory your change touches.
64
brettw2019b9e2017-02-09 06:40:2065Owners files are recursive, so each file also applies to its subdirectories.
66It's generally best to pick more specific owners. People listed in higher-level
thestig9208d8ba2017-06-09 22:05:3267directories may have less experience with the code in question. For example,
68the reviewers in the `//chrome/browser/component_name/OWNERS` file will likely
69be more familiar with code in `//chrome/browser/component_name/sub_component`
70than reviewers in the higher-level `//chrome/OWNERS` file.
71
Lei Zhang3b32caa2021-03-22 17:24:1972More detail on the owners file format is provided [here](#owners-file-details).
brettw40e953e2017-02-08 17:49:2873
Lei Zhang3b32caa2021-03-22 17:24:1974*Tip:* The `git cl owners` command can help find owners. Gerrit also provides
Jason D. Clintonc38b61d82021-04-20 20:02:1475this functionality in the Reviewers field of CLs.
brettw40e953e2017-02-08 17:49:2876
77While owners must approve all patches, any committer can contribute to the
78review. In some directories the owners can be overloaded or there might be
79people not listed as owners who are more familiar with the low-level code in
80question. In these cases it's common to request a low-level review from an
81appropriate person, and then request a high-level owner review once that's
82complete. As always, be clear what you expect of each reviewer to avoid
83duplicated work.
84
brettw2019b9e2017-02-09 06:40:2085Owners do not have to pick other owners for reviews. Since they should already
86be familiar with the code in question, a thorough review from any appropriate
87committer is sufficient.
brettw40e953e2017-02-08 17:49:2888
brettw2019b9e2017-02-09 06:40:2089#### Expectations of owners
90
91The existing owners of a directory approve additions to the list. It is
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:1192preferable to have many directories, each with a smaller number of specific
Dirk Pranke02c8906f2025-01-28 18:20:5793owners rather than large directories with many owners. Owners must be
94[committers](https://www.chromium.org/getting-involved/become-a-committer/)
95with at least 3 months' tenure, and in addition should:
brettw2019b9e2017-02-09 06:40:2096
Dirk Pranke3042ec92022-01-12 16:53:4097 * Demonstrate excellent judgment, teamwork and ability to uphold
98 [Chromium development principles](contributing.md).
brettw2019b9e2017-02-09 06:40:2099
100 * Be already acting as an owner, providing high-quality reviews and design
Dirk Pranke4f9740c2018-10-17 03:01:06101 feedback.
brettw2019b9e2017-02-09 06:40:20102
brettw2019b9e2017-02-09 06:40:20103 * Have submitted a substantial number of non-trivial changes to the affected
brettw40e953e2017-02-08 17:49:28104 directory.
105
brettw2019b9e2017-02-09 06:40:20106 * Have committed or reviewed substantial work to the affected directory
Dirk Pranke4f9740c2018-10-17 03:01:06107 within the last ninety days.
brettw40e953e2017-02-08 17:49:28108
brettw2019b9e2017-02-09 06:40:20109 * Have the bandwidth to contribute to reviews in a timely manner. If the load
110 is unsustainable, work to expand the number of owners. Don't try to
111 discourage people from sending reviews, including writing "slow" or
112 "emeritus" after your name.
113
Dirk Pranke3042ec92022-01-12 16:53:40114Seldom-updated directories may have exceptions to the "substantiality" and
115"recency" requirements.
116
117Directories in `//third_party` should list those most familiar with the
118library, regardless of how often the code is updated.
119
Rick Byers2e7b2492025-03-17 13:03:24120#### Addition of new OWNERS
121
122New OWNERS are added by consensus of the existing OWNERS.
123
124Some directories have more well-defined processes for updating their OWNERS
125file which will be documented at the top of the OWNERS file itself (such as in
Rick Byers4095ea742025-03-17 21:43:48126[blink/renderer/](../third_party/blink/renderer/OWNERS)).
Rick Byers2e7b2492025-03-17 13:03:24127
128CLs for modifying OWNERS files should cc all other OWNERS for awareness (unless
129another awareness mechanism exists), and concerns may be raised even after
130the change has landed. Any disagreements should be escalated up to higher-level
131directory OWNERS or up to top-level [ATL_OWNERS](../ATL_OWNERS).
132
Dirk Pranke3042ec92022-01-12 16:53:40133#### Removal of owners
134
135If a code owner is not meeting the [expectations of
136owners](#expectations-of-owners) listed above for more than one quarter (and
137they are not on a leave during that time), then they may be removed by any
138co-owner or an owner from the parent directory after a 4-week notice, using
139the following process:
140
141 * Upload a change removing the owner and copy all owners in that directory,
142 including the owner in question.
143 * If the affected owner approves the change, it may be landed immediately.
144 * Otherwise, the change author must wait five working days for feedback from
145 the other owners.
146 * After that time has elapsed, if the change has received 3 approvals
147 with no objections from anyone else, the change may be landed.
148 * If the directory does not have 4 owners, then the decision should
149 be escalated to the owners of the parent directory (or directories)
Andrew Mitchell04049fe2024-04-26 00:53:30150 as necessary to provide enough votes.
Dirk Pranke3042ec92022-01-12 16:53:40151 * If there are objections, then the decision should be escalated to
Rick Byers2e7b2492025-03-17 13:03:24152 the [ATL_OWNERS](../ATL_OWNERS) for resolution.
brettw40e953e2017-02-08 17:49:28153
Kentaro Hara52294ae2022-08-12 07:37:30154Note: For the purpose of not slowing down code review, Chromium removes
155inactive owners (e.g., those who made no contributions for multiple quarters)
156on a regular basis. The script does not take into account personal situations
157like a long leave. If you were inactive only for a certain period of time
158while you were on a long leave and have been meeting the above owner's
159expectations in other times, you can create a CL to re-add yourself and land
160after getting local owner's approval (you can refer to this policy in the CL).
Yulan Lin331686622023-03-30 23:10:51161The removal script will cc the removed owner and one other owner to avoid spam.
Kentaro Hara52294ae2022-08-12 07:37:30162
brettw2019b9e2017-02-09 06:40:20163### OWNERS file details
164
Anthony Polito9ce2a482022-02-10 18:39:49165Refer to the [owners plugin](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/backend-find-owners.md)
thestig9208d8ba2017-06-09 22:05:32166for all details on the file format.
brettw2019b9e2017-02-09 06:40:20167
168This example indicates that two people are owners, in addition to any owners
169from the parent directory. `git cl owners` will list the comment after an
170owner address, so this is a good place to include restrictions or special
171instructions.
172```
173# You can include comments like this.
174[email protected]
175[email protected] # Only for the frobinator.
176```
177
178A `*` indicates that all committers are owners:
179```
180*
181```
182
brettwd040b0be2017-02-09 19:11:33183The text `set noparent` will stop owner propagation from parent directories.
Jochen Eisingerea8f92d82017-08-02 17:40:14184This should be rarely used. If you want to use `set noparent` except for IPC
John Abd-El-Malek704bca02022-12-14 18:47:59185related files, please first reach out to [email protected].
Jochen Eisingerea8f92d82017-08-02 17:40:14186
Jochen Eisinger8f0c8d82019-10-25 18:28:27187You have to use `set noparent` together with a reference to a file that lists
188the owners for the given use case. Approved use cases are listed in
189`//build/OWNERS.setnoparent`. Owners listed in those files are expected to
John Abd-El-Malek704bca02022-12-14 18:47:59190execute special governance functions such as ATL reviews or ipc security review.
Jochen Eisinger8f0c8d82019-10-25 18:28:27191Every set of owners should implement their own means of auditing membership. The
192minimum expectation is that membership in those files is reevaluated on
193project, or affiliation changes.
194
John Abd-El-Malek704bca02022-12-14 18:47:59195In this example, only the ATLs are owners:
brettw2019b9e2017-02-09 06:40:20196```
197set noparent
John Abd-El-Malek704bca02022-12-14 18:47:59198file://ATL_OWNERS
brettw2019b9e2017-02-09 06:40:20199```
200
201The `per-file` directive allows owners to be added that apply only to files
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:11202matching a pattern. In this example, owners from the parent directory
brettw2019b9e2017-02-09 06:40:20203apply, plus one person for some classes of files, and all committers are
204owners for the readme:
205```
206per-file [email protected]
207per-file foo.*[email protected]
208
209per-file readme.txt=*
210```
211
212Other `OWNERS` files can be included by reference by listing the path to the
213file with `file://...`. This example indicates that only the people listed in
214`//ipc/SECURITY_OWNERS` can review the messages files:
215```
216per-file *_messages*.h=set noparent
217per-file *_messages*.h=file://ipc/SECURITY_OWNERS
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55218```
Anthony Polito9ce2a482022-02-10 18:39:49219
220File globbing is supported using the
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55221[simple path expression](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/path-expressions.md#simple-path-expressions)
222format.
Steve Kobesf885edf2018-09-11 13:41:11223
Vincent Scheibe360db92025-01-23 17:12:07224Owners annotated with `#{LAST_RESORT_SUGGESTION}` in their comment will be
225omitted when suggesting code owners, except if dropping these code owners would
226make the suggestion result empty or if these code owners are already reviewers
227of the change.
228
Jason Clinton0daf7b02021-02-09 20:36:22229### Owners-Override
Steve Kobesf885edf2018-09-11 13:41:11230
John Abd-El-Malekdfd1edc2021-02-24 22:22:40231Setting the `Owners-Override +1` label will bypass OWNERS enforcement. Active
dpapadeb6dadcf2024-09-23 19:22:51232[gardeners](gardener.md), Release Program Managers,
Dirk Pranke3042ec92022-01-12 16:53:40233[Large Scale Changes](#large-scale-changes),
234[Global Approvers](#global-approvals) reviewers,
John Abd-El-Malek704bca02022-12-14 18:47:59235[Chrome ATLs](../ATL_OWNERS)
Dirk Pranke3042ec92022-01-12 16:53:40236have this capability. The power to use Owners-Override should be restricted
Kentaro Hara7e85d34a2021-10-08 15:33:16237as follows:
238
dpapadeb6dadcf2024-09-23 19:22:51239 * Active gardeners and Release Program Managers can set Owners-Override only
240 on CLs needed for gardening and releasing (e.g., revert, reland, test fix,
Kentaro Hara23878c62022-01-28 00:18:41241 cherry-pick).
dpapadeb6dadcf2024-09-23 19:22:51242 * Large Scale Change reviewers can set Owners-Override only on gardening CLs
Kentaro Hara0cdc6072021-10-15 00:35:16243 and CLs about the approved Large Scale Change.
dpapadeb6dadcf2024-09-23 19:22:51244 * Global approvers can set Owners-Override only on gardening CLs and
Kentaro Hara0cdc6072021-10-15 00:35:16245 mechanical CLs associated with their API changes. For example,
246 //base/OWNERS can set Owners-Override on mechanical CLs associated with
247 //base/ API changes.
John Abd-El-Malek704bca02022-12-14 18:47:59248 * Chrome ATLs can set Owners-Override on any changes to help with cases that
249 cannot be handled by the above groups and expedite CLs when LSC is too
250 heavyweight. However, please use one of the above groups before asking
251 Chrome ATLs.
Kentaro Hara0cdc6072021-10-15 00:35:16252
dpapadeb6dadcf2024-09-23 19:22:51253When you need Owners-Override on gardening CLs, please reach out to the
Kentaro Hara0cdc6072021-10-15 00:35:16254Active Sheriffs and Release Program Managers first. If none of them is
255available, please send an email to [email protected] for help.
256
Dirk Pranke3042ec92022-01-12 16:53:40257Note that Owners-Override by itself is not enough on your own CLs. Where this
dpapadeb6dadcf2024-09-23 19:22:51258matters is when you are gardening. For example, if you want to revert or
Stephen McGruer282391a2022-08-04 16:46:55259disable a test, your Owners-Override on the CL is not enough. You also need
260either another committer to LGTM the CL or, for clean reverts, a `Bot-Commit:
261+1` from the [rubber-stamper bot](#automated-code_review).
Steve Kobesf885edf2018-09-11 13:41:11262
Rick Byers8bdaba42025-01-08 14:12:30263When setting Owners-Override it is your responsibility to confirm that every
264file (and line) in the patch has been appropriately reviewed.
265
Jason Clinton0daf7b02021-02-09 20:36:22266## Mechanical changes
Steve Kobesf885edf2018-09-11 13:41:11267
John Abd-El-Malekdfd1edc2021-02-24 22:22:40268### Global Approvals
Dave Tapuska4661b902023-07-12 17:21:45269For one-off CLs, API owners of `base`, `build`, `content`,
270`third_party/blink/public` and `url` can `Owners-Override +1` a change to their
271APIs to avoid waiting for rubberstamp +1s from affected directories' owners.
Rick Byerse848f2ef2025-01-21 17:56:00272This should only be used for mechanical updates, but global approvers are free
273to use their judgement in determining which mechanical changes they understand
274well enough to approve (rather than limit strictly to calls into code
275they own).
Steve Kobesf885edf2018-09-11 13:41:11276
Rick Byerse848f2ef2025-01-21 17:56:00277For a change that impacts many directories but doesn't need area-specific
278expertise to review, please ask any global approver or Chrome ATL to
279approve the change rather than incur unnecessary review cost on a larger number
280of reviewers.
Kentaro Hara7e85d34a2021-10-08 15:33:16281
282### Large Scale Changes
283You can use the [Large Scale Changes](process/lsc/large_scale_changes.md)
284process to get approval to bypass OWNERS enforcement for large changes like
285refactoring, architectural changes, or other repetitive code changes across the
286whole codebase. This is used for work that span many dozen CLs.
287
Jason Clinton0daf7b02021-02-09 20:36:22288## Documentation updates
Steve Kobesf885edf2018-09-11 13:41:11289
Jason Clinton0daf7b02021-02-09 20:36:22290Documentation updates require code review. We may revisit this decision in the
291future.
Steve Kobesf885edf2018-09-11 13:41:11292
Jason Clinton0daf7b02021-02-09 20:36:22293## Automated code-review
Steve Kobesf885edf2018-09-11 13:41:11294
Jason Clinton0daf7b02021-02-09 20:36:22295For verifiably safe changes like translation files, clean reverts, and clean
296cherry-picks, we have automation that will vote +1 on the `Bot-Commit` label
297allowing the CL to be submitted without human code-review. Add `Rubber Stamper`
298([email protected]) to your CL as a reviewer to
299activate this automation. It will scan the CL after about 1 minute and reply
300with its verdict. `Bot-Commit` votes are not sticky between patchsets and so
301only add the bot once the CL is finalized.
Steve Kobesf885edf2018-09-11 13:41:11302
dpapadeb6dadcf2024-09-23 19:22:51303When combined with the [`Owners-Override`](#owners_override) power, gardeners
304can effectively revert and reland on their own.
Steve Kobesf885edf2018-09-11 13:41:11305
Jason Clinton6026fd192021-03-24 19:58:33306Rubber Stamper never provides OWNERS approval, by design. It's intended to be
dpapadeb6dadcf2024-09-23 19:22:51307used by those who have owners in the directory modified or who are gardeners. If
Jason D. Clintonc38b61d82021-04-20 20:02:14308it provided both code review and OWNERS approval, that would be an abuse vector:
309that would allow anyone who can create a revert or cherry-pick to land it
310without any other person being involved (e.g. the silent revert of security
311patches).
Jason Clinton6026fd192021-03-24 19:58:33312
Jason D. Clintonc38b61d82021-04-20 20:02:14313Changes not supported by `Rubber Stamper` always need a +1 from another
Jason Clinton0daf7b02021-02-09 20:36:22314committer.