-
Notifications
You must be signed in to change notification settings - Fork 334
Dereference NPE Removals in MovementDisplay #6934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dereference NPE Removals in MovementDisplay #6934
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6934 +/- ##
============================================
+ Coverage 30.22% 30.31% +0.09%
- Complexity 15791 15807 +16
============================================
Files 2885 2886 +1
Lines 283320 283126 -194
Branches 49340 49326 -14
============================================
+ Hits 85633 85833 +200
+ Misses 192085 191694 -391
+ Partials 5602 5599 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixed CodeQL issues spotted in PR
|
|
||
| Coords targetCoords = new Coords(Integer.parseInt(target.nextToken()), | ||
| Integer.parseInt(target.nextToken())); | ||
| Coords targetCoords = new Coords(Integer.parseInt(target.nextToken()), Integer.parseInt(target.nextToken())); |
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException Note
|
|
||
| Coords targetCoords = new Coords(Integer.parseInt(target.nextToken()), | ||
| Integer.parseInt(target.nextToken())); | ||
| Coords targetCoords = new Coords(Integer.parseInt(target.nextToken()), Integer.parseInt(target.nextToken())); |
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException Note
|
Thats ALOT of whitespace change. |
|
EC Correction on Autosave when the ENUM was moved to it's own file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor style nits that don't need addressing.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the MovementDisplay code to clean up NPE issues by extracting MoveCommand into its own class and adding corresponding tests, along with updating related code and documentation.
- Extract MoveCommand enum from MovementDisplay into a dedicated file.
- Add unit tests in MoveCommandTest.java for command behaviors.
- Update ButtonOrderPreferences references and documentation to reflect the new organization.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| megamek/unittests/megamek/client/ui/swing/phaseDisplay/commands/MoveCommandTest.java | New test cases for verifying the behavior of the refactored MoveCommand enum. |
| megamek/src/megamek/client/ui/swing/phaseDisplay/commands/MoveCommand.java | Moves and refactors movement command logic into its own external class. |
| megamek/src/megamek/client/ui/swing/ButtonOrderPreferences.java | Updates to reference the new MoveCommand enum location. |
| megamek/docs/history.txt | Documentation update to record the changes in the movement display refactor. |
Comments suppressed due to low confidence (1)
megamek/src/megamek/client/ui/swing/phaseDisplay/commands/MoveCommand.java:93
- [nitpick] The command string for MOVE_EVADE is 'MoveEvade', which is inconsistent with other commands that use lower camel-case (e.g., 'moveNext'). Consider unifying the naming convention for clarity and consistency.
MOVE_EVADE("MoveEvade", MovementDisplay.CMD_MEK | MovementDisplay.CMD_TANK | MovementDisplay.CMD_VTOL),
|
|
||
| @Test | ||
| void testMoveRunHotKeyString() { | ||
| assertEquals("<BR> Toggle Move / Jump: J", MoveCommand.MOVE_WALK.getHotKeyDesc()); |
Copilot
AI
Apr 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test method 'testMoveRunHotKeyString' is using MOVE_WALK instead of a distinct move command, causing duplicate coverage. Consider updating the test to use the intended command (e.g., MOVE_JUMP) or renaming the test for clarity.
| assertEquals("<BR> Toggle Move / Jump: J", MoveCommand.MOVE_WALK.getHotKeyDesc()); | |
| assertEquals("<BR> Toggle Move / Jump: R", MoveCommand.MOVE_RUN.getHotKeyDesc()); |
|
Fixed the conflict and need one more set of reviews! (As much as I hate this part of the changes... I also respect the fact it is still required as any number of changes could be made.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This handles NPE cleanup of MovementDisplay. License updates, and overall codeQL cleanup.
Includes moving one internal class to external to better organize code.
Primary cleanup kept to main MovementDisplay class and new MovementCommand class that was pulled out.