Repository navigation
Warn when a state set is named like a method of its class - #516
Conversation
With a set named undo, a state error says undo(x) == undoable, which reads like a call to undo(). Warn about such names, rename the sets in the undo manager fixture to undoState/redoState, and advise against them in the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clean-code reviewAudit of this PR's own new code only (
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex
Skipping unnamed sets matches the stated intent. I did not run |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex round 1: fixed / declinedPushed with the clean-code fix. Full
|
CodexFinding: The inherited-method check can warn on a method that the annotated interface does not inherit. Spoon’s Concrete input: interface Parent {
static void reset() {}
}
@StateSet(name = "reset", value = {"fresh", "used"})
interface Child extends Parent {}
Test gap: The new external-spec test covers a method declared directly on I did not run tests or |
Codex round 2: fixed / declinedNothing changed in this round, so no push.
Codex's remaining findings are edge cases already declined, so the loop stops here (2 rounds). |
Closes #514
What and why
With named state sets, a set whose name is also a method name makes state errors read like method calls. With a set named
undo, the error saysexpected undo(undoManager) == undoable, which reads as "the result ofundoManager.undo()", the very call that failed. This is a confound for the error-message study.This PR:
@StateSetname is also the name of a method of its class. Inherited methods count too, sincex.undo()reads the same either way, except private methods of a superclass. For an@ExternalRefinementsForspec it checks the methods of the class the spec refines (this includes the methods declared in the spec). Sets without a name are not checked.state_hint_study_undo_manager_correctfromphase/undo/redotophase/undoState/redoState.Warning text
The example state is the first state of the set.
Before / after (real verifier output)
state_hint_study_undo_manager_errorfrom main, with its sets named as in the correct fixture. Only theUNDOerror is shown;REDOis the same.Before (main, sets
phase/undo/redo): no warning, and the error reads like a call.After (this branch, same names): two warnings on the set names, then the same errors.
After renaming to
phase/undoState/redoState: no warning, and the error no longer looks like a call.Tests
Three
// Expect: Warningcases and one no-warning case added to the existingErrorStateSetNamesfixture. Each one fails without the fix (main reports 6 diagnostics on the file, the fixture expects 9):ErrorStateSetNameOfAMethod: a setundoon a class with a methodundo().ErrorStateSetNameOfAnInheritedMethod: a setundoon a subclass that inheritsundo(). It also has a setresetwith no expected warning, because the superclass'sreset()is private (without that rule it warns once too many).ErrorStateSetNameOfAMethodOfTheTarget: an@ExternalRefinementsFor("java.util.ArrayList")spec with a setclear.The renamed undo manager fixture keeps passing with no warning. Full
mvn testpasses locally.🤖 Generated with Claude Code