In this lesson, you watched a review look past a diff. The change was made up for the video, on a local branch, so it isn’t in your clone. It renames the saved order field refunded to refundedPence, so the name says the unit.
Key Points
- Every line in the diff was right. Four files changed, each hunk swapped the old name for the new one, and
npm testpassed 15 of 15. However, a diff shows the lines that changed, with a few lines around them. Code elsewhere that still uses the old name isn’t in it. - The principle: a change reaches past its own lines, so look for every reader of what it touches.
- Search the whole repo for the old name on an order. With
-w,git grepmatches whole words only, sorefundedPencedoesn’t count. Three lines came back. The one increateRefund()is an event’s name, in quotes, so it’s text and doesn’t read the field. The other two are outside the diff.weeklySales()insrc/reports/weekly.jsbuilds the report’s refunded and net columns from the old field. The orders table in the staff desk, the admin page you’ve used (public/admin/app.js), shows it too. - Search the field’s bare name and the callers too. Also search the field’s bare name,
refunded, and the changed functions’ callers, and check each hit outside the diff. - Ask of each reader: does this still get what it expects? An order placed on the branch has no
refundedfield, so where both expect a number of pence, they readundefined. - Search the data too. Saved data can hold the old name. A search of the
data/folder for the old name finds one line in the seed file,data/seed.json: order-1, Nadia’s order, with"refunded": 0. The diff left this file alone, yetnpm run seedcopies it into the shop’s data, and the tests load it too. So every seed gives order-1 the old shape, with norefundedPence. A live shop’s orders saved before the change would keep it too. SocreateRefund()andupdateStatus(), the diff’s own functions, read a field order-1 doesn’t have. - Run the branch to check what you read. A new order for Nadia in the staff desk, order-2, is in the new shape. Its row shows £NaN returned. The table reads the old field, so it gets
undefined. Arithmetic onundefinedgivesNaN, short for not a number. The weekly report showsNaNfor order-2 too. - Then a return on order-1, the order in the old shape. On main, that row shows £4.50 returned and the status
partly-refunded. £4.50 is short because of main’s own refund bug, the one you found withgit bisect, and it’s the same on both branches. On the branch, the return is saved, yet order-1’s row shows £0.00 returned and the status is stillpaid. The return had norefundedPenceto add to, and the table still reads the old zero. - Write down the affected places, next to your review: the weekly report, the orders table, the seed file, and orders already saved. Give each its evidence: the line you found, or the run. Note what you checked and found not affected too, such as the event name.
- The rule: for each name or saved shape a change touches, search for every reader, including the data already saved, then run the branch to check.
The Searches
These are the commands the video ran, on the made-up branch:
$ git switch made-up/refunded-pence
$ git show --stat --format='%h %s' HEAD
$ npm test
$ git grep -n -w -F "order.refunded"
$ git grep -n -w -F "refunded" data/
$ npm run seed
$ npm start
$ npm run weekly-report
A full review also searches the field’s bare name and the changed functions’ callers, then checks each hit outside the diff:
$ git grep -n -w refunded
The search for readers of the old name on an order found these three lines:
public/admin/app.js:34: appendText(row, 'td', pounds(order.refunded));
src/refunds/create.js:41: eventLog(state, 'order.refunded', { ... });
src/reports/weekly.js:8: ... paid: order.total, refunded: order.refunded, ...
The search of the data folder found this one:
data/seed.json:33: "code": "READ20", "total": 2400, "refunded": 0, "status": "paid",
The List of Affected Places
This is the list written next to the review:
Reaches · made-up/refunded-pence
1. src/reports/weekly.js:8 · run: order-2 NaN in the report
2. public/admin/app.js:34 · run: order-2 shows £NaN
3. data/seed.json:33 · seed and tests load order-1 with refunded
4. orders saved before the change · run: order-1's return shows £0.00, still paid
Checked, not affected: src/refunds/create.js:41, the event name (text)
After a real review, switch back to main, seed again, and delete the branch, so the working tree is clean.
Next, in Exercise: Find What the Change Reaches, you’ll read a small change to part of the shop and list every place it reaches.