Skip to content

An issue or pull request URL in a code comment is a source citation, not a second lookup #1715

Closed

Description

@ptr727

comment-and-doc-style "Issue, pull request, and commit references" bans naming an issue or a pull request in any comment, code comments included. Applied to a code file that ban deletes source citations, because in code the reference is not a second lookup. It is the citation for the line under it, and it is doing the same job as the datasheet link, the wiki link and the SDK doc link sitting beside it, which the same rule leaves alone.

The rule's own remedy, "write the constraint the reference was standing in for", cannot be executed on some of them at all, because the reference is the content rather than a citation beside it.

What this looks like in practice

These are the eleven instances in ptr727/ESPHome-Config, a live ESPHome /config tree. Every one sits in a YAML comment.

The citation is one of several reference links, and the others are permitted. templates/norvi-enet-ae06-r.yaml:

# ESPHome support:
## DS3231 is compatible with the DS1307
## https://github.com/esphome/feature-requests/issues/515
## https://esp-idf-lib.readthedocs.io/en/latest/groups/ds3231.html
##
## microSD card IO is not yet supported
## https://github.com/esphome/feature-requests/issues/513

The banned line and the permitted line are adjacent, answer the same question, and differ only in which host serves them. archive/esp32-audio-kit-test.yaml is the same shape, a five-line bibliography where one entry is a pull request and the other four are vendor docs and a forum thread.

The citation substantiates a workaround. templates/norvi-enet-ae06-r.yaml:

    # Increase speed to prevent component took a long time errors
    # https://github.com/esphome/issues/issues/4717#issuecomment-1643391691
    frequency: 400kHz

A maintainer revisiting that frequency override needs to know whether the reported cause still stands. Nothing writable into the comment answers that, because the answer is live state in someone else's tracker.

The reference is the whole content, so the remedy has nothing to rewrite. templates/max17048.yaml:

# TODO: https://github.com/esphome/feature-requests/issues/2277

and recirculation-pump-controller.yaml:

    # https://github.com/esphome/issues/issues/2270
    # default_mode: heat

Applying the remedy here means opening two upstream issues and writing a summary of each. That is not a rewrite, it is research, and the result is a worse comment than the link: a paraphrase that goes stale silently while the link stays correct.

The reference is a safety record. garage-door-controller.yaml is a controller that is physically powered off after an opener self-opened twice. Its header comment carries the incident report, the upstream report the cause was confirmed in, and an older report of the same pattern. The block describes the mechanism in full, so nothing factual is lost by deleting them, and what is lost is the trail to whether the upstream fix has shipped.

Why the rule's three reasons do not reach this surface

  • "A reference is a second lookup, and the reader is already holding the file." True where the reference stands in for a fact that could have been written down. It is false where the referenced thing is upstream status, which is not in the file, cannot be put in the file, and changes without anyone touching the file.
  • "The lookup can be impossible." That reason is about a private repository's content carried into a public one. These all point at public upstream projects, exactly like a wiki or an SDK link.
  • "It pollutes the content." In these files a URL line is the established idiom. Removing only the ones whose host is a forge, while keeping datasheets, vendor wikis, forum threads and esphome.io component docs, is not less pollution. It is the same line count with the useful half removed.

Proposed change

In code, and YAML is code, treat an external link naming an issue or a pull request as information rather than a violation, at most a warning. Keep the ban where the reasons do hold:

  • Instruction documents keep the ban outright. AGENTS.md, CODESTYLE.md, GOVERNANCE.md and their siblings are prose that teaches a rule, and a citation there really is a second lookup standing in for a constraint that should have been written. The three the repository above removed from CODESTYLE.md and OPERATIONS.md were correct removals and are not asked back.
  • The bare spellings keep the ban everywhere, #1234 and owner/repo#1234. Those genuinely are a second lookup: they carry no destination, they resolve differently depending on which repository a reader happens to be in, and the existing issue-ref rule already detects them.
  • A URL is the permitted spelling in code, because it names its destination, it is verifiable by anyone, and it is indistinguishable in purpose from the documentation links the rule already allows.

This interacts directly with issue #1711, which asks the gate to read link destinations so a Markdown link to a pull request stops passing. The two are consistent if that detection lands with the surface split above: an error in instruction text, information in code. Landing #1711 as a uniform error instead would make every example on this page a CI failure, which is the outcome this issue is asking to avoid.

What the downstream repository is doing meanwhile

ptr727/ESPHome-Config is keeping all eleven and stating the divergence in the commit that would otherwise have swept them. Two of them changed spelling only, from owner/repo#N to the URL form, because the bare form fails the current gate on a changed line.

Activity

  1. ptr727 commented on Sep 20, 2026

    @ptr727
    OwnerAuthor

    Accepted, and the diagnosis lands one step further than the issue puts it: the gate is already doing the defensible thing, and the rule text is what is wrong.

    The gate and the rule disagree

    Probed at main against a YAML file carrying all four spellings:

    2 violation(s) across 1 file(s)
      issue-ref        2
    conf.yaml:10: issue-ref: issue or pull request reference '#4242'
    conf.yaml:12: issue-ref: issue or pull request reference '#4717'
    

    The two upstream URL citations pass. Only the two bare forms report. So the eleven instances in ESPHome-Config were never failing CI, and nine of them never could have.

    What deleted them is the prose. comment-and-doc-style says "No comment, no docstring, and no instruction document names an issue, a pull request, or a commit. The surfaces are code and workflow comments", which plainly covers a URL in a YAML comment. An agent following the rule removes a citation the gate would have allowed, which is what happened, and which no gate run would have caught either way.

    The rule is scoped on the wrong axis

    It splits on which file. Its own three reasons split on whose tracker.

    • A reference to this repository's own issue is a second lookup. The constraint could have been written into the comment, the reader is holding the file, and the rationale block grows a citation per round. All three reasons hold, in code and in instruction text alike.
    • A reference to another project's tracker is a source citation to live external state. It cannot be written into the file, because upstream status is not a fact the file can hold and it changes without anyone touching the file. The lookup is not impossible, these being public upstream projects. And it does not pollute, because the rule already permits the datasheet, the vendor wiki, the forum thread and the component docs on adjacent lines. The only discriminator left is the hostname, which nothing in the rationale supports.

    That is why the remedy is unexecutable on some of these. "Write the constraint the reference was standing in for" has nothing to rewrite when the referenced thing is upstream status.

    The decided shape

    • Own-repository reference: banned, in code comments and instruction text, bare or URL. This is the case the rule was written for and it keeps all three reasons.
    • External project's tracker: permitted in code, treated as the source citation it is, alongside the documentation links the rule already allows. Still banned in instruction text, where a rule states its constraint rather than citing a tracker.
    • Bare spellings banned everywhere, #1234 and owner/repo#1234, as this issue itself proposes. They name no destination and resolve against whichever repository the reader happens to be in.

    On the interaction with #1711

    That issue asks the gate to read link destinations so a Markdown link to a pull request stops passing. The direction recorded there already scopes the detection to instruction text only, so it does not turn any example on this page into a failure. The two are landing in one pull request together with #1710, because #1711 without this surface split is exactly the uniform error this issue asks to avoid, and one review loop should judge that coupling rather than two loops each seeing half of it.

    On the downstream divergence

    Keeping all eleven and stating the divergence was the right call. The two changed from owner/repo#N to the URL form stay changed, since the bare-form ban holds under this shape too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions