Skip to content

feat(#17): surface forwarding call-site line per hop - #18

Merged
larspohlmann merged 8 commits into
developfrom
feature/17-surface-forward-line
Aug 12, 2026
Merged

larspohlmann merged 8 commits into
developfrom
feature/17-surface-forward-line

Conversation

@larspohlmann

Copy link
Copy Markdown
Owner

Closes #17.

See design spec and implementation plan.

Summary

Surface Hop::forwardLine (the forwarding call-site line) in every reporter that previously hid it, so duplicate findings (one method forwarding a param to the same callee via multiple call sites — e.g. JsonLdLayer::article() calling CardFields::httpUrl() twice at lines 166 and 180) become distinguishable. No finding-emission or fingerprint change (Option B — display, not dedupe).

  • text/pretty reporters: append →N to each non-terminal hop's location (file:line→forwardLine); terminal hops keep plain file:line.
  • github reporter: line= uses forwardLine ?? hop->line for all annotations (anchor + notices).
  • sarif reporter: relatedLocations startLine uses forwardLine ?? hop->line; origin locations[0] keeps declaration line.
  • json reporter: already emitted forwardLine per hop; unchanged.
  • checkstyle reporter: origin-only summary; unchanged.
  • fingerprint: unchanged (refactor-stable by design — excludes lines and intermediate hops per docs/plan.md).
  • New fixture tests/fixtures/same-callee-two-callsites/ pins the two-finding emission rule against a future accidental dedup regression.
  • docs/plan.md §2.3 (Branching) amended to cover the same-callee-multiple-call-site case explicitly (clarification, not a semantics change).

Verification

  • composer check green (490 tests, 1581 assertions).
  • composer infection:diff clean on touched code (zero escaped mutants on forwardLine ?? hop->line / → / label() lines; MSI 94% vs 80% gate).
  • Manual reproduction against simple-feed-reader/backend/src confirms the two JsonLdLayer::article findings now distinguish at hop 4: :164→166 vs :164→180.

Side note

PrettyReporter::label() was refactored from two guard clauses to match(true) to keep PHPMD WMC under 50 (the new if ($hop->forwardLine !== null) guard in location() would have pushed it over). Behavior-preserving, idiomatic PHP 8.0+, flagged transparently in the task report. A structural split of PrettyReporter may be cleaner if WMC pressure recurs — out of scope for #17.

A method that forwards a param to the same callee via two distinct
call sites yields two findings (Option B, not deduped). They share
origin/param/terminal and differ only in the divergent hop's
forwardLine, which every reporter surfaces. The fingerprint is shared
by design (refactor-stable). Pins the emission rule against a future
accidental dedup regression.
Append '→N' (the forwarding call-site line) to each non-terminal
hop's location so findings that share origin/param/terminal but
differ in call site are distinguishable. Terminal hops keep the
plain 'file:line' form. Closes part of #17.
Same '→N' suffix as TextReporter; inherits the location style
through Styler::location(). Closes part of #17.
line= now uses forwardLine ?? hop->line so the annotation lands on
the forwarding call (the actionable line) rather than the method
declaration. The diff-aware changed-anchor selection is untouched.
Closes part of #17.
relatedLocations now use forwardLine ?? hop->line for region.startLine
so each hop's related location points at the forwarding call. The
origin locations[0] keeps the declaration line as the primary anchor.
Closes part of #17.
README examples now show the '→N' forwarding call-site suffix, with
a short explanation. docs/plan.md §2.3 (Branching) is amended to
cover the same-callee-multiple-call-site case explicitly: N findings,
shared fingerprint, distinguished by forwardLine. Clarification, not
a semantics change.
@larspohlmann
larspohlmann merged commit 5f591e8 into develop Aug 12, 2026
5 checks passed
@larspohlmann
larspohlmann deleted the feature/17-surface-forward-line branch August 12, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate findings when one method forwards a param to the same callee twice

1 participant