Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3466

FP S5845(AssertionTypesCheck) AssertJ is able to compare date/time and string

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.7
    • Component/s: Rules
    • Labels:
      None

      Description

      AssertJ supports the comparison of a date/time (ex: "java.util.Date") with a "java.lang.String":

          assertThat(new Date(0)).isEqualTo("1970-01-01T01:00:00"); // false-positive
      

      The rule S5845 should not report an issue: "Change the assertion arguments to not compare dissimilar types."

      Many types are also impacted:

      • AbstractDateAssert
        • java.util.Date
      • AbstractTemporalAssert
        • java.time.LocalDate
        • java.time.LocalDateTime
        • java.time.ZonedDateTime
        • java.time.OffsetDateTime
        • java.time.OffsetTime
        • java.time.LocalTime
        • java.time.Instant

      Reported by cott in a comment of SONARJAVA-3399

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                alban.auzeill Alban Auzeill
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: