Gerrit and Code Review Best Practices

Gerrit and Code Review Best Practices

1. Best Practices - Making Changes

2. Best Practices - Reviewing Changes

3. Best Practices - Project Setup

Best Practices - Making Changes

Making Changes

each change should add something usable

  change = complete feature

or

  change = bug-fix

⇒ Have a releasable state after every change.

Making Changes

each change should focus on only one thing

Q: Why is this bad?

A:

  • You need the bug-fix in another branch.
    git cherry-pick is not easy
  • The feature broke something.
    git revert cannot be used
  • It’s more difficult to review.

Making Changes

push only changes that are ready

Q: Who wants to merge unfinished changes?

Q: Who wants to review unfinished changes?

A: It is unclear for reviewers

  • what is an issue and
  • what is simply not done yet

Making Changes

mark unfinished and experimental changes as [RFC] (Request For Comments),
but tell reviewers which feedback you expect

RFC

Examples:

Making Changes

write good commit message

Q: Who wants to review this change?

Bad Commit Message

Making Changes

write good commit message

Q: This one looks more interesting, doesn’t it? Good Commit Message

Making Changes

write good commit message

Making Changes

explain the motivation for the change

Q: Why is this commit message bad?

Commit Message without motivation

A: No info about why this had to be disabled.
      git blame gets less useful.

Making Changes

prefer small changes

Q: Who wants to review this change?

Huge Change

Making Changes

make big features as series of small changes

Making Changes

split refactoring from feature

Making Changes

provide screenshots for UI changes

Screenshot Attached

Example:

Making Changes

reply to every comment

Making Changes - Summary

Better one developer invests time to polish a change
than n reviewers waste time on review.

Best Practices - Reviewing Changes

Reviewing Changes

review each change

Q: Looks good!?

Small Change

Reviewing Changes

review each change

Q: And now?

Small Change

Reviewing Changes

everyone should do reviews

follow reviews of others

Reviewing Changes

cooperate to find best solution

Reviewing Changes

mark optional comments as [optional]

Optional Comment

comment on nits

Nit Comment

Reviewing Changes

try out changes

Reviewing Changes

issue in merged code

Reviewing Changes

Code Review Voting

Reviewing Changes

do not self approve changes

Reviewing Changes

review takes time

Reviewing Changes - Summary

Being a good reviewer is a different qualification than being a good developer.

Best Practices - Project Setup

Project Setup

automate verification

Project Setup

Project Setup

not everyone needs submit privileges

Project Setup

use text format for documentation

Project Setup

customize submit rules via Prolog

Project Setup

choose right submit type

Project Setup

do not version large binaries

find right granularity for the repositories

Project Setup

learn Git/Gerrit tooling and workflow