Version: Current SonarCloud version (I was not able to find some version number…)
Rule: java:S5845 Assertions of dissimilar types should not be made
AssertJ.assertThat(LocalDate.of(2020, 1, 1)).isEqualTo("2020-01-01");
The above java code triggers rule S5845 saying that you should Change the assertion arguments to not compare dissimilar types
.
But actually AssertJ implements isEqualTo
in this case in AbstractLocalDateAssert
which parses the provided String as LocalDate. So the equal check is executed correctly.
Also in my opinion providing the other date as String
is usually more readable than creating a LocalDate
so it should be supported by sonar as well.
Btw.: This is also an issue for other Temporal
s of the Java 8 DateTime API and for the old java.util.Date