kotlinter-gradle icon indicating copy to clipboard operation
kotlinter-gradle copied to clipboard

Incremental task

Open AnthonyPct opened this issue 2 years ago • 4 comments

Hi,

I'm not sure i really understand incremental task. I integrate the plugging in my android app, in build.gradle.kts.

If i just launch lintFormat the first time, all files will be check. But if i run a second time, only changed files should be checked, right ?

I tried many things, but every files is checked every times. I must be missing something

AnthonyPct avatar Feb 02 '23 18:02 AnthonyPct

The lintKotlin task is incremental and only checks files which are changed since last check. The formatKotlin task however always runs on all files I generally this is ok since it is not part of workflow like check which is invoked often.

jeremymailen avatar Feb 05 '23 06:02 jeremymailen

Actually, formatKotlin can be a part of a workflow and be invoked often. I have it in the git hooks, running the formatKotlin on each commit locally, which I see takes noticeable time already.

The reason why it's not lintKotlin instead is that we let it commit and immediately show "new changes" for the re-formatted things, making them visible and being automatically fixed when possible. Otherwise with lintKotlin it would require first failing and then running formatKotlin additionally just to get automatic fixes.

ajeihala avatar Feb 07 '23 21:02 ajeihala

If I remember right, the wrinkle here is that formatKotlin modifies the files which are its inputs, so when we tried to make it incremental the behavior wasn't quite what one would expect.

jeremymailen avatar Feb 08 '23 07:02 jeremymailen

Hi @jeremymailen,

Would it be a problem to use the following code here?

p.files.from(inputChanges.getFileChanges(source))

Just an idea, I didn't have a chance to analyze it more deeply.

peshrus avatar Dec 12 '23 11:12 peshrus