8000 Fix: Fixed a Handful of Calls to Unsafe Faction Standing Getters by IllianiBird · Pull Request #7275 · MegaMek/mekhq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Fixed a Handful of Calls to Unsafe Faction Standing Getters #7275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025

Conversation

IllianiBird
Copy link
Collaborator

We should be using the safe variants, as that avoids needing to check whether faction standing is being tracked every time we call the getter

@IllianiBird IllianiBird self-assigned this Jun 24, 2025
@IllianiBird IllianiBird requested a review from a team as a code owner June 24, 2025 20:34
@IllianiBird IllianiBird added Bug Severity: Low Issues described as low severity as per the new issue form labels Jun 24, 2025
Copy link
codecov bot commented Jun 24, 2025

Codecov Report

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

Project coverage is 12.75%. Comparing base (825d04b) to head (1b6c80a).
Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
MekHQ/src/mekhq/campaign/Campaign.java 0.00% 2 Missing ⚠️
MekHQ/src/mekhq/campaign/mission/AtBContract.java 0.00% 1 Missing ⚠️
...aign/universe/factionStanding/PerformBatchall.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7275      +/-   ##
============================================
- Coverage     12.75%   12.75%   -0.01%     
  Complexity     7541     7541              
============================================
  Files          1148     1149       +1     
  Lines        147806   147820      +14     
  Branches      22593    22593              
============================================
+ Hits          18854    18855       +1     
- Misses       126935   126944       +9     
- Partials       2017     2021       +4     

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

@HammerGS HammerGS requested a review from Copilot June 25, 2025 19:26
Copy link
Contributor
@Copilot 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 replaces calls to the unsafe faction standing getters with their “Safe” variants to avoid repeated manual tracking checks.

  • Swapped isUseFactionStandingBatchallRestrictions() for isUseFactionStandingBatchallRestrictionsSafe() in batchall logic
  • Updated enemy and campaign jump path checks to use isUseFactionStandingBatchallRestrictionsSafe() and isUseFactionStandingOutlawedSafe()
  • Ensures all faction standing–based restrictions now use safe getters

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
MekHQ/src/mekhq/campaign/universe/factionStanding/PerformBatchall.java Use safe batchall restriction flag
MekHQ/src/mekhq/campaign/mission/AtBContract.java Switch to safe batchall restriction in enemy update
MekHQ/src/mekhq/campaign/Campaign.java Apply safe variants for batchall and outlawed checks
Comments suppressed due to low confidence (3)

MekHQ/src/mekhq/campaign/universe/factionStanding/PerformBatchall.java:95

  • Add a unit test covering the branch where isUseFactionStandingBatchallRestrictionsSafe() returns false to ensure batchall operations bypass the standing check as intended.
        if (campaign.getCampaignOptions().isUseFactionStandingBatchallRestrictionsSafe()) {

MekHQ/src/mekhq/campaign/mission/AtBContract.java:633

  • Introduce a test for the false case of isUseFactionStandingBatchallRestrictionsSafe() in updateEnemy(...) to verify that allowBatchalls remains true when restrictions are disabled.
            if (campaign.getCampaignOptions().isUseFactionStandingBatchallRestrictionsSafe()) {

MekHQ/src/mekhq/campaign/Campaign.java:5049

  • [nitpick] Consider adding or updating Javadoc on isUseFactionStandingBatchallRestrictionsSafe() to clarify how it differs from the legacy method and its default behavior.
                if (campaignOptions.isUseFactionStandingBatchallRestrictionsSafe()) {

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

# Conflicts:
#	MekHQ/src/mekhq/campaign/Campaign.java
@IllianiBird IllianiBird merged commit ae3518b into MegaMek:master Jul 1, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 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.

2 participants
0