-
Notifications
You must be signed in to change notification settings - Fork 134
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
ban assert #1810
ban assert #1810
Conversation
Generate changelog in
|
I've intentionally opted against automatically applying the suggested fixes given how rare they are, and some subtle uses (relying on side-effects based on whether or not asserts are enabled) could be broken by automatic changes. |
fix.replace( | ||
tree, | ||
String.format( | ||
"if (!%s) { throw new IllegalStateException(%s); }", |
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.
These can result in funny code when the input is assert !value
-> if (!!value) { throw...
. Not worth optimizing here imo because we have other tools to catch and resolve those, and the fixes are only for documentation, not enabled by default.
void testNonConstantStringDescription() { | ||
fix().addInputLines( | ||
"Test.java", | ||
// format-hint |
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.
formatter puts all these onto one line without a well-placed comment. Some day we'll have text blocks.
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.
Nice!
Released 3.94.0 |
###### _excavator_ is a bot for automating changes across repositories. Changes produced by the roomba/latest-baseline-oss check. # Release Notes ## 3.94.0 | Type | Description | Link | | ---- | ----------- | ---- | | Improvement | Introduce `BadAssert` to ban `assert` statements in favor of better alternatives. | palantir/gradle-baseline#1810 | To enable or disable this check, please contact the maintainers of Excavator.
Before this PR
assert
was allowed.After this PR
==COMMIT_MSG==
Introduce
BadAssert
to banassert
statements in favor of better alternatives.==COMMIT_MSG==
Possible downsides?
May block builds? That's rather the point.