Skip to content

Commit

Permalink
Rename TruthSelfEquals to a more sensible name.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 618828938
  • Loading branch information
graememorgan authored and Error Prone Team committed Mar 25, 2024
1 parent 5840b4d commit 9d5491d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
Expand Up @@ -41,9 +41,11 @@
import javax.inject.Inject;

/** A {@link BugPattern}; see the summary. */
// TODO(ghm): Rename to SelfAssertion or something.
@BugPattern(summary = "This assertion will always fail or succeed.", severity = ERROR)
public final class TruthSelfEquals extends BugChecker implements MethodInvocationTreeMatcher {
@BugPattern(
summary = "This assertion will always fail or succeed.",
altNames = "TruthSelfEquals",
severity = ERROR)
public final class SelfAssertion extends BugChecker implements MethodInvocationTreeMatcher {

private final Matcher<MethodInvocationTree> equalsMatcher =
anyOf(
Expand Down Expand Up @@ -87,7 +89,7 @@ public final class TruthSelfEquals extends BugChecker implements MethodInvocatio
private final ConstantExpressions constantExpressions;

@Inject
TruthSelfEquals(ConstantExpressions constantExpressions) {
SelfAssertion(ConstantExpressions constantExpressions) {
this.constantExpressions = constantExpressions;
}

Expand Down
Expand Up @@ -330,6 +330,7 @@
import com.google.errorprone.bugpatterns.RxReturnValueIgnored;
import com.google.errorprone.bugpatterns.SameNameButDifferent;
import com.google.errorprone.bugpatterns.SelfAlwaysReturnsThis;
import com.google.errorprone.bugpatterns.SelfAssertion;
import com.google.errorprone.bugpatterns.SelfAssignment;
import com.google.errorprone.bugpatterns.SelfComparison;
import com.google.errorprone.bugpatterns.SelfEquals;
Expand Down Expand Up @@ -378,7 +379,6 @@
import com.google.errorprone.bugpatterns.TruthConstantAsserts;
import com.google.errorprone.bugpatterns.TruthContainsExactlyElementsInUsage;
import com.google.errorprone.bugpatterns.TruthGetOrDefault;
import com.google.errorprone.bugpatterns.TruthSelfEquals;
import com.google.errorprone.bugpatterns.TryFailRefactoring;
import com.google.errorprone.bugpatterns.TryFailThrowable;
import com.google.errorprone.bugpatterns.TryWithResourcesVariable;
Expand Down Expand Up @@ -797,6 +797,7 @@ public static ScannerSupplier warningChecks() {
RequiredModifiersChecker.class,
RestrictedApiChecker.class,
ReturnValueIgnored.class,
SelfAssertion.class,
SelfAssignment.class,
SelfComparison.class,
SelfEquals.class,
Expand All @@ -812,7 +813,6 @@ public static ScannerSupplier warningChecks() {
ThrowIfUncheckedKnownChecked.class,
ThrowNull.class,
TreeToString.class,
TruthSelfEquals.class,
TryFailThrowable.class,
TypeParameterQualifier.class,
UnicodeDirectionalityCharacters.class,
Expand Down
Expand Up @@ -23,27 +23,27 @@
import org.junit.runners.JUnit4;

/**
* Unit tests for {@link TruthSelfEquals} bug pattern.
* Unit tests for {@link SelfAssertion} bug pattern.
*
* @author bhagwani@google.com (Sumit Bhagwani)
*/
@RunWith(JUnit4.class)
public class TruthSelfEqualsTest {
public class SelfAssertionTest {
CompilationTestHelper compilationHelper;

@Before
public void setUp() {
compilationHelper = CompilationTestHelper.newInstance(TruthSelfEquals.class, getClass());
compilationHelper = CompilationTestHelper.newInstance(SelfAssertion.class, getClass());
}

@Test
public void positiveCase() {
compilationHelper.addSourceFile("TruthSelfEqualsPositiveCases.java").doTest();
compilationHelper.addSourceFile("SelfAssertionPositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("TruthSelfEqualsNegativeCases.java").doTest();
compilationHelper.addSourceFile("SelfAssertionNegativeCases.java").doTest();
}

// regression test for b/32107126
Expand Down
Expand Up @@ -19,11 +19,11 @@
import static com.google.common.truth.Truth.assertThat;

/**
* Negative test cases for TruthSelfEquals check.
* Negative test cases for SelfAssertion check.
*
* @author bhagwani@google.com (Sumit Bhagwani)
*/
public class TruthSelfEqualsNegativeCases {
public class SelfAssertionNegativeCases {

public void testEq() {
assertThat(Boolean.TRUE.toString()).isEqualTo(Boolean.FALSE.toString());
Expand Down
Expand Up @@ -20,11 +20,11 @@
import static com.google.common.truth.Truth.assertWithMessage;

/**
* Positive test cases for TruthSelfEquals check.
* Positive test cases for SelfAssertion check.
*
* @author bhagwani@google.com (Sumit Bhagwani)
*/
public class TruthSelfEqualsPositiveCases {
public class SelfAssertionPositiveCases {

public void testAssertThatEq() {
String test = Boolean.TRUE.toString();
Expand Down
File renamed without changes.

0 comments on commit 9d5491d

Please sign in to comment.