blob: d169d99cd0ae9de1c9007206eefb0b7a21cc3de1 [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
54## OWNERS files
55
brettw2019b9e2017-02-09 06:40:2056In various directories there are files named `OWNERS` that list the email
brettw40e953e2017-02-08 17:49:2857addresses of people qualified to review changes in that directory. You must
58get a positive review from an owner of each directory your change touches.
59
brettw2019b9e2017-02-09 06:40:2060Owners files are recursive, so each file also applies to its subdirectories.
61It's generally best to pick more specific owners. People listed in higher-level
thestig9208d8ba2017-06-09 22:05:3262directories may have less experience with the code in question. For example,
63the reviewers in the `//chrome/browser/component_name/OWNERS` file will likely
64be more familiar with code in `//chrome/browser/component_name/sub_component`
65than reviewers in the higher-level `//chrome/OWNERS` file.
66
Lei Zhang3b32caa2021-03-22 17:24:1967More detail on the owners file format is provided [here](#owners-file-details).
brettw40e953e2017-02-08 17:49:2868
Lei Zhang3b32caa2021-03-22 17:24:1969*Tip:* The `git cl owners` command can help find owners. Gerrit also provides
Jason D. Clintonc38b61d82021-04-20 20:02:1470this functionality in the Reviewers field of CLs.
brettw40e953e2017-02-08 17:49:2871
72While owners must approve all patches, any committer can contribute to the
73review. In some directories the owners can be overloaded or there might be
74people not listed as owners who are more familiar with the low-level code in
75question. In these cases it's common to request a low-level review from an
76appropriate person, and then request a high-level owner review once that's
77complete. As always, be clear what you expect of each reviewer to avoid
78duplicated work.
79
brettw2019b9e2017-02-09 06:40:2080Owners do not have to pick other owners for reviews. Since they should already
81be familiar with the code in question, a thorough review from any appropriate
82committer is sufficient.
brettw40e953e2017-02-08 17:49:2883
brettw2019b9e2017-02-09 06:40:2084#### Expectations of owners
85
86The existing owners of a directory approve additions to the list. It is
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:1187preferable to have many directories, each with a smaller number of specific
Dirk Pranke02c8906f2025-01-28 18:20:5788owners rather than large directories with many owners. Owners must be
89[committers](https://www.chromium.org/getting-involved/become-a-committer/)
90with at least 3 months' tenure, and in addition should:
brettw2019b9e2017-02-09 06:40:2091
Dirk Pranke3042ec92022-01-12 16:53:4092 * Demonstrate excellent judgment, teamwork and ability to uphold
93 [Chromium development principles](contributing.md).
brettw2019b9e2017-02-09 06:40:2094
95 * Be already acting as an owner, providing high-quality reviews and design
Dirk Pranke4f9740c2018-10-17 03:01:0696 feedback.
brettw2019b9e2017-02-09 06:40:2097
brettw2019b9e2017-02-09 06:40:2098 * Have submitted a substantial number of non-trivial changes to the affected
brettw40e953e2017-02-08 17:49:2899 directory.
100
brettw2019b9e2017-02-09 06:40:20101 * Have committed or reviewed substantial work to the affected directory
Dirk Pranke4f9740c2018-10-17 03:01:06102 within the last ninety days.
brettw40e953e2017-02-08 17:49:28103
brettw2019b9e2017-02-09 06:40:20104 * Have the bandwidth to contribute to reviews in a timely manner. If the load
105 is unsustainable, work to expand the number of owners. Don't try to
106 discourage people from sending reviews, including writing "slow" or
107 "emeritus" after your name.
108
Dirk Pranke3042ec92022-01-12 16:53:40109Seldom-updated directories may have exceptions to the "substantiality" and
110"recency" requirements.
111
112Directories in `//third_party` should list those most familiar with the
113library, regardless of how often the code is updated.
114
115#### Removal of owners
116
117If a code owner is not meeting the [expectations of
118owners](#expectations-of-owners) listed above for more than one quarter (and
119they are not on a leave during that time), then they may be removed by any
120co-owner or an owner from the parent directory after a 4-week notice, using
121the following process:
122
123 * Upload a change removing the owner and copy all owners in that directory,
124 including the owner in question.
125 * If the affected owner approves the change, it may be landed immediately.
126 * Otherwise, the change author must wait five working days for feedback from
127 the other owners.
128 * After that time has elapsed, if the change has received 3 approvals
129 with no objections from anyone else, the change may be landed.
130 * If the directory does not have 4 owners, then the decision should
131 be escalated to the owners of the parent directory (or directories)
Andrew Mitchell04049fe2024-04-26 00:53:30132 as necessary to provide enough votes.
Dirk Pranke3042ec92022-01-12 16:53:40133 * If there are objections, then the decision should be escalated to
John Abd-El-Malek704bca02022-12-14 18:47:59134 the [../ATL_OWNERS](../ATL_OWNERS) for resolution.
brettw40e953e2017-02-08 17:49:28135
Kentaro Hara52294ae2022-08-12 07:37:30136Note: For the purpose of not slowing down code review, Chromium removes
137inactive owners (e.g., those who made no contributions for multiple quarters)
138on a regular basis. The script does not take into account personal situations
139like a long leave. If you were inactive only for a certain period of time
140while you were on a long leave and have been meeting the above owner's
141expectations in other times, you can create a CL to re-add yourself and land
142after getting local owner's approval (you can refer to this policy in the CL).
Yulan Lin331686622023-03-30 23:10:51143The removal script will cc the removed owner and one other owner to avoid spam.
Kentaro Hara52294ae2022-08-12 07:37:30144
brettw2019b9e2017-02-09 06:40:20145### OWNERS file details
146
Anthony Polito9ce2a482022-02-10 18:39:49147Refer to the [owners plugin](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/backend-find-owners.md)
thestig9208d8ba2017-06-09 22:05:32148for all details on the file format.
brettw2019b9e2017-02-09 06:40:20149
150This example indicates that two people are owners, in addition to any owners
151from the parent directory. `git cl owners` will list the comment after an
152owner address, so this is a good place to include restrictions or special
153instructions.
154```
155# You can include comments like this.
156[email protected]
157[email protected] # Only for the frobinator.
158```
159
160A `*` indicates that all committers are owners:
161```
162*
163```
164
brettwd040b0be2017-02-09 19:11:33165The text `set noparent` will stop owner propagation from parent directories.
Jochen Eisingerea8f92d82017-08-02 17:40:14166This should be rarely used. If you want to use `set noparent` except for IPC
John Abd-El-Malek704bca02022-12-14 18:47:59167related files, please first reach out to [email protected].
Jochen Eisingerea8f92d82017-08-02 17:40:14168
Jochen Eisinger8f0c8d82019-10-25 18:28:27169You have to use `set noparent` together with a reference to a file that lists
170the owners for the given use case. Approved use cases are listed in
171`//build/OWNERS.setnoparent`. Owners listed in those files are expected to
John Abd-El-Malek704bca02022-12-14 18:47:59172execute special governance functions such as ATL reviews or ipc security review.
Jochen Eisinger8f0c8d82019-10-25 18:28:27173Every set of owners should implement their own means of auditing membership. The
174minimum expectation is that membership in those files is reevaluated on
175project, or affiliation changes.
176
John Abd-El-Malek704bca02022-12-14 18:47:59177In this example, only the ATLs are owners:
brettw2019b9e2017-02-09 06:40:20178```
179set noparent
John Abd-El-Malek704bca02022-12-14 18:47:59180file://ATL_OWNERS
brettw2019b9e2017-02-09 06:40:20181```
182
183The `per-file` directive allows owners to be added that apply only to files
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:11184matching a pattern. In this example, owners from the parent directory
brettw2019b9e2017-02-09 06:40:20185apply, plus one person for some classes of files, and all committers are
186owners for the readme:
187```
188per-file [email protected]
189per-file foo.*[email protected]
190
191per-file readme.txt=*
192```
193
194Other `OWNERS` files can be included by reference by listing the path to the
195file with `file://...`. This example indicates that only the people listed in
196`//ipc/SECURITY_OWNERS` can review the messages files:
197```
198per-file *_messages*.h=set noparent
199per-file *_messages*.h=file://ipc/SECURITY_OWNERS
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55200```
Anthony Polito9ce2a482022-02-10 18:39:49201
202File globbing is supported using the
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55203[simple path expression](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/path-expressions.md#simple-path-expressions)
204format.
Steve Kobesf885edf2018-09-11 13:41:11205
Vincent Scheibe360db92025-01-23 17:12:07206Owners annotated with `#{LAST_RESORT_SUGGESTION}` in their comment will be
207omitted when suggesting code owners, except if dropping these code owners would
208make the suggestion result empty or if these code owners are already reviewers
209of the change.
210
Jason Clinton0daf7b02021-02-09 20:36:22211### Owners-Override
Steve Kobesf885edf2018-09-11 13:41:11212
John Abd-El-Malekdfd1edc2021-02-24 22:22:40213Setting the `Owners-Override +1` label will bypass OWNERS enforcement. Active
dpapadeb6dadcf2024-09-23 19:22:51214[gardeners](gardener.md), Release Program Managers,
Dirk Pranke3042ec92022-01-12 16:53:40215[Large Scale Changes](#large-scale-changes),
216[Global Approvers](#global-approvals) reviewers,
John Abd-El-Malek704bca02022-12-14 18:47:59217[Chrome ATLs](../ATL_OWNERS)
Dirk Pranke3042ec92022-01-12 16:53:40218have this capability. The power to use Owners-Override should be restricted
Kentaro Hara7e85d34a2021-10-08 15:33:16219as follows:
220
dpapadeb6dadcf2024-09-23 19:22:51221 * Active gardeners and Release Program Managers can set Owners-Override only
222 on CLs needed for gardening and releasing (e.g., revert, reland, test fix,
Kentaro Hara23878c62022-01-28 00:18:41223 cherry-pick).
dpapadeb6dadcf2024-09-23 19:22:51224 * Large Scale Change reviewers can set Owners-Override only on gardening CLs
Kentaro Hara0cdc6072021-10-15 00:35:16225 and CLs about the approved Large Scale Change.
dpapadeb6dadcf2024-09-23 19:22:51226 * Global approvers can set Owners-Override only on gardening CLs and
Kentaro Hara0cdc6072021-10-15 00:35:16227 mechanical CLs associated with their API changes. For example,
228 //base/OWNERS can set Owners-Override on mechanical CLs associated with
229 //base/ API changes.
John Abd-El-Malek704bca02022-12-14 18:47:59230 * Chrome ATLs can set Owners-Override on any changes to help with cases that
231 cannot be handled by the above groups and expedite CLs when LSC is too
232 heavyweight. However, please use one of the above groups before asking
233 Chrome ATLs.
Kentaro Hara0cdc6072021-10-15 00:35:16234
dpapadeb6dadcf2024-09-23 19:22:51235When you need Owners-Override on gardening CLs, please reach out to the
Kentaro Hara0cdc6072021-10-15 00:35:16236Active Sheriffs and Release Program Managers first. If none of them is
237available, please send an email to [email protected] for help.
238
Dirk Pranke3042ec92022-01-12 16:53:40239Note that Owners-Override by itself is not enough on your own CLs. Where this
dpapadeb6dadcf2024-09-23 19:22:51240matters is when you are gardening. For example, if you want to revert or
Stephen McGruer282391a2022-08-04 16:46:55241disable a test, your Owners-Override on the CL is not enough. You also need
242either another committer to LGTM the CL or, for clean reverts, a `Bot-Commit:
243+1` from the [rubber-stamper bot](#automated-code_review).
Steve Kobesf885edf2018-09-11 13:41:11244
Rick Byers8bdaba42025-01-08 14:12:30245When setting Owners-Override it is your responsibility to confirm that every
246file (and line) in the patch has been appropriately reviewed.
247
Jason Clinton0daf7b02021-02-09 20:36:22248## Mechanical changes
Steve Kobesf885edf2018-09-11 13:41:11249
John Abd-El-Malekdfd1edc2021-02-24 22:22:40250### Global Approvals
Dave Tapuska4661b902023-07-12 17:21:45251For one-off CLs, API owners of `base`, `build`, `content`,
252`third_party/blink/public` and `url` can `Owners-Override +1` a change to their
253APIs to avoid waiting for rubberstamp +1s from affected directories' owners.
Rick Byerse848f2ef2025-01-21 17:56:00254This should only be used for mechanical updates, but global approvers are free
255to use their judgement in determining which mechanical changes they understand
256well enough to approve (rather than limit strictly to calls into code
257they own).
Steve Kobesf885edf2018-09-11 13:41:11258
Rick Byerse848f2ef2025-01-21 17:56:00259For a change that impacts many directories but doesn't need area-specific
260expertise to review, please ask any global approver or Chrome ATL to
261approve the change rather than incur unnecessary review cost on a larger number
262of reviewers.
Kentaro Hara7e85d34a2021-10-08 15:33:16263
264### Large Scale Changes
265You can use the [Large Scale Changes](process/lsc/large_scale_changes.md)
266process to get approval to bypass OWNERS enforcement for large changes like
267refactoring, architectural changes, or other repetitive code changes across the
268whole codebase. This is used for work that span many dozen CLs.
269
Jason Clinton0daf7b02021-02-09 20:36:22270## Documentation updates
Steve Kobesf885edf2018-09-11 13:41:11271
Jason Clinton0daf7b02021-02-09 20:36:22272Documentation updates require code review. We may revisit this decision in the
273future.
Steve Kobesf885edf2018-09-11 13:41:11274
Jason Clinton0daf7b02021-02-09 20:36:22275## Automated code-review
Steve Kobesf885edf2018-09-11 13:41:11276
Jason Clinton0daf7b02021-02-09 20:36:22277For verifiably safe changes like translation files, clean reverts, and clean
278cherry-picks, we have automation that will vote +1 on the `Bot-Commit` label
279allowing the CL to be submitted without human code-review. Add `Rubber Stamper`
280([email protected]) to your CL as a reviewer to
281activate this automation. It will scan the CL after about 1 minute and reply
282with its verdict. `Bot-Commit` votes are not sticky between patchsets and so
283only add the bot once the CL is finalized.
Steve Kobesf885edf2018-09-11 13:41:11284
dpapadeb6dadcf2024-09-23 19:22:51285When combined with the [`Owners-Override`](#owners_override) power, gardeners
286can effectively revert and reland on their own.
Steve Kobesf885edf2018-09-11 13:41:11287
Jason Clinton6026fd192021-03-24 19:58:33288Rubber Stamper never provides OWNERS approval, by design. It's intended to be
dpapadeb6dadcf2024-09-23 19:22:51289used by those who have owners in the directory modified or who are gardeners. If
Jason D. Clintonc38b61d82021-04-20 20:02:14290it provided both code review and OWNERS approval, that would be an abuse vector:
291that would allow anyone who can create a revert or cherry-pick to land it
292without any other person being involved (e.g. the silent revert of security
293patches).
Jason Clinton6026fd192021-03-24 19:58:33294
Jason D. Clintonc38b61d82021-04-20 20:02:14295Changes not supported by `Rubber Stamper` always need a +1 from another
Jason Clinton0daf7b02021-02-09 20:36:22296committer.