Skip to content

Collapse the purity.not.* message-key variants into purity.* - #8242

Merged
mernst merged 18 commits into
typetools:masterfrom
mernst:purity-shorter-message-keys
Sep 23, 2026
Merged

mernst merged 18 commits into
typetools:masterfrom
mernst:purity-shorter-message-keys

Conversation

@mernst

@mernst mernst commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Merge together:
#8242
typetools/jdk#298
plume-lib/bcel-util#584
plume-lib/javac-parse#312
plume-lib/merging#397
plume-lib/plume-util#786
plume-lib/reflection-util#545

Rename the message keys purity.not.deterministic.X, purity.not.sideeffectfree.X, and purity.not.deterministic.not.sideeffectfree.X to purity.X. The required purity, and for purity.call the adjective describing the callee, become message arguments, so every rendered message is unchanged.

Build the message key from a switch over the reasons, so that each key is a literal that the CompilerMessages checker verifies; this removes a @SuppressWarnings("compilermessages").

This breaks existing warning suppressions that use the old keys.

Rename the message keys purity.not.deterministic.X, purity.not.sideeffectfree.X,
and purity.not.deterministic.not.sideeffectfree.X to purity.X.  The required
purity, and for purity.call the adjective describing the callee, become message
arguments, so every rendered message is unchanged.

Build the message key from a switch over the reasons, so that each key is a
literal that the CompilerMessages checker verifies; this removes a
@SuppressWarnings("compilermessages").

This breaks existing warning suppressions that use the old keys, so bump the
version to 4.3.0.
Adapt reportPurityError() to the new ImpurityReason record, and update the
purity message keys in the tests that upstream added.
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: typetools/checker-framework/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: ddd64bf3-6552-4212-a159-219a81dee7fb

📥 Commits

Reviewing files that changed from the base of the PR and between d23748a and 3500643.

📒 Files selected for processing (1)
  • framework/tests/purity-checker/PurityCheckerChecksAnnotations.java

Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The Purity Checker now reports violations with generalized purity.* diagnostic keys. BaseTypeVisitor maps standard and custom violations to these keys, and message templates include purity and callee details. The message catalog and changelog document the renamed keys. Purity tests and suppression annotations now expect the generalized keys across calls, assignments, object creation, and catches.

Merge Risk: ⚪ Minimal · up to 35006

Purity diagnostics now use the unified keys, with updated tests and documentation. No material merge risk remains.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 75 functions across 15 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Use the message key "purity.<reason>" for a purity violation reason that
PurityChecker does not produce, rather than throwing BugInCF.  A checker that
records its own reason via PurityResult.addNotDetReason, addNotSEFreeReason, or
addNotBothReason defines the key in its own messages.properties file.

In Issue951.java, put each of two purity.call errors on its own line.  The two
errors previously had distinct message keys; now that both keys are purity.call,
two expected diagnostics on one line collapse into one, because TestDiagnostic
equality ignores the message text.

In the changelog, state that a suppression that uses an old key silently stops
working, and that the new key cannot distinguish the purity property that the
method failed to have.
Track the enclosing type to compare in a single nullable variable, so that
the nullness checker can relate the null check to the use.
smillst
smillst previously approved these changes Sep 23, 2026
@smillst smillst assigned mernst and unassigned smillst Sep 23, 2026
@mernst mernst changed the title Collapse the purity.not.* message-key variants into purity.* Collapse the purity.not.* message-key variants into purity.* Sep 23, 2026
@mernst
mernst merged commit 1f1de5b into typetools:master Sep 23, 2026
26 checks passed
@mernst
mernst deleted the purity-shorter-message-keys branch September 23, 2026 21:25
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