blob: af8e91e24590c2fb3898e3dbc98f8e545ed84a86 [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
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:1117To indicate a positive review, the reviewer chooses "+1" in Code-Review field
18on Gerrit, or types "LGTM" (case insensitive) into a comment on Rietveld. This
19stands for "Looks Good To Me." "-1" in Code-Review field on Gerrit or the text
20"not LGTM" on Rietveld will cancel out a previous positive review.
brettw40e953e2017-02-08 17:49:2821
brettw2019b9e2017-02-09 06:40:2022If you have multiple reviewers, make it clear in the message you send
23requesting review what you expect from each reviewer. Otherwise people might
24assume their input is not required or waste time with redundant reviews.
25
26#### Expectations for all reviewers
brettw40e953e2017-02-08 17:49:2827
28 * Aim to provide some kind of actionable response within 24 hours of receipt
29 (not counting weekends and holidays). This doesn't mean you have to have
30 done a complete review, but you should be able to give some initial
31 feedback, request more time, or suggest another reviewer.
32
33 * It can be nice to indicate if you're away in your name in the code review
34 tool. If you do this, indicate when you'll be back.
35
36 * Don't generally discourage people from sending you code reviews. This
37 includes writing a blanket ("slow") after your name in the review tool.
38
39## OWNERS files
40
brettw2019b9e2017-02-09 06:40:2041In various directories there are files named `OWNERS` that list the email
brettw40e953e2017-02-08 17:49:2842addresses of people qualified to review changes in that directory. You must
43get a positive review from an owner of each directory your change touches.
44
brettw2019b9e2017-02-09 06:40:2045Owners files are recursive, so each file also applies to its subdirectories.
46It's generally best to pick more specific owners. People listed in higher-level
thestig9208d8ba2017-06-09 22:05:3247directories may have less experience with the code in question. For example,
48the reviewers in the `//chrome/browser/component_name/OWNERS` file will likely
49be more familiar with code in `//chrome/browser/component_name/sub_component`
50than reviewers in the higher-level `//chrome/OWNERS` file.
51
52More detail on the owners file format is provided in the "More information"
53section below.
brettw40e953e2017-02-08 17:49:2854
brettw2019b9e2017-02-09 06:40:2055*Tip:* The `git cl owners` command can help find owners.
brettw40e953e2017-02-08 17:49:2856
57While owners must approve all patches, any committer can contribute to the
58review. In some directories the owners can be overloaded or there might be
59people not listed as owners who are more familiar with the low-level code in
60question. In these cases it's common to request a low-level review from an
61appropriate person, and then request a high-level owner review once that's
62complete. As always, be clear what you expect of each reviewer to avoid
63duplicated work.
64
brettw2019b9e2017-02-09 06:40:2065Owners do not have to pick other owners for reviews. Since they should already
66be familiar with the code in question, a thorough review from any appropriate
67committer is sufficient.
brettw40e953e2017-02-08 17:49:2868
brettw2019b9e2017-02-09 06:40:2069#### Expectations of owners
70
71The existing owners of a directory approve additions to the list. It is
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:1172preferable to have many directories, each with a smaller number of specific
brettw2019b9e2017-02-09 06:40:2073owners rather than large directories with many owners. Owners must:
74
75 * Demonstrate excellent judgment, teamwork and ability to uphold Chrome
76 development principles.
77
78 * Be already acting as an owner, providing high-quality reviews and design
79 feedback
80
81 * Be a Chromium project member with full commit access of at least 6
82 months tenure.
83
84 * Have submitted a substantial number of non-trivial changes to the affected
brettw40e953e2017-02-08 17:49:2885 directory.
86
brettw2019b9e2017-02-09 06:40:2087 * Have committed or reviewed substantial work to the affected directory
88 within the last 90 days.
brettw40e953e2017-02-08 17:49:2889
brettw2019b9e2017-02-09 06:40:2090 * Have the bandwidth to contribute to reviews in a timely manner. If the load
91 is unsustainable, work to expand the number of owners. Don't try to
92 discourage people from sending reviews, including writing "slow" or
93 "emeritus" after your name.
94
95Seldom-updated directories may have exceptions. Directories in `third_party`
96should list those most familiar with the library.
brettw40e953e2017-02-08 17:49:2897
98## TBR ("To Be Reviewed")
99
100"TBR" is our mechanism for post-commit review. It should be used rarely and
101only in cases where a review is unnecessary or as described below. The most
102common use of TBR is to revert patches that broke the build.
103
brettw2019b9e2017-02-09 06:40:20104TBR does not mean "no review." A reviewer TBR-ed on a change should still
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:11105review the change. If there are comments after landing, the author is obligated
106to address them in a followup patch.
brettw40e953e2017-02-08 17:49:28107
108Do not use TBR just because a change is urgent or the reviewer is being slow.
brettw2019b9e2017-02-09 06:40:20109Contact the reviewer directly or find somebody.
brettw40e953e2017-02-08 17:49:28110
111To send a change TBR, annotate the description and send email like normal.
112Otherwise the reviewer won't know to review the patch.
113
114 * Add the reviewer's email address in the code review tool's reviewer field
115 like normal.
116
117 * Add a line "TBR=<reviewer's email>" to the bottom of the change list
thestig9208d8ba2017-06-09 22:05:32118 description. e.g. `[email protected],[email protected]`
119
120 * Type a message so that the owners in the TBR list can understand who is
121 responsible for reviewing what, as part of their post-commit review
122 responsibility. e.g.
123 ```
124 TBRing reviewers:
125 reviewer1: Please review changes to foo/
126 reviewer2: Please review changes to bar/
127 ```
brettw40e953e2017-02-08 17:49:28128
129 * Push the "send mail" button.
130
131### TBR-ing certain types of mechanical changes
132
133Sometimes you might do something that affects many callers in different
thestig9208d8ba2017-06-09 22:05:32134directories. For example, adding a parameter to a common function in
135`//base`, with callers in `//chrome/browser/foo`, `//net/bar`, and many other
136directories. If the updates to the callers is mechanical, you can:
brettw40e953e2017-02-08 17:49:28137
thestig9208d8ba2017-06-09 22:05:32138 * Get a normal owner of the lower-level code you're changing (in this
139 example, the function in `//base`) to do a proper review of those changes.
brettw40e953e2017-02-08 17:49:28140
thestig9208d8ba2017-06-09 22:05:32141 * Get _somebody_ to review the downstream changes made to the callers as a
142 result of the `//base` change. This is often the same person from the
143 previous step but could be somebody else.
brettw40e953e2017-02-08 17:49:28144
thestig9208d8ba2017-06-09 22:05:32145 * Add the owners of the affected downstream directories as TBR. (In this
146 example, reviewers from `//chrome/browser/foo/OWNERS`, `//net/bar/OWNERS`,
147 etc.)
brettw40e953e2017-02-08 17:49:28148
149This process ensures that all code is reviewed prior to checkin and that the
150concept of the change is reviewed by a qualified person, but you don't have to
thestig9208d8ba2017-06-09 22:05:32151wait for many individual owners to review trivial changes to their directories.
brettw40e953e2017-02-08 17:49:28152
153### TBR-ing documentation updates
154
155You can TBR documentation updates. Documentation means markdown files, text
156documents, and high-level comments in code. At finer levels of detail, comments
157in source files become more like code and should be reviewed normally (not
158using TBR). Non-TBR-able stuff includes things like function contracts and most
159comments inside functions.
160
brettw2019b9e2017-02-09 06:40:20161 * Use good judgement. If you're changing something very important, tricky,
162 or something you may not be very familiar with, ask for the code review
163 up-front.
brettw40e953e2017-02-08 17:49:28164
165 * Don't TBR changes to policy documents like the style guide or this document.
166
167 * Don't mix unrelated documentation updates with code changes.
168
169 * Be sure to actually send out the email for the code review. If you get one,
brettw2019b9e2017-02-09 06:40:20170 please actually read the changes.
171
172## More information
173
174### OWNERS file details
175
176Refer to the [source code](https://chromium.googlesource.com/chromium/tools/depot_tools/+/master/owners.py)
thestig9208d8ba2017-06-09 22:05:32177for all details on the file format.
brettw2019b9e2017-02-09 06:40:20178
179This example indicates that two people are owners, in addition to any owners
180from the parent directory. `git cl owners` will list the comment after an
181owner address, so this is a good place to include restrictions or special
182instructions.
183```
184# You can include comments like this.
185[email protected]
186[email protected] # Only for the frobinator.
187```
188
189A `*` indicates that all committers are owners:
190```
191*
192```
193
brettwd040b0be2017-02-09 19:11:33194The text `set noparent` will stop owner propagation from parent directories.
brettw2019b9e2017-02-09 06:40:20195This is used for specialized code. In this example, only the two listed people
196are owners:
197```
198set noparent
199[email protected]
200[email protected]
201```
202
203The `per-file` directive allows owners to be added that apply only to files
Wei-Yin Chen (陳威尹)681bc322017-07-20 01:55:11204matching a pattern. In this example, owners from the parent directory
brettw2019b9e2017-02-09 06:40:20205apply, plus one person for some classes of files, and all committers are
206owners for the readme:
207```
208per-file [email protected]
209per-file foo.*[email protected]
210
211per-file readme.txt=*
212```
213
214Other `OWNERS` files can be included by reference by listing the path to the
215file with `file://...`. This example indicates that only the people listed in
216`//ipc/SECURITY_OWNERS` can review the messages files:
217```
218per-file *_messages*.h=set noparent
219per-file *_messages*.h=file://ipc/SECURITY_OWNERS
220```