10 Tips for Effective Code Review

Preview:

Citation preview

TIM PETTERSEN • SENIOR DEVELOPER • ATLASSIAN • @KANNONBOY

Ten tips for effective code review

1. One issue, one pull request

=

1. One issue, one pull request

# what’s shipping? $ git branch --merged

# what’s left to ship? $ git branch --no-merged

master

IN REVIEW DONEIN PROGRESSOPEN

Automatic Transitions

feature/JIRA-30

master

IN REVIEW DONEIN PROGRESSOPEN

Branch created!

Automatic Transitions

feature/JIRA-30

master

IN REVIEW DONEIN PROGRESSOPEN

Pull Request Created!

Automatic Transitions

feature/JIRA-30

master

IN REVIEW DONEIN PROGRESSOPEN

Pull Request Merged!

Automatic Transitions

2. Minimum TWO approvals before merge

3. Have 1.5x - 2.5x that number reviewers

Fewer reviewers find more defects

0

7.5

15

22.5

30

1 2 3 4 5 6 7 8 9

Def

ects

/ k

LoC

Number of Reviewerssource: bit.ly/review-stats

More reviewers spend less time

0

7

14

21

28

1 2 3 4 5 6

Min

utes

spe

nt /

revi

ewer

Number of Reviewerssource: bit.ly/review-stats

4. Use blame to pick reviewers

4. Use blame to pick reviewers

$ npm install -g git-guilt

# find blame delta for current branch $ git guilt `git merge-base master HEAD` HEAD

Alice Foo ++++++++++++++++++++++++(239) Bob Bar ++++++++ Eve Baz ------- Mira Ted ---------------- Bec Opal ------------------------(-159)

4. Use blame to pick reviewers

bit.ly/suggest-reviewers

5. @mention specialists

6. Stuck in review?

Make Tuesday & Thursday inbox zero days

betterCode;

7. Move comments into code

review comments

// comments // in code

8. Build a team policy, as a team…

…and enforce it!

9. Add screenshots for UI/UX changes

(gifs / videos are even better)

9. Add screenshots for UI/UX changes

(gifs / videos are even better)

Monosnap GIPHY ScreenFlow

Ask a programmer to review 10 lines of code, they'll find 10 issues. Ask them to do 500 lines and they'll say it looks good.@ G I R AY O Z I L

“”

10. Keep it concise

10. Keep it concise Se

cond

s pe

r lin

e

Lines of Code

1 line per second

100 lines per second

source: bit.ly/review-stats

Thank you!

TIM PETTERSEN • SENIOR DEVELOPER • ATLASSIAN • @KANNONBOY