Avoid duplicate Truth migration comments - #1087
Draft
martinfrancois wants to merge 2 commits into
Draft
Conversation
4 tasks
martinfrancois
force-pushed
the
repro/truth-flagging-idempotence
branch
from
August 15, 2026 23:22
43b0e3b to
bd53941
Compare
martinfrancois
force-pushed
the
repro/truth-flagging-idempotence
branch
from
August 16, 2026 02:53
bd53941 to
675cd94
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Suggested review order: 26 of 52 (Score: 5)
Review first: #1096
What's changed?
TruthAssertToAssertThatandTruthCustomSubjectsToAssertJnow add a normal block comment through theCommentstrait. The trait recognizes an equivalent existing comment, so later recipe cycles leave the warning unchanged.Each focused test runs its recipe for two cycles and requires exactly one changing cycle. This verifies both the first-run warning and idempotence without a recipe-specific comment parser.
What's your motivation?
Recipes:
TruthAssertToAssertThatandTruthCustomSubjectsToAssertJ.I confirmed the released behavior by running
org.openrewrite.java.testing.truth.TruthAssertToAssertThatfromrewrite-testing-frameworks:3.44.0on Glide at36a7b2ec. The affected file islibrary/test/src/test/java/com/bumptech/glide/tests/KeyTester.java.After the first run, the recipe correctly flags the unsupported Truth assertion:
Before
Actual after the recipe
Expected after the recipe
The same defect affects
TruthCustomSubjectsToAssertJand itsassertAbout(...)warning. Every later run adds another identical comment. A recipe run over its own persisted warning MUST leave that warning unchanged.Confirmed real-world execution
KeyTester.javaat36a7b2ec.org.openrewrite.recipe:rewrite-testing-frameworks:3.44.0.The first execution adds the manual-migration warning. The second execution adds the same warning again instead of leaving the persisted result unchanged.
Anything in particular you'd like reviewers to focus on?
Please review the use of the shared
Commentstrait and the decision to emit a normal block comment instead of a rendered search marker. An equivalent warning on the matching invocation MUST suppress another insertion; unrelated comments MUST NOT.Have you considered any alternatives or workarounds?
Removing duplicate comments after every migration run hides the non-idempotent behavior and creates repeated cleanup work. A recipe-specific parser for rendered search-marker text also duplicates the shared comment service's equivalence behavior.
Any additional context
Pre-existing tests changed: None.
org.openrewrite.recipe:rewrite-testing-frameworks:3.44.0martinfrancois/rewrite-testing-frameworks:repro/truth-flagging-idempotenceTruthAssertToAssertThatTestandTruthCustomSubjectsToAssertJTest; each contains one two-cycle test./gradlew buildThis change was prepared with AI assistance. I reviewed the real-project execution evidence, implementation, tests, generated output, and contribution text.
Checklist
./gradlew buildlocally, and committed any resulting changes torecipes.csv