-
Notifications
You must be signed in to change notification settings - Fork 178
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
Conversation
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.
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
randomCompanyNameGenerator
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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.
Updated to account for the recent name change project |
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.