Skip to content

Report outdated annotations on a plain run, not only with --remove#448

Merged
dereuromark merged 1 commit into
masterfrom
report-stale-annotations
May 18, 2026
Merged

Report outdated annotations on a plain run, not only with --remove#448
dereuromark merged 1 commit into
masterfrom
report-stale-annotations

Conversation

@dereuromark
Copy link
Copy Markdown
Owner

Summary

Outdated-annotation detection was gated entirely behind --remove. A normal annotate run therefore silently ignored stale docblock lines — users only discovered cruft if they happened to run the destructive flag (and then it was deleted, not reported).

This makes detection always run:

  • --remove — unchanged: deletes the outdated lines.
  • plain run — counts what -r would prune and prints -> N annotations outdated (run with -r to remove); verbose (-v) names each line.

No file is modified and the exit code is unchanged on a plain run, so it is purely additive and non-breaking. Clean projects stay silent — the line is only emitted when the count is non-zero.

Why no opt-in flag

The first iteration added a --warn-stale flag. Dropped it: a flag defeats discoverability (users who do not know to pass it never see the cruft, which is the whole point), and the output is non-destructive informational text. Making it the default is the useful behaviour — analogous to how git status always surfaces untracked files. The only cost is that in-use detection now runs on plain runs too; acceptable for a dev/CI tool where "helpful and correct" beats micro-perf.

Truthfulness

The in-use and parent-superseded checks are no longer conditional on --remove either. The report must apply the exact same filter chain (in-use heuristic, description-skip, generated-tag set, and the parent-superseded bypass) as actual removal — otherwise it would cry wolf about lines -r would in fact keep.

Tests

  • AbstractAnnotatorTest::testReportSurfacesRemovableCount asserts report() emits the count.
  • Full suite green (297), composer stan clean, composer cs-check clean.
  • Verified end-to-end on a real app: a plain annotate models over a table carrying stale overrides prints -> 7 annotations outdated (run with -r to remove) (and -v lists each), leaving the file untouched; -r still deletes them.

Possible follow-ups (not in this PR)

  • A CI gate (extend --ci to fail when removable orphans exist) so teams can block on docblock cruft without ever running destructive removal.
  • Per-line provenance in the verbose listing (e.g. "not in generated set" vs "superseded by parent generic").

Previously the outdated-annotation detection was gated entirely behind
--remove, so a normal "annotate" run silently ignored stale docblock
lines and users only discovered cruft if they happened to run the
destructive flag.

Detection now always runs. --remove still deletes (unchanged); a plain
run instead counts the would-remove annotations and prints
"N annotations outdated (run with -r to remove)" (verbose mode names
each line). No file is modified and the exit code is unchanged, so the
behaviour is purely additive and non-breaking; clean projects stay
silent because the line is only emitted when the count is non-zero.

The in-use / parent-superseded detection is no longer conditional on
--remove either, since the report must apply the exact same filter
chain to be truthful about what -r would actually prune.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 18, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.56%. Comparing base (cb1648c) to head (ede3fed).

Files with missing lines Patch % Lines
src/Annotator/AbstractAnnotator.php 97.05% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #448      +/-   ##
============================================
+ Coverage     84.55%   84.56%   +0.01%     
- Complexity     2217     2220       +3     
============================================
  Files           122      122              
  Lines          5893     5904      +11     
============================================
+ Hits           4983     4993      +10     
- Misses          910      911       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark merged commit a42af9f into master May 18, 2026
16 checks passed
@dereuromark dereuromark deleted the report-stale-annotations branch May 18, 2026 23:21
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.

2 participants