Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rjhancock
Copy link
Collaborator

@rjhancock rjhancock commented Apr 26, 2025

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.

@codecov
Copy link

codecov bot commented Apr 26, 2025

Codecov Report

Attention: Patch coverage is 22.60692% with 380 lines in your changes missing coverage. Please review.

Project coverage is 30.31%. Comparing base (f19d894) to head (bca68e9).
Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
.../megamek/client/ui/swing/CommonSettingsDialog.java 0.00% 195 Missing ⚠️
megamek/src/megamek/client/ui/swing/MapMenu.java 0.00% 163 Missing ⚠️
...nt/ui/swing/phaseDisplay/commands/MoveCommand.java 84.73% 20 Missing ⚠️
...egamek/client/ui/swing/ButtonOrderPreferences.java 0.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Potential uncaught 'java.lang.NumberFormatException'.

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

Potential uncaught 'java.lang.NumberFormatException'.
@rjhancock rjhancock requested a review from a team as a code owner April 27, 2025 22:56
Scoppio
Scoppio previously approved these changes Apr 28, 2025
@Scoppio
Copy link
Collaborator

Scoppio commented Apr 28, 2025

Thats ALOT of whitespace change.

@rjhancock
Copy link
Collaborator Author

EC Correction on Autosave when the ENUM was moved to it's own file.

Sleet01
Sleet01 previously approved these changes Apr 29, 2025
Copy link
Collaborator

@Sleet01 Sleet01 left a 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!

@HammerGS HammerGS requested a review from Copilot April 29, 2025 18:49
Copy link
Contributor

Copilot AI left a 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>&nbsp;&nbsp;Toggle Move / Jump: J", MoveCommand.MOVE_WALK.getHotKeyDesc());
Copy link

Copilot AI Apr 29, 2025

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.

Suggested change
assertEquals("<BR>&nbsp;&nbsp;Toggle Move / Jump: J", MoveCommand.MOVE_WALK.getHotKeyDesc());
assertEquals("<BR>&nbsp;&nbsp;Toggle Move / Jump: R", MoveCommand.MOVE_RUN.getHotKeyDesc());

Copilot uses AI. Check for mistakes.
@rjhancock
Copy link
Collaborator Author

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.)

Copy link
Collaborator

@Sleet01 Sleet01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rjhancock rjhancock merged commit d8027d5 into MegaMek:master Apr 29, 2025
6 checks passed
@rjhancock rjhancock deleted the dereference-npe-removals branch May 23, 2025 04:06
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.

3 participants