skip to content

Why annotate analyser findings on the change under review instead of only failing the build?

level: middleimportance: nice to knowfreq 26%

answer

  1. Deciding and explaining are different jobs
  2. Count the context switches
  3. Findings belong next to the code
  4. Attribute to this change only
  5. Replace annotations, never append

basics

~20 s

A failed build says something is wrong; an annotation on the changed line says which rule, which line and what to do, where the author is already reading the code. It removes the context switches between failure and fix.

solid answer

~50 s

A pipeline has two jobs and they should stay separate: the status decides whether the change may merge, and the presentation explains what is wrong. A red build with a log link makes the author open the log, find the analysis step, map a path and line back to their change, and look up the rule - four context switches that can cost more than the fix. An annotation on the changed line collapses that to zero by carrying the rule identifier, a statement of what is wrong in this specific code, and the fix where the analyser can produce one. Three disciplines keep it useful: annotate only findings attributable to this change, not inherited ones in touched files; cap the inline count and summarise the rest, since a change with 143 annotations gets none of them read; and replace rather than append on each push, so stale findings do not accumulate.

go deeper

for a junior

Be ready to say why a finding shown next to the offending line is easier to act on than the same finding buried in a build log, and that the build status is still what decides whether the change can merge.

for a middle

Explain what a useful annotation carries - rule identifier, what is wrong in this specific code, the suggested fix - and the two disciplines that keep it usable: attributing findings to the change and replacing rather than appending on each push.

for a senior

Show that you would bound volume deliberately, aggregate low-severity findings, and treat a flood of annotations as a signal about the rollout. Be clear that annotations explain while the status enforces, and never split enforcement across both.

for a principal

Own the credibility angle: automated commentary on a review surface carries the authority of that surface, so noisy or wrong annotations cost you human review attention too. Decide what the organisation is willing to say automatically on someone's change.

### Two different jobs: deciding and explaining A pipeline that runs analysis has to do two things, and they are frequently confused. It has to **decide** — this change may or may not merge — and it has to **explain** — here is what is wrong, where, and what to do. A pass/fail status does the first job well and the second job not at all. An annotation attached to the changed lines does the second job well and should not be trusted with the first. Keep them separate. One status, owned by the gate, answers "can this merge". Annotations are presentation: they put the finding in front of the author at the moment and place where the decision to change the code is being made. ### Why the log is not good enough When the only artefact is a red build with a link, the author pays a context switch to open the log, another to find the analysis step among the others, another to map a file path and line number back to the change they are looking at, and often a fourth to work out which rule fired and whether it is worth arguing with. Each of those is small; together they are the difference between fixing the finding now and adding it to a mental list. On a change that produced a handful of easy findings, the surfacing cost can exceed the fixing cost. An annotation on the changed line collapses that to zero: file, line, rule identifier, one-sentence explanation, and where possible the suggested fix, rendered next to the code. ### What a good annotation contains - **The rule identifier**, so the author can look up its rationale, and — if they disagree — write a correctly targeted, justified suppression instead of a broad one. - **A statement of what is wrong in this specific code**, not the rule's generic description. "This comparison of monetary amounts uses floating-point equality" beats "avoid float equality". - **What to do**, and the fix itself where the analyser can produce one. - **Severity, disambiguated.** An analyser's own severity level for a rule is not the same thing as the business urgency of the finding, and a reviewer reading the annotation should be told which is meant. ### The failure mode: volume Annotation quality collapses with quantity. A change that arrives with 143 annotations is a change whose annotations will all be collapsed unread, and the useful one among them is lost. Three defences: 1. **Attribute to the change.** Annotate findings the change introduced, not every pre-existing finding in the files it happens to touch. Otherwise a one-line edit to an old file buries the author in inherited debt they did not create and cannot triage. 2. **Cap and summarise.** Post the first N inline and a single summary carrying the counts by rule, with a link to the rest. The summary also gives you somewhere to say "and 118 more of the same rule", which is itself the most useful signal on that change. 3. **Annotate errors inline, aggregate warnings.** If everything is annotated with equal weight, nothing is. ### Idempotence Annotations are posted per run, and changes get pushed repeatedly. Without care, the third push leaves three copies of every finding, and a finding the author has already fixed still sits there from run one. Replace the previous run's annotations rather than adding to them, resolve or delete annotations for findings that no longer reproduce, and key annotations to content rather than to a line number so a shifted line does not create a duplicate. A review surface littered with stale bot output trains reviewers to filter out the bot entirely — which costs you the human findings that were mixed in with it. ### Where this sits in the stack Annotation is the last of the feedback placements, and it should mostly be a safety net: the editor and the commit-time check should already have shown the author almost everything the pipeline annotates. If the review surface is where people routinely first learn about a rule, the earlier placements are not working, and the annotation quality is treating a symptom. Finally, this is a courtesy that only pays if it is honest. An annotation that says a line is wrong when the rule is a matter of taste, or that offers a fix that does not compile, is worse than a log entry, because it arrives with the authority of the review surface. Annotate what you would be willing to defend in review yourself.

  • A change arrives with 143 inline annotations. What has gone wrong?
    The volume itself is the defect: at that count everything is collapsed and nothing is read, so the useful finding is lost. Usually the cause is annotating pre-existing findings in touched files rather than findings the change introduced, or enforcing a rule set that was never staged. Cap the inline count, summarise by rule, and treat the number as feedback on the rollout.
  • Should the annotations themselves decide whether a change can merge?
    No. Keep one enforcement source - the build status the gate owns - so the question of whether a change may merge has exactly one answer and one owner. Annotations are presentation: they explain the same findings in a better place. Splitting enforcement across two mechanisms produces changes that are red in one place and green in another, and nobody knows which to trust.
  • How do you keep repeated pushes from leaving stale annotations behind?
    Make annotation idempotent. Replace the previous run's annotations instead of adding to them, remove those whose findings no longer reproduce, and key each one to the offending content rather than to a line number so an unrelated insertion above does not create a duplicate. Stale bot output trains reviewers to filter out the tool entirely, human findings included.

saying these in an interview costs you the question

  • Treats the annotation itself as the enforcement mechanism
  • Annotates every pre-existing finding in a touched file
  • Posts the same findings again on every push
  • Gives a bare rule code with no explanation or fix
  • Assumes developers will open the build log anyway
  • Uses the analyser's rule severity as business urgency

context