Skip to content
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

Merged
merged 3 commits into from
Nov 9, 2021
Merged

Conversation

pkoenig10
Copy link
Member

@pkoenig10 pkoenig10 commented Nov 9, 2021

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.

@changelog-app
Copy link

changelog-app bot commented Nov 9, 2021

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Add Error Prone check to prefer hasNoArgs on service exception asserts and loggable exception asserts.

Check the box to generate changelog(s)

  • Generate changelog entry

"import com.palantir.logsafe.testing.LoggableExceptionAssert;",
"public class Test {",
" void f(LoggableExceptionAssert a) {",
" a.hasNoArgs();",
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep 👍

@bulldozer-bot bulldozer-bot bot merged commit efed75b into develop Nov 9, 2021
@bulldozer-bot bulldozer-bot bot deleted the pkoenig10/noArgs branch November 9, 2021 14:54
@svc-autorelease
Copy link
Collaborator

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 {
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bulldozer-bot bot pushed a commit to palantir/witchcraft-api that referenced this pull request Nov 9, 2021
###### _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.
This was referenced Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants