Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

lint: Enable unused import checks

Open david-allison opened this issue 6 months ago • 5 comments

These were disabled in ktlint 1.7 and is now opt-in. ktlint planned to remove these checks, but this decision has been reversed

Ktlint analyses code on a file by file base. Meaning, that all linting/formatting decisions have to be made based on information in the file that is being processed. Information in other files is not taken into account at all. For a 100% reliable detection whether an import is used, or unused, a file needs to be analyzed within the scope of the project and its dependencies.

The no-unused-imports rule is marked as deprecated starting from Ktlint 1.7.0, and will be removed in Ktlint 2.0.0. Until the rule is removed, it can be used by explicitly enabling the rule in the .editorconfig, by adding:

  • https://redirect.github.com/pinterest/ktlint/issues/3038

I will use detekt for this: https://detekt.dev/

I have been planning to enable detekt for a while, and this is a sufficient reason to start. Detekt bugfixes should be added as TODOs

david-allison avatar Jun 03 '26 10:06 david-allison

Detekt 2.0.0 is required. Using ktlint for now

david-allison avatar Jun 03 '26 10:06 david-allison

Hello 👋, this issue has been opened for more than 3 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] avatar Sep 01 '26 10:09 github-actions[bot]

Hi @david-allison, I would like to work on this issue, could you assign it to me?

Ratnesh5 avatar Sep 10 '26 18:09 Ratnesh5

As far as I'm aware, Detekt 2 is still unreleased

Probably best to wait, unless you have a suggestion on how to solve it

david-allison avatar Sep 10 '26 20:09 david-allison

Not actionable, no point in keeping this around

david-allison avatar Oct 03 '26 10:10 david-allison