A-Assertions: Assert the assumptions the code relies on - #5
Merged
Merged
Conversation
Several classes rely on a guarantee made elsewhere without saying so. If a later change breaks one of these guarantees, the failure appears far from its cause, as a confusing reply or a NullPointerException. Let's state each assumption with an assert whose message names what guarantees it: * Parser.parse never sees blank input, as Ted skips it * Storage.parseLine never sees a blank line, as load() skips them, and never reaches its default branch, as fieldCountFor accepts only T, D and E * TaskList is never given null, as Storage.load() skips unreadable lines instead of adding null * Ted always has a task list, as the constructor makes an empty one when loading fails * MainWindow always has a Ted, as Main calls setTed before showing the window Let's also enable assertions for gradle run, as Java ignores them by default. Tests already run with assertions on. Checks on user input stay as exceptions, because bad input is expected and must be reported even with assertions off. For the same reason there is no assert that an event ends after it starts: the parser rejects such an event, but a hand-edited save file can still hold one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Increment: A-Assertions
assertstatements for assumptions one part of Ted makes about another, each with a message naming what guarantees it:Parser#parse,Storage#parseLine, theTaskListconstructor,Ted#getResponseandMainWindow#handleUserInput.gradle run. Tests already run with them on.🤖 Generated with Claude Code