Skip to content
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

Refactored Random Company Name Generator to Use CSV #4655

Merged
merged 7 commits into from
Sep 13, 2024

Conversation

IllianiCBT
Copy link
Collaborator

This PR switches the random company name generator from using enum-based values to using a handful of csv files, similar to how we handle Bloodnames and Callsigns. This means users can edit and customize the available pool of name segments, with full support for the user folder.

Deleted the EndWordCorporate, EndWordMercenary, MiddleWordCorporate, and MiddleWordMercenary classes. These classes were redundant and no longer needed for the current functionality of the application.
Added new CSV files for the RandomCompanyNameGenerator, including endWordCorporate, preFab, and middleWordCorporate. These files will be used to generate random corporate and mercenary company names within the MekHQ universe.
Introduced RandomCompanyNameGenerator to generate random company names with configurable word segments. Integrated this generator within the data loading process and associated GUI components in MekHQ.
Added a try-catch block to handle potential NullPointerExceptions in the randomMercenaryCompanyNameGenerator method. Simplified the getCommanderName method by removing an unnecessary try-catch block.
@IllianiCBT IllianiCBT added Refactoring UX User experience labels Aug 16, 2024
@IllianiCBT IllianiCBT self-assigned this Aug 16, 2024
if (randomCompanyNameGenerator == null) { // First check
synchronized (RandomCompanyNameGenerator.class) {
if (randomCompanyNameGenerator == null) { // Double check
randomCompanyNameGenerator = new RandomCompanyNameGenerator();

Check warning

Code scanning / CodeQL

Race condition in double-checked locking object initialization Warning

Potential race condition. This assignment to
randomCompanyNameGenerator
is visible to other threads before the subsequent statements are executed.
@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 9.86%. Comparing base (2dbc50b) to head (790edcd).
Report is 36 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4655      +/-   ##
============================================
- Coverage     10.76%    9.86%   -0.91%     
+ Complexity     5668     5645      -23     
============================================
  Files           948      944       -4     
  Lines        132553   131356    -1197     
  Branches      19048    19055       +7     
============================================
- Hits          14272    12956    -1316     
- Misses       117041   117163     +122     
+ Partials       1240     1237       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@IllianiCBT IllianiCBT marked this pull request as draft August 21, 2024 17:15
@IllianiCBT
Copy link
Collaborator Author

Flipped this to draft, so it can't be accidentally merged into 50.0

# Conflicts:
#	MekHQ/resources/mekhq/resources/RandomMercenaryCompanyNameGenerator.properties
#	MekHQ/src/mekhq/campaign/personnel/backgrounds/BackgroundsController.java
#	MekHQ/src/mekhq/campaign/personnel/backgrounds/enums/mercenaryCompanyNameGenerator/PreFabHumorous.java
#	MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java
Reorganized and removed unused imports to improve code readability and maintainability. Static imports for methods were added for clarity.
@IllianiCBT IllianiCBT marked this pull request as ready for review September 13, 2024 20:08
@IllianiCBT
Copy link
Collaborator Author

Updated to account for the recent name change project

@IllianiCBT IllianiCBT merged commit a19cf37 into MegaMek:master Sep 13, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants