Is it even possible? It seems every third-party tool that did it is abandoning the feature and I can’t get the deprecated but still present feature to work in Detekt or ktlint. I didn’t realise the biggest challenge with Kotlin would be detecting unused import statements so I can easily remove them.

Edit: Thanks for the help everyone, but I could not get anything working so I eventually just did it manually with a little help from the android linter.

  • HelloRoot@lemy.lol
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    5 days ago
    kotlinc -Xanalysis-mode=unused-imports -Xreport-perf -Xuse-k2 $(find "$SRC_DIR" -name '*.kt')
    

    maybe you need to play around with the flags, I’m away from pc and can’t test, but from the top of my head and a quick search it should be something like that

    on arch linux it comes from this package: https://archlinux.org/packages/extra/any/kotlin/ not sure about other distros

    no clue about windows

    • dr_robotBones@reddthat.comOP
      link
      fedilink
      arrow-up
      2
      ·
      4 days ago

      I got the Kotlin compiler using sdkman, the closest thing to that command I found was: kotlinc -Xreturn-value-checker=full $(find . -name ‘*.kt’)

      It doesn’t really work, it just gives errors for every single import that comes from a library (libKTX in my case)