Urgent.News

650+ sources. One page. See who else covered it.

Editions

Tech

The what, why, and how of pull requests and source comments

Microsoft veteran on knowing the difference and convincing approvers to accept a change

The what, why, and how of pull requests and source comments

Veteran Microsoft engineer Raymond Chen recently clarified the distinction between pull request descriptions and comments embedded within code. Both are essential, but they serve distinct purposes.

According to Chen, the PR description is a snapshot of information relevant to the code review process at a particular moment. It is a persuasive document aimed at convincing the approver that the proposed changes should be accepted. In contrast, code comments are meant to elucidate the code itself. These comments provide enduring insights that remain valuable even after a pull request has been finalized.

Chen argues that commit messages should be considered alongside PR descriptions and code comments, though the focus presently lies on the difference between PR descriptions and code comments, given the surge in AI-generated pull requests and sometimes puzzling annotations. Interestingly, developers from Chen's past, like another colleague who avoided commenting altogether, had a different approach.

They believed their code was self-explanatory. Today, a more candid comment might read: "This was written by [name], and I have no idea how it works."

This situation mirrors another ongoing debate among developers: whether to use tabs or spaces for indentation. In 2024, Microsoft veteran Larry Osterman adopted a neutral stance, suggesting that tabs were acceptable when storage was limited, but spaces were preferable due to their consistent and reliable nature.

Chen's perspective on code formatting is flexible: he doesn't care how code is formatted as long as it remains his own source code. However, he recommends treating any significant changes in formatting as a separate commit, so maintainers aren't overwhelmed with a diff dominated by a new style guide.

Ultimately, Chen's distinction between PR descriptions and code comments highlights their different roles: PR descriptions explain why a change should be accepted, while code comments preserve the necessary context for future programmers to understand the code.

Written by urgent.news from The Register's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Also reported by 1 other outlet

Read the original at theregister.com →

More in Tech

The Command Injection Fix Cursor Writes Still Runs Code (CWE-78)

TL;DR Cursor writes exec() with your input pasted into the command string, which is textbook command injection (CWE-78). Ask it to fix that and it adds a regex blocklist for shell metacharacters.

  • Command injection vulnerability allows attackers to execute arbitrary code on the server.
  • Fix bypassed despite regex blocklist due to git protocol.ext.allow defaulting to user.
  • Mitigation involves using execFile with argv array and validating input as a URL with whitelist.

More from Sunday 16 August →