GitHub's New Whitespace Preferences: How to Review AI Code in Two Passes
A cleaner diff can help you understand a change. Before you merge, check what your review settings left out. You ask AI to fix one bug. It returns a change that also reformats half the file. Now you have two problems: understanding the fix and finding everything else that moved. On October 22, GitHub announced saved whitespace preferences for pull-request reviews . You can keep whitespace…
GitHub has introduced new whitespace preferences for pull-request reviews. This update allows you to review AI-generated code in two distinct passes. During the first pass, focus on understanding the intended behavior and changes made to the code. Write down the desired outcome before opening the diff, explaining it in a single sentence. For instance, a fictional appointment app might state: "Reject an end time that comes before the start time and keep the user's entered values visible."
In the second pass, restore the full diff view to ensure all changes, both formatting and behavior-related, are visible. This step is crucial for catching any overlooked modifications, such as configuration edits, deleted tests, or unrelated files that were reformatted. Remember, whitespace changes are not always cosmetic; they can alter the execution flow of your program. For example, moving a save operation outside an error-handling block could lead to unintended behavior if the validation fails.
After the second pass, record three key points in your review: 1) the intended behavior (e.g., invalid time ranges cannot be saved), 2) the completeness of the inspection (the complete diff was reviewed with whitespace visible after the focused pass), and 3) the behavioral outcomes (invalid input failed safely, corrected input was saved, and the saved record contained the expected times). These statements provide a clear record of what was verified during the review process.
While GitHub's review tool offers a convenient view that can simplify the initial assessment of a patch, it's essential to remember that this does not guarantee every possible failure has been found. Use the second pass to thoroughly check the changes and record any uncertainties before making a decision to merge.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.