An assertion compares a value with itself, so it can never fail
What it finds
assertEquals(result, result) and assertThat(total).isEqualTo(total) always pass, so the test checks nothing: one side was meant to be the expected value.
Reported is assertEquals, assertNotEquals, assertSame, assertNotSame or assertArrayEquals whose two compared arguments are the same expression without calls, which could give a new value each time, and assertThat(x) followed by isEqualTo(x), isSameAs(x) or isNotEqualTo(x).
From the rule's source, same_value_assertion.rs.
import static org.junit.jupiter.api.Assertions.assertEquals;import static org.assertj.core.api.Assertions.assertThat; class CalcTest { void check(int result, int expected) { assertEquals(result, result);tx0 reports: both sides of this assertion are the same expression assertThat(result).isEqualTo(result);tx0 reports: both sides assertEquals(expected, result); assertEquals(1, 1); }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:same-value-assertion" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:same-value-assertion] reason="..."tx0 explain tx0/java:same-value-assertion shows the same in the terminal. Found a false positive? Report it.