Uploaded image for project: 'SonarKotlin'
  1. SonarKotlin
  2. SONARKT-182

S1128: FP on imports for annotations, delegates, overloaded operators and annotations

    XMLWordPrintable

    Details

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

      Description

      When import is actually a delegate or contains operator or probably another non-math operator, this rule doesn't resolve its usages correctly and reports such imports to be unused. Example:

      import delegates.getValue // FP here now
      class SomeClass(delegate: Delegate) {
          val someProperty: String by delegate
      }
      
      class Delegate
      
      package delegates
      operator fun Delegate.getValue(someClass: Any, property: KProperty<*>): String = "delegate"
      

      See this thread for an example with dagger annotations:
      https://community.sonarsource.com/t/sonarcloud-unused-import-false-positive-in-dagger2-module/53648

        Attachments

          Activity

            People

            Assignee:
            margarita.nedzelska Margarita Nedzelska
            Reporter:
            margarita.nedzelska Margarita Nedzelska
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: