Skip to content

Conversation

@psikomonkie
Copy link
Member

Sorry... This is a pretty big refactor. But I hope it'll be worth it.

Campaign Operations refers to the organization structure that units are in as a "Formation", not a "Force". Campaign Operations generally uses "Force" to refer to all of the players assets. This refactor is to bring MekHQ's terminology closer in line with Campaign Operations & to free up the class name Force.

There's still places that refer to a "Formation" as a "Force". We use the word "Force" a lot in the code, and many of those usages are still accurate - referring to the entire player force, or the verb used in properties files. This will be an ongoing cleanup task, I believe, to replace instances of Force with Formation, as appropriate.

@psikomonkie psikomonkie added Refactoring Severity: Low Issues described as low severity as per the new issue form labels Jan 2, 2026

if (campaignOptions.isUseAtB() && force.getUnits().isEmpty()) {
combatTeams.remove(force.getId());
if (campaignOptions.isUseAtB() && formation.getUnits().isEmpty()) {

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
CampaignOptions.isUseAtB
should be avoided because it has been deprecated.
}

private static void processUnitNodes(Force retVal, Node wn, Version version) {
private static void processUnitNodes(Formation retVal, Node wn, Version version) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'version' is never used.

// region Getters/Setters
public Map<LayeredForceIconLayer, List<ForcePieceIcon>> getPieces() {
public Map<LayeredFormationIconLayer, List<FormationPieceIcon>> getPieces() {

Check notice

Code scanning / CodeQL

Exposing internal representation Note

getPieces exposes the internal representation stored in field pieces. The value may be modified
after this call to getPieces
.
getPieces exposes the internal representation stored in field pieces. The value may be modified
after this call to getPieces
.
getPieces exposes the internal representation stored in field pieces. The value may be modified
after this call to getPieces
.
getPieces exposes the internal representation stored in field pieces. The value may be modified
after this call to getPieces
.
*/
public boolean isUnitInForce(UUID unitId, Force force, Campaign campaign) {
Vector<UUID> unitIds = force.getAllUnits(false);
public boolean isUnitInForce(UUID unitId, Formation formation, Campaign campaign) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'campaign' is never used.
Force force = gui.getCampaign().getForce(Integer.parseInt(forceId));
if (null != force) {
forces.add(force);
Formation formation = gui.getCampaign().getForce(Integer.parseInt(forceId));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
}
if (type.equals("FORCE")) {
force = gui.getCampaign().getForce(Integer.parseInt(id));
formation = gui.getCampaign().getForce(Integer.parseInt(id));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
if (type.equals("FORCE")) {
force = gui.getCampaign().getForce(Integer.parseInt(id));
if (force == null || force.isDeployed()) {
formation = gui.getCampaign().getForce(Integer.parseInt(id));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
gbc.gridx++;
add(new MMButton("btnExport", resources, "Export.text",
"LayeredForceIconCreationPanel.btnExport.toolTipText", evt -> exportAction()), gbc);
"LayeredFormationIconCreationPanel.btnExport.toolTipText", evt -> exportAction()), gbc);

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'evt' is never used.
@codecov
Copy link

codecov bot commented Jan 2, 2026

Codecov Report

❌ Patch coverage is 5.98540% with 1288 lines in your changes missing coverage. Please review.
✅ Project coverage is 12.50%. Comparing base (37c7f9e) to head (d6a2cef).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java 0.00% 146 Missing ⚠️
MekHQ/src/mekhq/campaign/force/Formation.java 24.52% 77 Missing and 3 partials ⚠️
MekHQ/src/mekhq/campaign/Campaign.java 5.88% 63 Missing and 1 partial ⚠️
...rs/companyGenerators/AbstractCompanyGenerator.java 0.00% 64 Missing ⚠️
MekHQ/src/mekhq/gui/BriefingTab.java 0.00% 49 Missing ⚠️
MekHQ/src/mekhq/campaign/force/CombatTeam.java 0.00% 48 Missing ⚠️
...ekhq/gui/panels/CompanyGenerationOptionsPanel.java 0.00% 45 Missing ⚠️
.../mekhq/campaign/stratCon/StratConRulesManager.java 0.00% 44 Missing ⚠️
...kHQ/src/mekhq/gui/dialog/CampaignExportWizard.java 0.00% 44 Missing ⚠️
MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java 0.00% 33 Missing ⚠️
... and 93 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8627      +/-   ##
============================================
+ Coverage     12.48%   12.50%   +0.01%     
- Complexity     7553     7558       +5     
============================================
  Files          1294     1294              
  Lines        166215   166215              
  Branches      25055    25055              
============================================
+ Hits          20758    20779      +21     
+ Misses       143455   143437      -18     
+ Partials       2002     1999       -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactoring Severity: Low Issues described as low severity as per the new issue form

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant