blob: f5b6679df24a39b1d8948d512cca1f038b29b09c [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 Pranke4f9740c2018-10-17 03:01:0688owners rather than large directories with many owners. Owners should:
brettw2019b9e2017-02-09 06:40:2089
Dirk Pranke3042ec92022-01-12 16:53:4090 * Demonstrate excellent judgment, teamwork and ability to uphold
91 [Chromium development principles](contributing.md).
brettw2019b9e2017-02-09 06:40:2092
93 * Be already acting as an owner, providing high-quality reviews and design
Dirk Pranke4f9740c2018-10-17 03:01:0694 feedback.
brettw2019b9e2017-02-09 06:40:2095
Dirk Pranke4f9740c2018-10-17 03:01:0696 * Be a Chromium project member with full commit access of at least three
brettw2019b9e2017-02-09 06:40:2097 months tenure.
98
99 * Have submitted a substantial number of non-trivial changes to the affected
brettw40e953e2017-02-08 17:49:28100 directory.
101
brettw2019b9e2017-02-09 06:40:20102 * Have committed or reviewed substantial work to the affected directory
Dirk Pranke4f9740c2018-10-17 03:01:06103 within the last ninety days.
brettw40e953e2017-02-08 17:49:28104
brettw2019b9e2017-02-09 06:40:20105 * Have the bandwidth to contribute to reviews in a timely manner. If the load
106 is unsustainable, work to expand the number of owners. Don't try to
107 discourage people from sending reviews, including writing "slow" or
108 "emeritus" after your name.
109
Dirk Pranke3042ec92022-01-12 16:53:40110Seldom-updated directories may have exceptions to the "substantiality" and
111"recency" requirements.
112
113Directories in `//third_party` should list those most familiar with the
114library, regardless of how often the code is updated.
115
116#### Removal of owners
117
118If a code owner is not meeting the [expectations of
119owners](#expectations-of-owners) listed above for more than one quarter (and
120they are not on a leave during that time), then they may be removed by any
121co-owner or an owner from the parent directory after a 4-week notice, using
122the following process:
123
124 * Upload a change removing the owner and copy all owners in that directory,
125 including the owner in question.
126 * If the affected owner approves the change, it may be landed immediately.
127 * Otherwise, the change author must wait five working days for feedback from
128 the other owners.
129 * After that time has elapsed, if the change has received 3 approvals
130 with no objections from anyone else, the change may be landed.
131 * If the directory does not have 4 owners, then the decision should
132 be escalated to the owners of the parent directory (or directories)
Andrew Mitchell04049fe2024-04-26 00:53:30133 as necessary to provide enough votes.
Dirk Pranke3042ec92022-01-12 16:53:40134 * If there are objections, then the decision should be escalated to
John Abd-El-Malek704bca02022-12-14 18:47:59135 the [../ATL_OWNERS](../ATL_OWNERS) for resolution.
brettw40e953e2017-02-08 17:49:28136
Kentaro Hara52294ae2022-08-12 07:37:30137Note: For the purpose of not slowing down code review, Chromium removes
138inactive owners (e.g., those who made no contributions for multiple quarters)
139on a regular basis. The script does not take into account personal situations
140like a long leave. If you were inactive only for a certain period of time
141while you were on a long leave and have been meeting the above owner's
142expectations in other times, you can create a CL to re-add yourself and land
143after getting local owner's approval (you can refer to this policy in the CL).
Yulan Lin331686622023-03-30 23:10:51144The removal script will cc the removed owner and one other owner to avoid spam.
Kentaro Hara52294ae2022-08-12 07:37:30145
brettw2019b9e2017-02-09 06:40:20146### OWNERS file details
147
Anthony Polito9ce2a482022-02-10 18:39:49148Refer to the [owners plugin](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/backend-find-owners.md)
thestig9208d8ba2017-06-09 22:05:32149for all details on the file format.
brettw2019b9e2017-02-09 06:40:20150
151This example indicates that two people are owners, in addition to any owners
152from the parent directory. `git cl owners` will list the comment after an
153owner address, so this is a good place to include restrictions or special
154instructions.
155```
156# You can include comments like this.
157[email protected]
158[email protected] # Only for the frobinator.
159```
160
161A `*` indicates that all committers are owners:
162```
163*
164```
165
brettwd040b0be2017-02-09 19:11:33166The text `set noparent` will stop owner propagation from parent directories.
Jochen Eisingerea8f92d82017-08-02 17:40:14167This should be rarely used. If you want to use `set noparent` except for IPC
John Abd-El-Malek704bca02022-12-14 18:47:59168related files, please first reach out to chrome-atls@google.com.
Jochen Eisingerea8f92d82017-08-02 17:40:14169
Jochen Eisinger8f0c8d82019-10-25 18:28:27170You have to use `set noparent` together with a reference to a file that lists
171the owners for the given use case. Approved use cases are listed in
172`//build/OWNERS.setnoparent`. Owners listed in those files are expected to
John Abd-El-Malek704bca02022-12-14 18:47:59173execute special governance functions such as ATL reviews or ipc security review.
Jochen Eisinger8f0c8d82019-10-25 18:28:27174Every set of owners should implement their own means of auditing membership. The
175minimum expectation is that membership in those files is reevaluated on
176project, or affiliation changes.
177
John Abd-El-Malek704bca02022-12-14 18:47:59178In this example, only the ATLs are owners:
brettw2019b9e2017-02-09 06:40:20179```
180set noparent
John Abd-El-Malek704bca02022-12-14 18:47:59181file://ATL_OWNERS
brettw2019b9e2017-02-09 06:40:20182```
183
184The `per-file` directive allows owners to be added that apply only to files
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:11185matching a pattern. In this example, owners from the parent directory
brettw2019b9e2017-02-09 06:40:20186apply, plus one person for some classes of files, and all committers are
187owners for the readme:
188```
189per-file [email protected]
190per-file foo.*[email protected]
191
192per-file readme.txt=*
193```
194
195Other `OWNERS` files can be included by reference by listing the path to the
196file with `file://...`. This example indicates that only the people listed in
197`//ipc/SECURITY_OWNERS` can review the messages files:
198```
199per-file *_messages*.h=set noparent
200per-file *_messages*.h=file://ipc/SECURITY_OWNERS
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55201```
Anthony Polito9ce2a482022-02-10 18:39:49202
203File globbing is supported using the
Wei-Yin Chen (陳威尹)1fb88e22023-01-09 18:39:55204[simple path expression](https://github.com/GerritCodeReview/plugins_code-owners/blob/master/resources/Documentation/path-expressions.md#simple-path-expressions)
205format.
Steve Kobesf885edf2018-09-11 13:41:11206
Jason Clinton0daf7b02021-02-09 20:36:22207### Owners-Override
Steve Kobesf885edf2018-09-11 13:41:11208
John Abd-El-Malekdfd1edc2021-02-24 22:22:40209Setting the `Owners-Override +1` label will bypass OWNERS enforcement. Active
dpapadeb6dadcf2024-09-23 19:22:51210[gardeners](gardener.md), Release Program Managers,
Dirk Pranke3042ec92022-01-12 16:53:40211[Large Scale Changes](#large-scale-changes),
212[Global Approvers](#global-approvals) reviewers,
John Abd-El-Malek704bca02022-12-14 18:47:59213[Chrome ATLs](../ATL_OWNERS)
Dirk Pranke3042ec92022-01-12 16:53:40214have this capability. The power to use Owners-Override should be restricted
Kentaro Hara7e85d34a2021-10-08 15:33:16215as follows:
216
dpapadeb6dadcf2024-09-23 19:22:51217 * Active gardeners and Release Program Managers can set Owners-Override only
218 on CLs needed for gardening and releasing (e.g., revert, reland, test fix,
Kentaro Hara23878c62022-01-28 00:18:41219 cherry-pick).
dpapadeb6dadcf2024-09-23 19:22:51220 * Large Scale Change reviewers can set Owners-Override only on gardening CLs
Kentaro Hara0cdc6072021-10-15 00:35:16221 and CLs about the approved Large Scale Change.
dpapadeb6dadcf2024-09-23 19:22:51222 * Global approvers can set Owners-Override only on gardening CLs and
Kentaro Hara0cdc6072021-10-15 00:35:16223 mechanical CLs associated with their API changes. For example,
224 //base/OWNERS can set Owners-Override on mechanical CLs associated with
225 //base/ API changes.
John Abd-El-Malek704bca02022-12-14 18:47:59226 * Chrome ATLs can set Owners-Override on any changes to help with cases that
227 cannot be handled by the above groups and expedite CLs when LSC is too
228 heavyweight. However, please use one of the above groups before asking
229 Chrome ATLs.
Kentaro Hara0cdc6072021-10-15 00:35:16230
dpapadeb6dadcf2024-09-23 19:22:51231When you need Owners-Override on gardening CLs, please reach out to the
Kentaro Hara0cdc6072021-10-15 00:35:16232Active Sheriffs and Release Program Managers first. If none of them is
233available, please send an email to lsc-owners-override@chromium.org for help.
234
Dirk Pranke3042ec92022-01-12 16:53:40235Note that Owners-Override by itself is not enough on your own CLs. Where this
dpapadeb6dadcf2024-09-23 19:22:51236matters is when you are gardening. For example, if you want to revert or
Stephen McGruer282391a2022-08-04 16:46:55237disable a test, your Owners-Override on the CL is not enough. You also need
238either another committer to LGTM the CL or, for clean reverts, a `Bot-Commit:
239+1` from the [rubber-stamper bot](#automated-code_review).
Steve Kobesf885edf2018-09-11 13:41:11240
Rick Byers8bdaba42025-01-08 14:12:30241When setting Owners-Override it is your responsibility to confirm that every
242file (and line) in the patch has been appropriately reviewed.
243
Jason Clinton0daf7b02021-02-09 20:36:22244## Mechanical changes
Steve Kobesf885edf2018-09-11 13:41:11245
John Abd-El-Malekdfd1edc2021-02-24 22:22:40246### Global Approvals
Dave Tapuska4661b902023-07-12 17:21:45247For one-off CLs, API owners of `base`, `build`, `content`,
248`third_party/blink/public` and `url` can `Owners-Override +1` a change to their
249APIs to avoid waiting for rubberstamp +1s from affected directories' owners.
250This should only be used for mechanical updates to the affected directories.
Steve Kobesf885edf2018-09-11 13:41:11251
Dirk Pranke3042ec92022-01-12 16:53:40252If you are making one-off CLs that touch many directories and cannot be
John Abd-El-Malek704bca02022-12-14 18:47:59253handled by the global approvers, you can ask one of Chrome ATLs.
Kentaro Hara7e85d34a2021-10-08 15:33:16254
255### Large Scale Changes
256You can use the [Large Scale Changes](process/lsc/large_scale_changes.md)
257process to get approval to bypass OWNERS enforcement for large changes like
258refactoring, architectural changes, or other repetitive code changes across the
259whole codebase. This is used for work that span many dozen CLs.
260
Jason Clinton0daf7b02021-02-09 20:36:22261## Documentation updates
Steve Kobesf885edf2018-09-11 13:41:11262
Jason Clinton0daf7b02021-02-09 20:36:22263Documentation updates require code review. We may revisit this decision in the
264future.
Steve Kobesf885edf2018-09-11 13:41:11265
Jason Clinton0daf7b02021-02-09 20:36:22266## Automated code-review
Steve Kobesf885edf2018-09-11 13:41:11267
Jason Clinton0daf7b02021-02-09 20:36:22268For verifiably safe changes like translation files, clean reverts, and clean
269cherry-picks, we have automation that will vote +1 on the `Bot-Commit` label
270allowing the CL to be submitted without human code-review. Add `Rubber Stamper`
271([email protected]) to your CL as a reviewer to
272activate this automation. It will scan the CL after about 1 minute and reply
273with its verdict. `Bot-Commit` votes are not sticky between patchsets and so
274only add the bot once the CL is finalized.
Steve Kobesf885edf2018-09-11 13:41:11275
dpapadeb6dadcf2024-09-23 19:22:51276When combined with the [`Owners-Override`](#owners_override) power, gardeners
277can effectively revert and reland on their own.
Steve Kobesf885edf2018-09-11 13:41:11278
Jason Clinton6026fd192021-03-24 19:58:33279Rubber Stamper never provides OWNERS approval, by design. It's intended to be
dpapadeb6dadcf2024-09-23 19:22:51280used by those who have owners in the directory modified or who are gardeners. If
Jason D. Clintonc38b61d82021-04-20 20:02:14281it provided both code review and OWNERS approval, that would be an abuse vector:
282that would allow anyone who can create a revert or cherry-pick to land it
283without any other person being involved (e.g. the silent revert of security
284patches).
Jason Clinton6026fd192021-03-24 19:58:33285
Jason D. Clintonc38b61d82021-04-20 20:02:14286Changes not supported by `Rubber Stamper` always need a +1 from another
Jason Clinton0daf7b02021-02-09 20:36:22287committer.