blob: 6efe906166b90c994d45006416ac3c822e1ae486 [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.
4All changes must be reviewed.
5
6The bigger patch-upload-and-land process is covered in more detail the
7[contributing code](https://www.chromium.org/developers/contributing-code)
8page.
9
10# Code review policies
11
12Ideally the reviewer is someone who is familiar with the area of code you are
brettw2019b9e2017-02-09 06:40:2013touching. Any committer can review code, but an owner must provide a review
14for each directory you are touching. If you have doubts, look at the git blame
15for the file and the `OWNERS` files (see below).
brettw40e953e2017-02-08 17:49:2816
brettw2019b9e2017-02-09 06:40:2017To indicate a positive review, the reviewer types "LGTM" (case insensitive)
18into a comment on the code review. This stands for "Looks Good To Me." The text
19"not LGTM" will cancel out a previous positive review.
brettw40e953e2017-02-08 17:49:2820
brettw2019b9e2017-02-09 06:40:2021If you have multiple reviewers, make it clear in the message you send
22requesting review what you expect from each reviewer. Otherwise people might
23assume their input is not required or waste time with redundant reviews.
24
25#### Expectations for all reviewers
brettw40e953e2017-02-08 17:49:2826
27 * Aim to provide some kind of actionable response within 24 hours of receipt
28 (not counting weekends and holidays). This doesn't mean you have to have
29 done a complete review, but you should be able to give some initial
30 feedback, request more time, or suggest another reviewer.
31
32 * It can be nice to indicate if you're away in your name in the code review
33 tool. If you do this, indicate when you'll be back.
34
35 * Don't generally discourage people from sending you code reviews. This
36 includes writing a blanket ("slow") after your name in the review tool.
37
38## OWNERS files
39
brettw2019b9e2017-02-09 06:40:2040In various directories there are files named `OWNERS` that list the email
brettw40e953e2017-02-08 17:49:2841addresses of people qualified to review changes in that directory. You must
42get a positive review from an owner of each directory your change touches.
43
brettw2019b9e2017-02-09 06:40:2044Owners files are recursive, so each file also applies to its subdirectories.
45It's generally best to pick more specific owners. People listed in higher-level
46directories may have less experience with the code in question. More detail on
47the owners file format is provided in the "More information" section below.
brettw40e953e2017-02-08 17:49:2848
brettw2019b9e2017-02-09 06:40:2049*Tip:* The `git cl owners` command can help find owners.
brettw40e953e2017-02-08 17:49:2850
51While owners must approve all patches, any committer can contribute to the
52review. In some directories the owners can be overloaded or there might be
53people not listed as owners who are more familiar with the low-level code in
54question. In these cases it's common to request a low-level review from an
55appropriate person, and then request a high-level owner review once that's
56complete. As always, be clear what you expect of each reviewer to avoid
57duplicated work.
58
brettw2019b9e2017-02-09 06:40:2059Owners do not have to pick other owners for reviews. Since they should already
60be familiar with the code in question, a thorough review from any appropriate
61committer is sufficient.
brettw40e953e2017-02-08 17:49:2862
brettw2019b9e2017-02-09 06:40:2063#### Expectations of owners
64
65The existing owners of a directory approve additions to the list. It is
66preferrable to have many directories, each with a smaller number of specific
67owners rather than large directories with many owners. Owners must:
68
69 * Demonstrate excellent judgment, teamwork and ability to uphold Chrome
70 development principles.
71
72 * Be already acting as an owner, providing high-quality reviews and design
73 feedback
74
75 * Be a Chromium project member with full commit access of at least 6
76 months tenure.
77
78 * Have submitted a substantial number of non-trivial changes to the affected
brettw40e953e2017-02-08 17:49:2879 directory.
80
brettw2019b9e2017-02-09 06:40:2081 * Have committed or reviewed substantial work to the affected directory
82 within the last 90 days.
brettw40e953e2017-02-08 17:49:2883
brettw2019b9e2017-02-09 06:40:2084 * Have the bandwidth to contribute to reviews in a timely manner. If the load
85 is unsustainable, work to expand the number of owners. Don't try to
86 discourage people from sending reviews, including writing "slow" or
87 "emeritus" after your name.
88
89Seldom-updated directories may have exceptions. Directories in `third_party`
90should list those most familiar with the library.
brettw40e953e2017-02-08 17:49:2891
92## TBR ("To Be Reviewed")
93
94"TBR" is our mechanism for post-commit review. It should be used rarely and
95only in cases where a review is unnecessary or as described below. The most
96common use of TBR is to revert patches that broke the build.
97
brettw2019b9e2017-02-09 06:40:2098TBR does not mean "no review." A reviewer TBR-ed on a change should still
99review the change. If there comments after landing the author is obligated to
100address them in a followup patch.
brettw40e953e2017-02-08 17:49:28101
102Do not use TBR just because a change is urgent or the reviewer is being slow.
brettw2019b9e2017-02-09 06:40:20103Contact the reviewer directly or find somebody.
brettw40e953e2017-02-08 17:49:28104
105To send a change TBR, annotate the description and send email like normal.
106Otherwise the reviewer won't know to review the patch.
107
108 * Add the reviewer's email address in the code review tool's reviewer field
109 like normal.
110
111 * Add a line "TBR=<reviewer's email>" to the bottom of the change list
112 description.
113
114 * Push the "send mail" button.
115
116### TBR-ing certain types of mechanical changes
117
118Sometimes you might do something that affects many callers in different
119directories. For example, adding a parameter to a common function in //base.
120If the updates to the callers is mechanical, you can:
121
brettw2019b9e2017-02-09 06:40:20122 * Get a normal owner of the lower-level directory you're changing (in this
123 example, `//base`) to do a proper review of those changes.
brettw40e953e2017-02-08 17:49:28124
125 * Get _somebody_ to review the downstream changes. This is often the same
126 person from the previous step but could be somebody else.
127
128 * Add the owners of the affected downstream directories as TBR.
129
130This process ensures that all code is reviewed prior to checkin and that the
131concept of the change is reviewed by a qualified person, but you don't have to
132track down many individual owners for trivial changes to their directories.
133
134### TBR-ing documentation updates
135
136You can TBR documentation updates. Documentation means markdown files, text
137documents, and high-level comments in code. At finer levels of detail, comments
138in source files become more like code and should be reviewed normally (not
139using TBR). Non-TBR-able stuff includes things like function contracts and most
140comments inside functions.
141
brettw2019b9e2017-02-09 06:40:20142 * Use good judgement. If you're changing something very important, tricky,
143 or something you may not be very familiar with, ask for the code review
144 up-front.
brettw40e953e2017-02-08 17:49:28145
146 * Don't TBR changes to policy documents like the style guide or this document.
147
148 * Don't mix unrelated documentation updates with code changes.
149
150 * Be sure to actually send out the email for the code review. If you get one,
brettw2019b9e2017-02-09 06:40:20151 please actually read the changes.
152
153## More information
154
155### OWNERS file details
156
157Refer to the [source code](https://chromium.googlesource.com/chromium/tools/depot_tools/+/master/owners.py)
158for all details on the file format.
159
160This example indicates that two people are owners, in addition to any owners
161from the parent directory. `git cl owners` will list the comment after an
162owner address, so this is a good place to include restrictions or special
163instructions.
164```
165# You can include comments like this.
166[email protected]
167[email protected] # Only for the frobinator.
168```
169
170A `*` indicates that all committers are owners:
171```
172*
173```
174
brettwd040b0be2017-02-09 19:11:33175The text `set noparent` will stop owner propagation from parent directories.
brettw2019b9e2017-02-09 06:40:20176This is used for specialized code. In this example, only the two listed people
177are owners:
178```
179set noparent
180[email protected]
181[email protected]
182```
183
184The `per-file` directive allows owners to be added that apply only to files
185matching a pattern. In this example, owners from the parent directiory
186apply, 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
201```