In ktlint 1.3.0 an import which is only used inside a block which is excluded from formatting, is reported as being an unused import. Removing the import results in code which can not be compiled.
import bar.Bar1
import bar.Bar2
fun foo123() {
// @formatter:off
// Assume that class Bar1 is defined in package. The import
// for this class is reported as unused
Bar1()
// @formatter:on
// Assume that class Bar1 is defined in package. The import
// // for this class is not reported as unused
Bar2()
}
Based on https://github.com/nbadal/ktlint-intellij-plugin/issues/535#issuecomment-2162188102
In ktlint
1.3.0
an import which is only used inside a block which is excluded from formatting, is reported as being an unused import. Removing the import results in code which can not be compiled.