blob: 0e34979d60f855e63fefcb61249f3efa3b31318b [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
Colin Blundell59a6fc02025-12-02 07:48:5848* Use the "Display name" and "About me" fields in Gerrit settings to indicate
49 if you're away and when 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
Colin Blundell59a6fc02025-12-02 07:48:5852 includes using a blanket "slow" in your "Display name" or "About me"
53 fields.
brettw40e953e2017-02-08 17:49:2854
Erik Chen8bda7ba2025-02-26 21:30:2955#### Expectations for all authors
56
57* If a reviewer does not respond within 2 works days, add another
58 reviewer onto the CL. Do not remove the initial reviewer.
59
brettw40e953e2017-02-08 17:49:2860## OWNERS files
61
brettw2019b9e2017-02-09 06:40:2062In various directories there are files named `OWNERS` that list the email
brettw40e953e2017-02-08 17:49:2863addresses of people qualified to review changes in that directory. You must
64get a positive review from an owner of each directory your change touches.
65
brettw2019b9e2017-02-09 06:40:2066Owners files are recursive, so each file also applies to its subdirectories.
67It's generally best to pick more specific owners. People listed in higher-level
thestig9208d8ba2017-06-09 22:05:3268directories may have less experience with the code in question. For example,
69the reviewers in the `//chrome/browser/component_name/OWNERS` file will likely
70be more familiar with code in `//chrome/browser/component_name/sub_component`
71than reviewers in the higher-level `//chrome/OWNERS` file.
72
Lei Zhang3b32caa2021-03-22 17:24:1973More detail on the owners file format is provided [here](#owners-file-details).
brettw40e953e2017-02-08 17:49:2874
Lei Zhang3b32caa2021-03-22 17:24:1975*Tip:* The `git cl owners` command can help find owners. Gerrit also provides
Jason D. Clintonc38b61d82021-04-20 20:02:1476this functionality in the Reviewers field of CLs.
brettw40e953e2017-02-08 17:49:2877
78While owners must approve all patches, any committer can contribute to the
79review. In some directories the owners can be overloaded or there might be
80people not listed as owners who are more familiar with the low-level code in
81question. In these cases it's common to request a low-level review from an
82appropriate person, and then request a high-level owner review once that's
83complete. As always, be clear what you expect of each reviewer to avoid
84duplicated work.
85
brettw2019b9e2017-02-09 06:40:2086Owners do not have to pick other owners for reviews. Since they should already
87be familiar with the code in question, a thorough review from any appropriate
88committer is sufficient.
brettw40e953e2017-02-08 17:49:2889
brettw2019b9e2017-02-09 06:40:2090#### Expectations of owners
91
92The existing owners of a directory approve additions to the list. It is
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:1193preferable to have many directories, each with a smaller number of specific
Dirk Pranke02c8906f2025-01-28 18:20:5794owners rather than large directories with many owners. Owners must be
95[committers](https://www.chromium.org/getting-involved/become-a-committer/)
96with at least 3 months' tenure, and in addition should:
brettw2019b9e2017-02-09 06:40:2097
Dirk Pranke3042ec92022-01-12 16:53:4098 * Demonstrate excellent judgment, teamwork and ability to uphold
99 [Chromium development principles](contributing.md).
brettw2019b9e2017-02-09 06:40:20100
101 * Be already acting as an owner, providing high-quality reviews and design
Dirk Pranke4f9740c2018-10-17 03:01:06102 feedback.
brettw2019b9e2017-02-09 06:40:20103
brettw2019b9e2017-02-09 06:40:20104 * Have submitted a substantial number of non-trivial changes to the affected
brettw40e953e2017-02-08 17:49:28105 directory.
106
brettw2019b9e2017-02-09 06:40:20107 * Have committed or reviewed substantial work to the affected directory
Dirk Pranke4f9740c2018-10-17 03:01:06108 within the last ninety days.
brettw40e953e2017-02-08 17:49:28109
brettw2019b9e2017-02-09 06:40:20110 * Have the bandwidth to contribute to reviews in a timely manner. If the load
111 is unsustainable, work to expand the number of owners. Don't try to
112 discourage people from sending reviews, including writing "slow" or
113 "emeritus" after your name.
114
Dirk Pranke3042ec92022-01-12 16:53:40115Seldom-updated directories may have exceptions to the "substantiality" and
116"recency" requirements.
117
118Directories in `//third_party` should list those most familiar with the
119library, regardless of how often the code is updated.
120
Rick Byers2e7b2492025-03-17 13:03:24121#### Addition of new OWNERS
122
123New OWNERS are added by consensus of the existing OWNERS.
124
125Some directories have more well-defined processes for updating their OWNERS
126file which will be documented at the top of the OWNERS file itself (such as in
Rick Byers4095ea742025-03-17 21:43:48127[blink/renderer/](../third_party/blink/renderer/OWNERS)).
Rick Byers2e7b2492025-03-17 13:03:24128
129CLs for modifying OWNERS files should cc all other OWNERS for awareness (unless
130another awareness mechanism exists), and concerns may be raised even after
131the change has landed. Any disagreements should be escalated up to higher-level
132directory OWNERS or up to top-level [ATL_OWNERS](../ATL_OWNERS).
133
Dirk Pranke3042ec92022-01-12 16:53:40134#### Removal of owners
135
136If a code owner is not meeting the [expectations of
137owners](#expectations-of-owners) listed above for more than one quarter (and
138they are not on a leave during that time), then they may be removed by any
139co-owner or an owner from the parent directory after a 4-week notice, using
140the following process:
141
142 * Upload a change removing the owner and copy all owners in that directory,
143 including the owner in question.
144 * If the affected owner approves the change, it may be landed immediately.
145 * Otherwise, the change author must wait five working days for feedback from
146 the other owners.
147 * After that time has elapsed, if the change has received 3 approvals
148 with no objections from anyone else, the change may be landed.
149 * If the directory does not have 4 owners, then the decision should
150 be escalated to the owners of the parent directory (or directories)
Andrew Mitchell04049fe2024-04-26 00:53:30151 as necessary to provide enough votes.
Dirk Pranke3042ec92022-01-12 16:53:40152 * If there are objections, then the decision should be escalated to
Rick Byers2e7b2492025-03-17 13:03:24153 the [ATL_OWNERS](../ATL_OWNERS) for resolution.
brettw40e953e2017-02-08 17:49:28154
Kentaro Hara52294ae2022-08-12 07:37:30155Note: For the purpose of not slowing down code review, Chromium removes
156inactive owners (e.g., those who made no contributions for multiple quarters)
157on a regular basis. The script does not take into account personal situations
158like a long leave. If you were inactive only for a certain period of time
159while you were on a long leave and have been meeting the above owner's
160expectations in other times, you can create a CL to re-add yourself and land
161after getting local owner's approval (you can refer to this policy in the CL).
Yulan Lin331686622023-03-30 23:10:51162The removal script will cc the removed owner and one other owner to avoid spam.
Kentaro Hara52294ae2022-08-12 07:37:30163
brettw2019b9e2017-02-09 06:40:20164### OWNERS file details
165
Anthony Polito9ce2a482022-02-10 18:39:49166Refer to the [owners plugin](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/backend-find-owners.md)
thestig9208d8ba2017-06-09 22:05:32167for all details on the file format.
brettw2019b9e2017-02-09 06:40:20168
169This example indicates that two people are owners, in addition to any owners
170from the parent directory. `git cl owners` will list the comment after an
171owner address, so this is a good place to include restrictions or special
172instructions.
173```
174# You can include comments like this.
175[email protected]
176[email protected] # Only for the frobinator.
177```
178
179A `*` indicates that all committers are owners:
180```
181*
182```
183
brettwd040b0be2017-02-09 19:11:33184The text `set noparent` will stop owner propagation from parent directories.
Jochen Eisingerea8f92d82017-08-02 17:40:14185This should be rarely used. If you want to use `set noparent` except for IPC
John Abd-El-Malek704bca02022-12-14 18:47:59186related files, please first reach out to [email protected].
Jochen Eisingerea8f92d82017-08-02 17:40:14187
Jochen Eisinger8f0c8d82019-10-25 18:28:27188You have to use `set noparent` together with a reference to a file that lists
189the owners for the given use case. Approved use cases are listed in
190`//build/OWNERS.setnoparent`. Owners listed in those files are expected to
John Abd-El-Malek704bca02022-12-14 18:47:59191execute special governance functions such as ATL reviews or ipc security review.
Jochen Eisinger8f0c8d82019-10-25 18:28:27192Every set of owners should implement their own means of auditing membership. The
193minimum expectation is that membership in those files is reevaluated on
194project, or affiliation changes.
195
John Abd-El-Malek704bca02022-12-14 18:47:59196In this example, only the ATLs are owners:
brettw2019b9e2017-02-09 06:40:20197```
198set noparent
John Abd-El-Malek704bca02022-12-14 18:47:59199file://ATL_OWNERS
brettw2019b9e2017-02-09 06:40:20200```
201
202The `per-file` directive allows owners to be added that apply only to files
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:11203matching a pattern. In this example, owners from the parent directory
brettw2019b9e2017-02-09 06:40:20204apply, plus one person for some classes of files, and all committers are
205owners for the readme:
206```
207per-file [email protected]
208per-file foo.*[email protected]
209
210per-file readme.txt=*
211```
212
213Other `OWNERS` files can be included by reference by listing the path to the
214file with `file://...`. This example indicates that only the people listed in
215`//ipc/SECURITY_OWNERS` can review the messages files:
216```
217per-file *_messages*.h=set noparent
218per-file *_messages*.h=file://ipc/SECURITY_OWNERS
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55219```
Anthony Polito9ce2a482022-02-10 18:39:49220
221File globbing is supported using the
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55222[simple path expression](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/path-expressions.md#simple-path-expressions)
223format.
Steve Kobesf885edf2018-09-11 13:41:11224
Vincent Scheibe360db92025-01-23 17:12:07225Owners annotated with `#{LAST_RESORT_SUGGESTION}` in their comment will be
226omitted when suggesting code owners, except if dropping these code owners would
227make the suggestion result empty or if these code owners are already reviewers
228of the change.
229
Jason Clinton0daf7b02021-02-09 20:36:22230### Owners-Override
Steve Kobesf885edf2018-09-11 13:41:11231
John Abd-El-Malekdfd1edc2021-02-24 22:22:40232Setting the `Owners-Override +1` label will bypass OWNERS enforcement. Active
dpapadeb6dadcf2024-09-23 19:22:51233[gardeners](gardener.md), Release Program Managers,
Dirk Pranke3042ec92022-01-12 16:53:40234[Large Scale Changes](#large-scale-changes),
235[Global Approvers](#global-approvals) reviewers,
John Abd-El-Malek704bca02022-12-14 18:47:59236[Chrome ATLs](../ATL_OWNERS)
Dirk Pranke3042ec92022-01-12 16:53:40237have this capability. The power to use Owners-Override should be restricted
Kentaro Hara7e85d34a2021-10-08 15:33:16238as follows:
239
dpapadeb6dadcf2024-09-23 19:22:51240 * Active gardeners and Release Program Managers can set Owners-Override only
241 on CLs needed for gardening and releasing (e.g., revert, reland, test fix,
Kentaro Hara23878c62022-01-28 00:18:41242 cherry-pick).
dpapadeb6dadcf2024-09-23 19:22:51243 * Large Scale Change reviewers can set Owners-Override only on gardening CLs
Kentaro Hara0cdc6072021-10-15 00:35:16244 and CLs about the approved Large Scale Change.
dpapadeb6dadcf2024-09-23 19:22:51245 * Global approvers can set Owners-Override only on gardening CLs and
Kentaro Hara0cdc6072021-10-15 00:35:16246 mechanical CLs associated with their API changes. For example,
247 //base/OWNERS can set Owners-Override on mechanical CLs associated with
248 //base/ API changes.
John Abd-El-Malek704bca02022-12-14 18:47:59249 * Chrome ATLs can set Owners-Override on any changes to help with cases that
250 cannot be handled by the above groups and expedite CLs when LSC is too
251 heavyweight. However, please use one of the above groups before asking
252 Chrome ATLs.
Kentaro Hara0cdc6072021-10-15 00:35:16253
dpapadeb6dadcf2024-09-23 19:22:51254When you need Owners-Override on gardening CLs, please reach out to the
Kentaro Hara0cdc6072021-10-15 00:35:16255Active Sheriffs and Release Program Managers first. If none of them is
256available, please send an email to [email protected] for help.
257
Dirk Pranke3042ec92022-01-12 16:53:40258Note that Owners-Override by itself is not enough on your own CLs. Where this
dpapadeb6dadcf2024-09-23 19:22:51259matters is when you are gardening. For example, if you want to revert or
Stephen McGruer282391a2022-08-04 16:46:55260disable a test, your Owners-Override on the CL is not enough. You also need
261either another committer to LGTM the CL or, for clean reverts, a `Bot-Commit:
262+1` from the [rubber-stamper bot](#automated-code_review).
Steve Kobesf885edf2018-09-11 13:41:11263
Rick Byers8bdaba42025-01-08 14:12:30264When setting Owners-Override it is your responsibility to confirm that every
265file (and line) in the patch has been appropriately reviewed.
266
Jason Clinton0daf7b02021-02-09 20:36:22267## Mechanical changes
Steve Kobesf885edf2018-09-11 13:41:11268
John Abd-El-Malekdfd1edc2021-02-24 22:22:40269### Global Approvals
Dave Tapuska4661b902023-07-12 17:21:45270For one-off CLs, API owners of `base`, `build`, `content`,
271`third_party/blink/public` and `url` can `Owners-Override +1` a change to their
272APIs to avoid waiting for rubberstamp +1s from affected directories' owners.
Rick Byerse848f2ef2025-01-21 17:56:00273This should only be used for mechanical updates, but global approvers are free
274to use their judgement in determining which mechanical changes they understand
275well enough to approve (rather than limit strictly to calls into code
276they own).
Steve Kobesf885edf2018-09-11 13:41:11277
Rick Byerse848f2ef2025-01-21 17:56:00278For a change that impacts many directories but doesn't need area-specific
279expertise to review, please ask any global approver or Chrome ATL to
280approve the change rather than incur unnecessary review cost on a larger number
281of reviewers.
Kentaro Hara7e85d34a2021-10-08 15:33:16282
283### Large Scale Changes
284You can use the [Large Scale Changes](process/lsc/large_scale_changes.md)
285process to get approval to bypass OWNERS enforcement for large changes like
286refactoring, architectural changes, or other repetitive code changes across the
287whole codebase. This is used for work that span many dozen CLs.
288
Jason Clinton0daf7b02021-02-09 20:36:22289## Documentation updates
Steve Kobesf885edf2018-09-11 13:41:11290
Jason Clinton0daf7b02021-02-09 20:36:22291Documentation updates require code review. We may revisit this decision in the
292future.
Steve Kobesf885edf2018-09-11 13:41:11293
Jason Clinton0daf7b02021-02-09 20:36:22294## Automated code-review
Steve Kobesf885edf2018-09-11 13:41:11295
Jason Clinton0daf7b02021-02-09 20:36:22296For verifiably safe changes like translation files, clean reverts, and clean
297cherry-picks, we have automation that will vote +1 on the `Bot-Commit` label
298allowing the CL to be submitted without human code-review. Add `Rubber Stamper`
299([email protected]) to your CL as a reviewer to
300activate this automation. It will scan the CL after about 1 minute and reply
301with its verdict. `Bot-Commit` votes are not sticky between patchsets and so
302only add the bot once the CL is finalized.
Steve Kobesf885edf2018-09-11 13:41:11303
dpapadeb6dadcf2024-09-23 19:22:51304When combined with the [`Owners-Override`](#owners_override) power, gardeners
305can effectively revert and reland on their own.
Steve Kobesf885edf2018-09-11 13:41:11306
Jason Clinton6026fd192021-03-24 19:58:33307Rubber Stamper never provides OWNERS approval, by design. It's intended to be
dpapadeb6dadcf2024-09-23 19:22:51308used by those who have owners in the directory modified or who are gardeners. If
Jason D. Clintonc38b61d82021-04-20 20:02:14309it provided both code review and OWNERS approval, that would be an abuse vector:
310that would allow anyone who can create a revert or cherry-pick to land it
311without any other person being involved (e.g. the silent revert of security
312patches).
Jason Clinton6026fd192021-03-24 19:58:33313
Jason D. Clintonc38b61d82021-04-20 20:02:14314Changes not supported by `Rubber Stamper` always need a +1 from another
Jason Clinton0daf7b02021-02-09 20:36:22315committer.