Skip to content

Commit

Permalink
cleanup: Declaring a method parameter as final for an interface metho…
Browse files Browse the repository at this point in the history
…d is useless because the implementation may choose to not respect it.

https://docs.pmd-code.org/pmd-doc-7.9.0/pmd_rules_java_codestyle.html#finalparameterinabstractmethod
  • Loading branch information
firefly2442 committed Jan 10, 2025
1 parent f4b7479 commit 930f28f
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void setOffers(final List<UnitMarketOffer> offers) {
*
* @param campaign the campaign to process the Unit Market new day using
*/
public abstract void processNewDay(final Campaign campaign);
public abstract void processNewDay(Campaign campaign);

// region Generate Offers
/**
Expand All @@ -91,7 +91,7 @@ public void setOffers(final List<UnitMarketOffer> offers) {
*
* @param campaign the campaign to generate the unit offers for
*/
public abstract void generateUnitOffers(final Campaign campaign);
public abstract void generateUnitOffers(Campaign campaign);

/**
* This adds a number of unit offers
Expand All @@ -107,8 +107,8 @@ public void setOffers(final List<UnitMarketOffer> offers) {
* @param quality the quality of the unit to generate
* @param priceTarget the target number used to determine the percent
*/
public abstract void addOffers(final Campaign campaign, final int number, UnitMarketType market, final int unitType,
@Nullable Faction faction, final int quality, final int priceTarget);
public abstract void addOffers(Campaign campaign, int number, UnitMarketType market, int unitType,
@Nullable Faction faction, int quality, int priceTarget);

/**
* @param campaign the campaign to use to generate the unit
Expand Down Expand Up @@ -214,8 +214,8 @@ public String addSingleUnit(final Campaign campaign, final UnitMarketType market
* @param faction the faction to generate the weight for
* @return the generated weight
*/
protected abstract int generateWeight(final Campaign campaign, final int unitType,
final Faction faction);
protected abstract int generateWeight(Campaign campaign, int unitType,
Faction faction);

/**
* @param campaign the campaign to use to generate the transit duration
Expand Down Expand Up @@ -244,7 +244,7 @@ protected void writeRefreshReport(final Campaign campaign) {
*
* @param campaign the campaign to use in determining the offers to remove
*/
protected abstract void removeUnitOffers(final Campaign campaign);
protected abstract void removeUnitOffers(Campaign campaign);

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'campaign' is never used.
// endregion Offer Removal
// endregion Process New Day

Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/parts/Part.java
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ protected boolean isClanTechBase() {
return getTechBase() == TECH_BASE_CLAN;
}

public abstract void writeToXML(final PrintWriter pw, int indent);
public abstract void writeToXML(PrintWriter pw, int indent);

protected int writeToXMLBegin(final PrintWriter pw, int indent) {
MHQXMLUtility.writeSimpleXMLOpenTag(pw, indent++, "part", "id", id, "type", getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public boolean processNewDay(final Campaign campaign, final LocalDate today,
* @param gender the person's gender
* @return true if the person is selected to randomly die, otherwise false
*/
public abstract boolean randomlyDies(final int age, final Gender gender);
public abstract boolean randomlyDies(int age, Gender gender);
// endregion Random Death
// endregion New Day

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void setSkillPreferences(RandomSkillPreferences skillPreferences) {
* @param expLvl The experience level of the person (e.g.
* {@link SkillType#EXP_GREEN}).
*/
public abstract void generateSkills(final Campaign campaign, final Person person, final int expLvl);
public abstract void generateSkills(Campaign campaign, Person person, int expLvl);

/**
* Generates the default skills for a {@link Person} based on their primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ public void setSkillPreferences(RandomSkillPreferences skillPreferences) {
* @param expLvl The experience level of the person (e.g. {@link SkillType#EXP_GREEN}).
* @return A value indicating whether or not a special ability was assigned.
*/
public abstract boolean generateSpecialAbilities(final Campaign campaign, final Person person, final int expLvl);
public abstract boolean generateSpecialAbilities(Campaign campaign, Person person, int expLvl);
}
Original file line number Diff line number Diff line change
Expand Up @@ -600,5 +600,5 @@ protected boolean randomlyProcreates(final LocalDate today, final Person person)
* @param person the person to determine for
* @return true if they do, otherwise false
*/
protected abstract boolean procreation(final Person person);
protected abstract boolean procreation(Person person);
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected EquipmentProposal createProposal() {

protected abstract List<UnscrambleStep> createSteps();

protected abstract @Nullable String createReport(final EquipmentProposal proposal);
protected abstract @Nullable String createReport(EquipmentProposal proposal);

public static EquipmentUnscrambler create(final Unit unit) {
Objects.requireNonNull(unit, "Unit must not be null");
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/unit/cleanup/UnscrambleStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import mekhq.campaign.parts.equipment.MissingEquipmentPart;

public abstract class UnscrambleStep {
public abstract void visit(final EquipmentProposal proposal, final EquipmentPart part);
public abstract void visit(EquipmentProposal proposal, EquipmentPart part);

public void visit(final EquipmentProposal proposal, final MissingEquipmentPart part) {

Expand Down
22 changes: 11 additions & 11 deletions MekHQ/src/mekhq/campaign/universe/IUnitGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static boolean unitTypeSupportsWeightClass(final int unitType) {
* @param unitType UnitType constant
* @return true if the generator supports the unit type
*/
boolean isSupportedUnitType(final int unitType);
boolean isSupportedUnitType(int unitType);

/**
* Generate a single unit.
Expand Down Expand Up @@ -170,9 +170,9 @@ static boolean unitTypeSupportsWeightClass(final int unitType) {
* @param filter All generated units return true when the filter function is applied.
* @return A unit that matches the criteria
*/
@Nullable MekSummary generate(final String faction, final int unitType, final int weightClass, final int year,
final int quality, final Collection<EntityMovementMode> movementModes,
final Collection<MissionRole> missionRoles, @Nullable Predicate<MekSummary> filter);
@Nullable MekSummary generate(String faction, int unitType, int weightClass, int year,
int quality, Collection<EntityMovementMode> movementModes,
Collection<MissionRole> missionRoles, @Nullable Predicate<MekSummary> filter);

/**
* Generates a list of units.
Expand Down Expand Up @@ -261,10 +261,10 @@ default List<MekSummary> generate(final int count, final String faction, final i
* @param filter All generated units return true when the filter function is applied.
* @return A list of units matching the criteria.
*/
@Nullable List<MekSummary> generate(final int count, final String faction, final int unitType,
final int weightClass, final int year, final int quality,
final Collection<EntityMovementMode> movementModes,
final Collection<MissionRole> missionRoles,
@Nullable List<MekSummary> generate(int count, String faction, int unitType,
int weightClass, int year, int quality,
Collection<EntityMovementMode> movementModes,
Collection<MissionRole> missionRoles,
@Nullable Predicate<MekSummary> filter);

/**
Expand All @@ -274,7 +274,7 @@ default List<MekSummary> generate(final int count, final String faction, final i
* @param parameters data structure containing unit generation parameters
* @return The generated unit, or null if none are generated.
*/
@Nullable MekSummary generate(final UnitGeneratorParameters parameters);
@Nullable MekSummary generate(UnitGeneratorParameters parameters);

/**
* Generates the given count of units to be used in an OpFor using the given set of parameters.
Expand All @@ -284,7 +284,7 @@ default List<MekSummary> generate(final int count, final String faction, final i
* @param parameters data structure containing unit generation parameters
* @return List of generated units. Empty if none are generated.
*/
List<MekSummary> generate(final int count, final UnitGeneratorParameters parameters);
List<MekSummary> generate(int count, UnitGeneratorParameters parameters);

/**
* Generates a list of turrets given a skill level, quality and year
Expand All @@ -294,5 +294,5 @@ default List<MekSummary> generate(final int count, final String faction, final i
* @param currentYear The current year
* @return List of turrets
*/
List<MekSummary> generateTurrets(final int num, final SkillLevel skill, final int quality, final int currentYear);
List<MekSummary> generateTurrets(int num, SkillLevel skill, int quality, int currentYear);

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'skill' is never used.
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ public BattleMekQualityGenerationMethod getMethod() {
* @param roll the modified roll to use
* @return the generated IUnitRating magic int for Dragoon Quality
*/
public abstract int generate(final int roll);
public abstract int generate(int roll);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ public BattleMekWeightClassGenerationMethod getMethod() {
* signify no generation and EntityWeightClass.WEIGHT_SUPER_HEAVY to signify Star League-era
* generation.
*/
public abstract int generate(final int roll);
public abstract int generate(int roll);
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ private void generateCommandingOfficer(final Campaign campaign,
* @param numMekWarriors the number of MekWarriors in their force, used to
* determine their rank
*/
protected abstract void generateCommandingOfficerRank(final Faction faction,
final CompanyGenerationPersonTracker tracker,
final int numMekWarriors);
protected abstract void generateCommandingOfficerRank(Faction faction,
CompanyGenerationPersonTracker tracker,
int numMekWarriors);

/**
* This generates the initial officer list and assigns the type
Expand Down Expand Up @@ -953,9 +953,9 @@ private void generateEntity(final Campaign campaign,
* @return the MekSummary generated from the provided parameters, or null if
* generation fails
*/
protected abstract @Nullable MekSummary generateMekSummary(final Campaign campaign,
final AtBRandomMekParameters parameters,
final Faction faction);
protected abstract @Nullable MekSummary generateMekSummary(Campaign campaign,
AtBRandomMekParameters parameters,
Faction faction);

/**
* @param campaign the campaign to generate for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public List<Part> generate(final List<Part> inputParts) {
* unassigned. Implementors are required to clone the parts as required.
* @return a warehouse containing the generated parts
*/
public abstract Warehouse generateWarehouse(final List<Part> inputParts);
public abstract Warehouse generateWarehouse(List<Part> inputParts);

/**
* This creates a clone of the input part, with it not being omni-podded if it was originally.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void setOptionsDirect(final RandomOriginOptions options) {
* @param campaign The {@link Campaign} within which this {@link Faction} exists.
* @return A {@link Faction} selected for {@code campaign}.
*/
public abstract @Nullable Faction selectFaction(final Campaign campaign);
public abstract @Nullable Faction selectFaction(Campaign campaign);

/**
* Clears any cache associated with faction selection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public void setOptionsDirect(final RandomOriginOptions options) {
* @param campaign The {@link Campaign} to use when selecting a planet.
* @return A {@link Planet} or {@code null}.
*/
public abstract @Nullable Planet selectPlanet(final Campaign campaign);
public abstract @Nullable Planet selectPlanet(Campaign campaign);

/**
* Select a {@link Planet} for a {@link Campaign} and optional {@link} Faction.
* @param campaign The {@link Campaign} to use when selecting a planet.
* @param faction An optional {@link Faction} to use when selecting a planet.
* @return A {@link Planet} or {@code null}.
*/
public abstract @Nullable Planet selectPlanet(final Campaign campaign, final @Nullable Faction faction);
public abstract @Nullable Planet selectPlanet(Campaign campaign, @Nullable Faction faction);

/**
* Clears any cache associated with planet selection.
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/module/api/MekHQModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public interface MekHQModule {
void initPlugin(Campaign c);

void loadFieldsFromXml(Node node);
void writeToXML(final PrintWriter pw, int indent);
void writeToXML(PrintWriter pw, int indent);

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'pw' is never used.

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'indent' is never used.
}

0 comments on commit 930f28f

Please sign in to comment.