Skip to content

Remove redundant null check in ResourceHarness #216

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

Merged
merged 1 commit into from
Mar 2, 2018

Conversation

thc202
Copy link
Contributor

@thc202 thc202 commented Mar 1, 2018

Remove the null check in constructor of WriterAsserter as the reference
being checked is guaranteed to be non-null (a NullPointerException would
be thrown in a previous statement).

I'm proposing the removal of the null check instead of moving it up in the call chain because no other null check is being done in the class (methods and ReadAsserter).

Remove the null check in constructor of WriterAsserter as the reference
being checked is guaranteed to be non-null (a NullPointerException would
be thrown in a previous statement).
@jbduncan
Copy link
Member

jbduncan commented Mar 2, 2018

@thc202 Good catch! I'd personally prefer for the line this.file = Objects.requireNonNull(file); to be made the first line and file.getParentFile().mkdirs(); the second line to make the null check explicit, but I won't insist.

@nedtwigg nedtwigg merged commit 995b6a9 into diffplug:master Mar 2, 2018
@thc202 thc202 deleted the rm-null-check-resourceharness branch March 2, 2018 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants