Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Triage a Queue by Risk

In this lesson, you watched a reviewer rank a queue of five changes by risk before reading any of them closely. The five come from the history of main and are already merged: pulls #18, #22, #24 and #25, and Edsger’s formatter commit, 9dd98af. The video pictures them arriving together on one morning. You know how #24 ended, since you tracked its refund bug down with git bisect, so it’s ranked on what a reviewer could see before the merge.

Key Points

  • Rank first, then read. Giving every line the same care means your time goes by size. The formatter’s 473 lines would eat most of the morning, and the one-line refund change in #24, fourth in line, would wait until you’d run out of time. Spend your time where a mistake would cost the most.
  • Ask each change the same questions. What does it reach? Can a revert undo it? Does it touch stored data, money or security? Is it new logic, code that now decides differently? Does a test run what it changes?
  • Large and harmless can be a skim. The formatter is the biggest change, yet in the ordinary diff each line comes back with only its indentation changed, and git diff -w agrees: nothing left. An empty git diff -w could still hide a change, since it also ignores spaces inside strings.
  • A loud, undoable change can be a skim too. Pull #18 renames the weekly report’s npm script from report to weekly-report. Only people who type the command use it, and git grep -n 'npm run report' finds one stale reader, README.md:35, which you found when you checked #18 against its intent. The old command fails loudly with npm error Missing script: "report", and a revert undoes the rename.
  • Wide reach with low stakes gets a light read. Pull #22 runs on every order. But a mistake there declines a basket before any stock or money moves: in createOrder(), orderLines() runs on line 15 of src/orders/create.js, before reserve() on line 23 and payOrder() on line 24. A revert undoes it, so it gets a light read.
  • Money that can’t come back gets the close reads. Pulls #24 and #25 both decide how much money goes back to a customer, and a refund that’s sent can’t be reverted.
  • The authors on the cards decide nothing. Margaret built the refunds code, but that’s no reason to skim her changes, or to read them harder. The same diff gets the same review, whoever wrote it.
  • A test counts only if it runs the behavior that changed. Edsger’s note on #24 says the ordinary return still passes, and the refund area has two tests. Check with a run whether either one runs what #24 changed.
  • Pull #24 is untested. Pull #24 swapped the paid items subtotal for the gross subtotal. With the paid one back in src/refunds/allocation.js, all fifteen tests still pass. At #24’s own commit, before #25 added its test, the old line passes too: fourteen of fourteen. No test can tell the change from the line it replaced. git restore puts the file back.
  • Pull #25’s final-penny case is covered. Take out the line that hands over the last penny, and its own test fails. That’s one case, not the whole change, but it’s more evidence than #24 has.
  • So #24 goes to the top. It’s one line that sends money out, and no test would catch a mistake in it. Then #25, a light read of #22, and a skim of #18 and the formatter. Ranking takes minutes, and the close reads get most of the morning. The close read of #24 starts where no test reaches: an order with a complimentary book, the case Edsger’s note says he never tried.
  • Write the triage down in your map’s Reviews section, so whoever reads your review knows what you read closely, what you skimmed and why. Give each line its reason and its evidence, such as a run or a line you found.
  • The rule: rank by what a mistake would cost, check every coverage claim with a run, then read from the top.

The Coverage Checks

This is the check on #24, from your clone on main. Line 4 of src/refunds/allocation.js is let denominator = order.grossSubtotal;. Put back the old line from before the change, let denominator = order.paidItemsSubtotal;, then run the tests:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 In the last exercise, you mapped one change’s intent to its hunks. A real morning brings several changes at once. Here are five from main’s history: pull 18, Edsger’s formatter commit, then pulls 22, 24 and 25.

00:17 They’re all merged already. Picture them arriving together this morning. You know how pull 24 ended: you tracked its refund bug down with git bisect.

00:27 So rank it on what a reviewer could see before the merge. Watch out: giving every line the same care means time goes by size. The formatter’s 473 lines would eat most of the morning, and the one-line refund change, fourth in line, would wait until you’d run out of time.

00:46 So rank first, then read. Spend your time where a mistake would cost the most.

00:54 Ask each change the same questions. What does it reach? Can a revert undo it? Does it touch stored data, money or security? Is it new logic, code that now decides differently?

01:06 Does a test run what it changes? The formatter is the biggest change. In the ordinary diff, each line comes back with only its indentation changed. With -w, git diff agrees and shows nothing left.

01:20 So it’s a skim. Pull 18 renames the weekly report’s npm script. Only people who type the command use it. You already found its one stale reader, the README.

01:33 The old command fails loudly, and a revert undoes it. That’s another skim. Pull 22 runs on every order. But a mistake there declines a basket before any stock or money moves, and a revert undoes it.

01:47 So it gets a light read.

01:51 Pulls 24 and 25 both decide how much money goes back to a customer. A refund that’s sent can’t be reverted. Those two get the close reads.

02:02 The authors on the cards decided nothing. Margaret built the refunds code, but that’s no reason to skim her changes, or to read them harder. The same diff gets the same review, whoever wrote it.

02:16 Edsger’s note on pull 24 says the ordinary return still passes. The refund area has two tests. Watch out: a test counts only if it runs the behavior that changed.

02:28 So check it. Pull 24 swapped the paid items subtotal for the gross subtotal. In the allocation file, put the paid one back. Run the tests. All fifteen pass.

02:42 At pull 24’s own commit, before pull 25 added its test, the old line passes too: fourteen of fourteen. No test can tell the change from the line it replaced.

02:53 So pull 24 is untested.

02:57 Then git restore puts the file back. Pull 25 gets the same check. Take out the line that hands over the last penny. Its own test fails.

03:09 Its final-penny case is covered. That’s one case, not the whole change, but it’s more than pull 24 has.

03:18 So pull 24 goes to the top. It’s one line that sends money out, and no test would catch a mistake in it. Pull 25 comes second.

03:28 Now spend the time in that order. Pull 24 first. Its close read starts where no test reaches: an order with a complimentary book, the case Edsger never tried.

03:41 Then pull 25. Pull 22 gets a light read, and pull 18 and the formatter a skim. Ranking took minutes. The close reads get most of the morning.

03:52 Write the triage in your map’s Reviews section. Whoever reads your review then knows what you read closely, what you skimmed and why. Give each line its reason and its evidence, such as a run or a line you found.

04:07 Here’s the rule: rank the queue by what a mistake in each change would cost, check every coverage claim with a run, then read from the top. Next, in Exercise: Plan a Thirty-Minute Review, you’ll rank the parts of one change and write your own triage note.

Become a Member to join the conversation.