How to review a code change

A diff shows what changed. Deciding whether the change is right is still your job. This routine works for a copied function, a small script or a configuration change.

Start with the purpose

Write one sentence that says why the code changed, for example "Normalize license codes before validation". Then read every changed row against that sentence. A bug fix should touch only the area of the bug. If a wording change also touches database access, permissions or file handling, review that part on its own.

What each kind of row can hide

Worked example

Open Compare Codes and click Sample. It loads two versions of a small C# license validator and reports 4 modified rows and 1 deleted row in 3 blocks. Read them against the purpose "Normalize license codes before validation".

Block 1: empty input

return false; became throw new ArgumentException("License code is required.");. This has nothing to do with normalizing. Every caller that expected false for an empty field now gets an exception.

Block 2: the format check

The old code required exactly four parts separated by dashes. The new code only checks that a dash exists, so ABCD-EFGHIJKLMNOPQR was rejected before and is accepted now. The tool pairs rows in order, which puts Split('-') next to the unrelated Contains("-"), so read this block as a whole. Only ToUpperInvariant() matches the stated purpose.

Block 3: the return value

The added normalized.Contains("-") repeats a check that already ran a few lines above. It is harmless, but it suggests the author was unsure about the earlier change.

Result: one change matches the purpose, two change behavior without saying so, and one is redundant. Reading every block matters more than counting rows.

Checklist

Review the risky areas first. A one line change there can cause a security issue or data loss:

Then check behavior, not only text:

For code from an AI assistant or a forum, add the extra steps in how to review copied code.