Reviewer · Documentation
Document non-obvious rationale
When code contains logic whose intent isn't obvious from reading it alone—such as why a field is preferred over a similar one, why a partial match is used instead of an exact match, or why a file/function was removed—add an inline comment (or detailed PR description) explaining the "why," not just the "what." This helps future maintainers avoid...
When code contains logic whose intent isn’t obvious from reading it alone—such as why a field is preferred over a similar one, why a partial match is used instead of an exact match, or why a file/function was removed—add an inline comment (or detailed PR description) explaining the “why,” not just the “what.” This helps future maintainers avoid reintroducing bugs or misunderstanding intent, and helps reviewers verify correctness without having to dig through history or other files.
For subtle semantic distinctions, document the relationship between related fields/values:
// `plugin_version` represents the version specified at mount time (if any), and is only used for external plugins.
// For built-in plugins, this field is intentionally left empty to simplify upgrades.
//
// `running_plugin_version` reflects the actual version of the plugin currently running,
// regardless of whether it is built-in or external. This provides a reliable source of truth
// and is why we are surfacing it over plugin_version.
@attr('string') runningPluginVersion;
For intentional implementation choices that could look like a mistake, explain the reasoning:
// We're using a partial match ("includes") to catch any occurrence of "permission denied" in error messages.
// This ensures we catch permission errors in all workflows, even if the message is not an exact match.
const permissionDenied = resp?.errors?.some((str) => str.includes('permission denied'));
When removing or replacing files/functions, include a summary (in the PR description or as inline comments) of what the removed code previously did and where/how that functionality is now covered, e.g.:
This file previously exported
MOUNTABLE_AUTH_METHODS,ENTERPRISE_AUTH_METHODS,methods(), andallMethods(), used in ~12 places. This has been replaced byutil/all-engines-metadata.ts, which provides the same data plus additional metadata.
This saves reviewers from having to open deleted files or trace history to confirm no functionality was lost.