Skip to content

Refactor mek hq unit selector#7085

Merged
Scoppio merged 31 commits into
MegaMek:masterfrom
savanik:refactorMekHQUnitSelector
May 25, 2025
Merged

Refactor mek hq unit selector#7085
Scoppio merged 31 commits into
MegaMek:masterfrom
savanik:refactorMekHQUnitSelector

Conversation

@savanik

@savanik savanik commented May 22, 2025

Copy link
Copy Markdown
Contributor

The MekHQUnitSelectorDialog had a lot of inconsistencies and bad design choices. This updates the code to add the 'buy' and 'add gm' buttons separately from the abstract class, correctly instantiates them during initialization, updates their state to match the desired states on init and during runtime changes, and logic was cleaned up in the 'include' function override. A LOT of documentation was added to clearly state what's going on. Still needs more documentation, likely.

@codecov

codecov Bot commented May 22, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 75 lines in your changes missing coverage. Please review.

Project coverage is 12.48%. Comparing base (0950a8d) to head (215cd93).
Report is 49 commits behind head on master.

Files with missing lines Patch % Lines
.../src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java 0.00% 75 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7085      +/-   ##
============================================
- Coverage     12.53%   12.48%   -0.05%     
  Complexity     7363     7363              
============================================
  Files          1128     1133       +5     
  Lines        145643   146220     +577     
  Branches      22394    22422      +28     
============================================
  Hits          18262    18262              
- Misses       125503   126082     +579     
+ Partials       1878     1876       -2     

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

@savanik savanik marked this pull request as ready for review May 23, 2025 17:21
@savanik savanik requested a review from a team as a code owner May 23, 2025 17:21
rjhancock
rjhancock previously approved these changes May 24, 2025

@rjhancock rjhancock left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks clean.

Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
@rjhancock rjhancock dismissed their stale review May 24, 2025 01:27

Wrong status.

@rjhancock rjhancock left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copyright header and the javadoc are the two fixes I spotted.

Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java Outdated
@HammerGS HammerGS requested a review from Copilot May 24, 2025 23:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors the MekHQ unit selector dialog by separating and properly managing the buy/add-GM buttons, cleaning up the filtering logic, and adding documentation.

  • Extracts buy and GM-add buttons from the abstract class and initializes them independently
  • Moves complex filtering logic into a new isAllowedUnit helper method
  • Adds Javadoc for key methods and cleans up the include override
Comments suppressed due to low confidence (2)

MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java:253

  • Rename parameter 'NoOP' to follow lowerCamelCase and convey its purpose (e.g. 'unused' or '_').
    protected void select(boolean NoOP) {

MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java:192

  • [nitpick] Consider renaming 'isBadSelection' to something like 'isInvalidSelection' for clearer intent.
    private boolean isBadSelection() {

Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java Outdated
Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
Comment thread MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
@Scoppio Scoppio merged commit fc68782 into MegaMek:master May 25, 2025
4 checks passed
@savanik savanik deleted the refactorMekHQUnitSelector branch May 25, 2025 06:33
@tapenvy-sentry

tapenvy-sentry Bot commented May 26, 2025

Copy link
Copy Markdown

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ ExecutionException: java.lang.NullPointerException mekhq.campaign.unit.UnitTechProgression in getP... View Issue
  • ‼️ ExecutionException: java.lang.NullPointerException mekhq.campaign.unit.UnitTechProgression in getP... View Issue
  • ‼️ ExecutionException: java.lang.NullPointerException mekhq.campaign.unit.UnitTechProgression in getP... View Issue
  • ‼️ ExecutionException: java.lang.NullPointerException mekhq.campaign.unit.UnitTechProgression in getP... View Issue
  • ‼️ ExecutionException: java.lang.NullPointerException mekhq.campaign.unit.UnitTechProgression in getP... View Issue

Did you find this useful? React with a 👍 or 👎

@savanik savanik restored the refactorMekHQUnitSelector branch May 27, 2025 03:31
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.

4 participants