code-review/README.md
A guide for reviewing code and having your code reviewed.
Watch a presentation that covers this material from Derek Prior at RailsConf 2015.
Accept that many programming decisions are opinions
Ask good questions; don't make demands
:user_id?"Good questions avoid judgment and avoid assumptions about the author's perspective
Ask for clarification
Avoid selective ownership of code
Avoid using terms that could be seen as referring to personal traits
Avoid diminishing words
Be explicit
When disagreeing, provide alternative solutions
Be humble
Don't use hyperbole
Don't use sarcasm
Keep it real
Talk synchronously if there are too many "I didn't understand" or "Alternative solution:" comments
If you learned something new, share your appreciation
Avoid the "since you're at it" attitude
Be grateful for the reviewer's suggestions
Be aware that it can be challenging to convey emotion and intention online
Explain why the code exists
Extract some changes and refactoring into future tickets/stories
When making visual changes, include screenshots or screencasts to show the effect of the changes
Link to the code review from the ticket/story
https://github.com/organization/project/pull/1Push commits based on earlier rounds of feedback as isolated commits to the branch
Seek to understand the reviewer's perspective
Try to respond to every comment
Wait to merge the branch until continuous integration tells you the test suite is green in the branch
Merge once you feel confident in the code and its impact on the project
Final editorial control rests with the pull request author
Recognize the work of your teammates when you are pairing
Co-Authored-By: <name> <email> at the end of your commit message.Understand why the change is necessary (fixes a bug, improves the user experience, refactors the existing code).
Then:
Communicate which ideas you feel strongly about and those you don't
Identify ways to simplify the code while still solving the problem
If discussions turn too philosophical or academic, move the discussion offline to a regular Friday afternoon technique discussion
Offer alternative implementations
Seek to understand the author's perspective
Approve the pull request
Remember that you are here to provide feedback, not to be a gatekeeper
When suggesting changes using the "Add a suggestion" feature:
Reviewers should comment on missed style guidelines. Example comment:
> Order resourceful routes alphabetically by name.
An example response to style comments:
Whoops. Good catch, thanks. Fixed in a4994ec.
If you disagree with a guideline, open an issue on the guides repo rather than debating it within the code review. In the meantime, apply the guideline. It's often helpful to set up a linter like standard to format code automatically.
This helps us have more meaningful conversations on PRs rather than debating personal style preferences.