Skip to content

Commit

Permalink
Refit - Fix a couple of CodeQL issues
Browse files Browse the repository at this point in the history
  • Loading branch information
WeaverThree committed Nov 7, 2024
1 parent 716d11c commit 388676a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion MekHQ/src/mekhq/campaign/unit/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,6 @@ public Part getHeatSinkExample() {
* not work on small craft and larger because they hide their heatsinks in an available
* Spacecraft Cooling System Part.
*
* @param entity Either the starting or the ending unit of the refit.
* @return The number of heat sinks the unit mounts that are not tracked as parts.
*/
public Part getUntrackedHeatSinks () {
Expand Down
16 changes: 8 additions & 8 deletions MekHQ/src/mekhq/gui/dialog/ChooseRefitDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ public static int getActualQuantity(Part part) {
}
}

public int getToOrder(Part part) {
PartInventory inventory = campaign.getPartInventory(part);
public static int getToOrder(Part part) {
PartInventory inventory = part.getCampaign().getPartInventory(part);
return Math.max(0, getActualQuantity(part)
- inventory.getSupply()
- inventory.getTransit()
Expand Down Expand Up @@ -689,7 +689,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole

// region Needed Model

public class RefitNeededListTableModel extends AbstractTableModel {
public static class RefitNeededListTableModel extends AbstractTableModel {
public final static int COL_NEEDED = 0;
public final static int COL_NAME = 1;
public final static int COL_TECH_BASE = 2;
Expand Down Expand Up @@ -752,7 +752,7 @@ public Object getValueAt(int row, int col) {
} else {
part = (Part) data.get(row);
}

Campaign campaign = part.getCampaign();
return switch(col) {
case COL_NAME -> "<html><nobr>"
+ part.getName() + ReportingUtilities.surroundIf(" (", part.getDetails(), ")")
Expand Down Expand Up @@ -800,7 +800,7 @@ public String getTooltip(int row, int col) {
part = data.get(row);
}
return switch (col) {
case COL_TARGET -> campaign.getTargetForAcquisition(part.getAcquisitionWork()).getDesc();
case COL_TARGET -> part.getCampaign().getTargetForAcquisition(part.getAcquisitionWork()).getDesc();
default -> null;
};
}
Expand All @@ -826,7 +826,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole

// region Returns Model

public class RefitReturnsListTableModel extends AbstractTableModel {
public static class RefitReturnsListTableModel extends AbstractTableModel {
public final static int COL_RECEIVING = 0;
public final static int COL_NAME = 1;
public final static int COL_TECH_BASE = 2;
Expand Down Expand Up @@ -885,7 +885,7 @@ public Object getValueAt(int row, int col) {
+ part.getName() + ReportingUtilities.surroundIf(" (", part.getDetails(), ")")
+ "</nobr></html>";
case COL_TECH_BASE -> part.getTechBaseName();
case COL_STOCK -> campaign.getPartInventory(part).getSupply();
case COL_STOCK -> part.getCampaign().getPartInventory(part).getSupply();
case COL_RECEIVING -> getActualQuantity(part);
case COL_VALUE -> part.getActualValue().multipliedBy(part.getQuantity()).toAmountAndSymbolString();
default -> "?";
Expand Down Expand Up @@ -935,7 +935,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole

// region Steps Model

public class RefitStepsListTableModel extends AbstractTableModel {
public static class RefitStepsListTableModel extends AbstractTableModel {
public final static int COL_OLD_NAME = 0;
public final static int COL_OLD_LOC = 1;
public final static int COL_OLD_QUANTITY = 2;
Expand Down

0 comments on commit 388676a

Please sign in to comment.