-
Notifications
You must be signed in to change notification settings - Fork 334
fix: stop npe whe a board is missing to generate board for acar #7167
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
Conversation
There was a problem hiding this 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 aims to fix a NullPointerException that occurs when a board is missing by updating the logic for iterating through the boards array.
- Replaces a traditional for-loop with an iterator-based loop over the boards vector
- Introduces a null and empty check to skip invalid board names
| while (boardsIterator.hasNext()) { | ||
| String name = boardsIterator.next(); | ||
|
|
||
| if (name == null || name.isEmpty()) { |
Copilot
AI
May 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipping the increment of 'i' when a board name is null or empty might lead to misalignment between the iterator and the sheetBoards array indexes. Consider incrementing 'i' even when skipping an empty name or adjust the loop logic to ensure the sheetBoards array is populated correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats literally what I want to do here... 🤷🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot’s been struggling with these, it hit me with a bunch of false positives over a for loop where I used “i” the other day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not switch to a foreach instead of the iterator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I need the index.
|
Related issue MegaMek/mekhq#7121 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7167 +/- ##
============================================
+ Coverage 30.64% 30.65% +0.01%
- Complexity 17128 17150 +22
============================================
Files 2968 2968
Lines 289621 289627 +6
Branches 50488 50489 +1
============================================
+ Hits 88754 88797 +43
+ Misses 194267 194219 -48
- Partials 6600 6611 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fix: stop npe whe a board is missing to generate board for acar