jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle
Apache License 2.0
583 stars 50 forks source link

Certain Imports Removed by Formatter #165

Closed bellini-ea closed 3 years ago

bellini-ea commented 3 years ago

In a kotlin project, using 3.2.0 of this plugin, the following import is totally removed by the formatter cause build failures due to the deleted line. I have mitigated this so we can continue to use the formatter however it is not ideal.

import org.mockito.Mockito.`when` as mockWhen

image

jeremymailen commented 3 years ago

Thank you for reporting. It appears to be a bug in the underlying ktlint engine: https://github.com/pinterest/ktlint/issues/937

I will watch the issue and incorporate a fix when available.

jeremymailen commented 3 years ago

You may already be mitigating it this way, but a workaround is to suppress ktlint for that line of code: https://github.com/pinterest/ktlint#how-do-i-suppress-an-error-for-a-lineblockfile

In this case I think it's

/* ktlint-disable no-unused-imports */
import org.mockito.Mockito.`when` as mockWhen
/* ktlint-enable no-unused-imports */
jeremymailen commented 3 years ago

Should be fixed in the latest