-
Notifications
You must be signed in to change notification settings - Fork 295
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
Fixing all Assert Usages #3615
Fixing all Assert Usages #3615
Conversation
…ding exceptions to methods calls
…ss necessary view
…I made in the Preference setup by using asserts
Codecov Report
@@ Coverage Diff @@
## master #3615 +/- ##
============================================
- Coverage 23.63% 23.63% -0.01%
+ Complexity 4811 4807 -4
============================================
Files 2204 2204
Lines 242385 242389 +4
Branches 45417 45394 -23
============================================
- Hits 57293 57292 -1
- Misses 183628 183642 +14
+ Partials 1464 1455 -9
Continue to review full report at Codecov.
|
This is ready for review |
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.
A couple of questions.
skinEditPanel.setupSkinEditPanel(skinSpec); | ||
editPanel.add(skinEditPanel); | ||
} catch (Exception ignored) { | ||
|
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.
?
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.
If you mean the tear out note, it was a code misread.
Otherwise... there's a potential exception that can be thrown, but in all likelihood won't. I'll be doing a full look at catches in the future, and will probably change it then.
megamek/src/megamek/common/weapons/CapitalMissileBearingsOnlyHandler.java
Show resolved
Hide resolved
*/ | ||
protected void setCustomPreferences(final PreferencesNode preferences) { | ||
protected void setCustomPreferences(final PreferencesNode preferences) throws Exception { |
Check notice
Code scanning / CodeQL
Useless parameter
*/ | ||
protected void setCustomPreferences(final PreferencesNode preferences) { | ||
protected void setCustomPreferences(final PreferencesNode preferences) throws Exception { |
Check notice
Code scanning / CodeQL
Useless parameter
indices[i] = Integer.parseInt(strings[i]); | ||
} | ||
setSelectedIndices(indices); | ||
setSelectedIndices(Arrays.stream(strings).mapToInt(Integer::parseInt).toArray()); |
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException
Asserts do not work properly outside of isolated builds, so this fixes all assert uses outside of the net setup (which will be in the network rework instead). This largely removes the unused calls, only moving them to actual error handling when the call should be required.
The main changes are in the Preference setup, which uses asserts as part of the core design. Otherwise, there's a lot of cleanup in otherwise untouched files because of the change from just swapping to throwing exceptions to removing the unnecessary calls during the dev process.
This requires MegaMek/megameklab#1096 and MegaMek/mekhq#3261.
To review: Whitespace differences off.