Uploaded image for project: 'SonarSlang'
  1. SonarSlang
  2. SONARSLANG-95

S1125: Kotlin raises FP for nullable Boolean variables

    Details

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

      Description

      In Kotlin the following code actually makes sense:

      val b: Boolean? = null
      if (b == true) {
          println("true")
      }
      

      Since b is nullable, it is not possible to directly test the condition if (b) ... as compiler won't allow such code.
      Rule should therefore not raise issue in this case to avoid FP.
      Also, once this is fixed, another ticket should be opened, so that once syntactic information is available, the issue will be raised for non-nullable booleans, i.e.

      val b = true
      if (b == true) { // Noncompliant
          println("true")
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                christophe.zurn Christophe Zurn
                Reporter:
                christophe.zurn Christophe Zurn
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: