-
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
Add error-prone check to prefer hasNoArgs #1966
Conversation
Generate changelog in
|
baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/AssertNoArgsTest.java
Outdated
Show resolved
Hide resolved
"import com.palantir.logsafe.testing.LoggableExceptionAssert;", | ||
"public class Test {", | ||
" void f(LoggableExceptionAssert a) {", | ||
" a.hasNoArgs();", |
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.
I think this one could produce failures, but I can't imagine anyone would write .containsArgs()
and expect it to be a no-op.
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.
Searching our internal repos, I only see 2 uses of .containsArgs()
without any arguments and they are both in a repo I own. And the intention in both cases was to assert that the exception has no args.
It's probably more likely that this change is a bug fix.
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.
Yep 👍
Released 4.39.0 |
linkType = BugPattern.LinkType.CUSTOM, | ||
severity = BugPattern.SeverityLevel.WARNING, | ||
summary = "Prefer hasNoArgs when asserting that an exception has no args.") | ||
public final class AssertNoArgs extends BugChecker implements BugChecker.MethodInvocationTreeMatcher { |
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.
@pkoenig10 we probably should have added this to the BaselineErrorProneExtension so it's automatically fiexed
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.
###### _excavator_ is a bot for automating changes across repositories. Changes produced by the roomba/latest-baseline-oss check. # Release Notes ## 4.38.0 | Type | Description | Link | | ---- | ----------- | ---- | | Improvement | Improve Zero Warmup Rate Limiter to Catch Int Literals | palantir/gradle-baseline#1960 | ## 4.39.0 | Type | Description | Link | | ---- | ----------- | ---- | | Fix | The `com.palantir.baseline-java-versions` plugin requires gradle 7 and fails eagerly on older versions. Previously it would cause non-obvious failures later depending on task execution. | palantir/gradle-baseline#1965 | | Feature | Add Error Prone check to prefer `hasNoArgs` on service exception asserts and loggable exception asserts. | palantir/gradle-baseline#1966 | ## 4.40.0 | Type | Description | Link | | ---- | ----------- | ---- | | Improvement | Automatically fix AssertNoArgs | palantir/gradle-baseline#1967 | To enable or disable this check, please contact the maintainers of Excavator.
Error prone check to switch to the methods added in palantir/safe-logging#607 and palantir/conjure-java-runtime-api#702.
Probably want to wait a while before merging this so repos have upgraded to releases with the
hasNoArgs
method.