Um momento
0x50Lesson 6 of 14

Code review

Review pull requests kindly and effectively, use suggestions and review states, and route reviews with CODEOWNERS.

26 min 7-question quiz 2 code exercises
By the end of this lesson you can
  • Leave clear, kind, actionable review comments, including suggested changes
  • Use review states - comment, approve, request changes - and required reviews
  • Route reviews automatically with a CODEOWNERS file

Code review catches bugs, spreads knowledge across the team, and keeps a codebase consistent. On GitHub you review in a PR’s Files changed tab: click a line (or drag across several) to comment, and submit everything as one review with a state:

  • Comment - feedback without a verdict.
  • Approve - good to merge.
  • Request changes - must be addressed first. With branch protection, this blocks merging until the reviewer approves.

A suggested change is a comment containing a block marked suggestion. The author can apply it with one click, which commits it for them:

a review comment with a suggestion
1**nit:** this name hides what the number means.
2
3```suggestion
4MAX_DASH_DISTANCE = 3  # tiles
5```

Good reviews are about the code, never the person, and make each comment’s weight clear:

  • Prefix optional comments: nit: (tiny), suggestion:, question:. Make blocking ones explicit.
  • Explain why: “This runs once per frame, so the list copy will add up” beats “don’t copy the list”.
  • Ask rather than accuse: “What happens if enemies is empty?”
  • Praise good things - it tells people what to keep doing.
  • Review promptly. A PR waiting three days for review is a PR whose author has moved on.

And as the author: don’t take comments personally, reply to each one (or resolve it with a fix), and say thanks.

Try it

Review this pull request

A contributor’s PR adds a high-score saver to Dungeon Dash. Click every line you’d comment on, then check what you missed.

src/scores.py (new file) (1 of 1)Flags found 0/0

Click every part that looks suspicious. There are 5.

import json API_KEY = "sk_live_51HxQ..." def save_score(name, score): data = json.load(open("scores.json")) data.append({"name": name, "score": score}) data.sort(key=lambda entry: entry["score"]) print("DEBUG", data) json.dump(data, open("scores.json", "w")) def top_score(): return load()[0]

CODEOWNERS

A CODEOWNERS file (in .github/, the root or docs/) maps paths to the people or teams who own them. When a PR touches matching files, GitHub automatically requests their review - and branch protection can require a code owner’s approval.

Each line is a pattern and one or more owners. Patterns work like .gitignore, and the last matching line wins - so put general rules first and specific ones after.

.github/CODEOWNERS
1# Default owners for everything
2*                 @dungeon-dash/maintainers
3
4# Art and audio
5*.png             @sam-sprites
6/assets/audio/    @dungeon-dash/audio
7
8# The physics engine
9/src/engine/      @mira
10
11# Docs: anyone on the docs team, plus mira for the API reference
12/docs/            @dungeon-dash/docs
13/docs/api/        @mira @dungeon-dash/docs

Key takeaways

  • Submit reviews as Comment, Approve or Request changes; suggestions let authors apply fixes in one click.

  • Comment on the code, explain why, label nits, ask questions and point out what’s good.

  • CODEOWNERS requests reviews automatically; the last matching line wins.

  • Branch protection can require approvals and code owner reviews before merging.

Lesson quiz

7 questions · pass with 5 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: automate GitHub chores with Python

Real GitHub work involves lots of small automation: matching CODEOWNERS, expanding build matrices, bumping versions, reading the API. Write those helpers in Python and run them against sample inputs - locally in your browser, with no GitHub account needed.

Exercise 1

Who owns this file?

+25 XP

The input is a CODEOWNERS file, a line ---, then changed file paths (starting with /). For each path print its owners from the last matching rule, or (no owners). Then print reviewers: ... - every distinct owner across all files, sorted.

Simplified matching: a pattern ending in / matches everything under that folder; a pattern starting with / is matched from the root; otherwise the pattern is matched (with fnmatch) against the file name. Skip blank lines and # comments.

  • Dungeon Dash
  • No default owner
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Exercise 2

Can this PR merge?

+25 XP

Each input line is a review event in time order: user STATE, where STATE is APPROVED, CHANGES_REQUESTED or COMMENTED. Only each user’s latest approve or request-changes counts (a later COMMENTED doesn’t change their verdict). The branch requires 2 approvals and no outstanding change requests.

Print each reviewer’s verdict sorted by name (mira: APPROVED, or sam: none for a reviewer who only commented), then mergeable: yes or mergeable: no (1 of 2 approvals, changes requested by mira) - listing whichever reasons apply, separated by commas.

  • Approved after changes
  • Blocked
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Gostou da aula? 😆👍
Apoie nosso trabalho com uma doação: