Skip to content

Commit

Permalink
Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rickie committed Mar 27, 2023
1 parent 4462c78 commit 9d8141e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tech.picnic.errorprone.bugpatterns.util;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.util.Objects.requireNonNull;

import com.google.common.collect.ImmutableList;
import com.google.errorprone.VisitorState;
Expand All @@ -27,7 +27,7 @@ private MoreASTHelpers() {}
*/
public static ImmutableList<MethodTree> findMethods(CharSequence methodName, VisitorState state) {
ClassTree clazz = state.findEnclosing(ClassTree.class);
requireNonNull(clazz, "Visited node is not enclosed by a class");
checkArgument(clazz != null, "Visited node is not enclosed by a class");
return clazz.getMembers().stream()
.filter(MethodTree.class::isInstance)
.map(MethodTree.class::cast)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ T after(T object) {
}
}

/** Prefer {@link Objects#requireNonNull(Object)} over non-JDK alternatives. */
/** Prefer {@link Objects#requireNonNull(Object)} over more verbose alternatives. */
static final class RequireNonNullStatement<T> {
@BeforeTemplate
void before(T object) {
Expand All @@ -97,11 +97,6 @@ void before(T object) {
}
}

@BeforeTemplate
void before2(T object) {
checkArgument(object != null);
}

@AfterTemplate
@UseImportPolicy(STATIC_IMPORT_ALWAYS)
void after(T object) {
Expand Down Expand Up @@ -132,11 +127,6 @@ void before(T object, String message) {
}
}

@BeforeTemplate
void before2(T object, String message) {
checkArgument(object != null, message);
}

@AfterTemplate
@UseImportPolicy(STATIC_IMPORT_ALWAYS)
void after(T object, String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tech.picnic.errorprone.refasterrules;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -39,7 +38,6 @@ void testRequireNonNullStatement() {
if ("foo" == null) {
throw new NullPointerException();
}
checkArgument("bar" != null);
}

String testRequireNonNullWithMessage() {
Expand All @@ -50,7 +48,6 @@ void testRequireNonNullWithMessageStatement() {
if ("foo" == null) {
throw new NullPointerException("The string is null");
}
checkArgument("bar" != null, "The string is null");
}

void testCheckPositionIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ String testRequireNonNull() {

void testRequireNonNullStatement() {
requireNonNull("foo");
requireNonNull("bar");
}

String testRequireNonNullWithMessage() {
Expand All @@ -44,7 +43,6 @@ String testRequireNonNullWithMessage() {

void testRequireNonNullWithMessageStatement() {
requireNonNull("foo", "The string is null");
requireNonNull("bar", "The string is null");
}

void testCheckPositionIndex() {
Expand Down

0 comments on commit 9d8141e

Please sign in to comment.