https://kotlinlang.org logo
#detekt
Title
# detekt
l

Luca Nicoletti

02/21/2023, 9:58 AM
I’m running
detekt
and updating a rule (custom), but the rule code is not the latest I have in the file. Any why I can force re-loading the rule when I run
./gradlew detekt
?
b

Brais Gabin

02/21/2023, 11:16 AM
What is the output of
./gradlew detekt
? is it
UP-TO-DATE
? If so it seems like an issue in your gradle configuration or our plugin.
As a fast solution you can run
./gradlew detekt --rerun-tasks
.
l

Luca Nicoletti

02/21/2023, 11:18 AM
What is the output of ./gradlew detekt? is it UP-TO-DATE?
No, it runs, but, for example, I had
println()
statements in my rule, and after removing them, I can still see them in the terminal
b

Brais Gabin

02/21/2023, 11:19 AM
Check with
--rerun-tasks
and see if it works.
If it doesn’t work for sure is that
detekt
is not using that file. It could be getting the code from a maven server or something similar.
If it works it seems like an issue in your gradle configuration or the detekt gradle plugin.
l

Luca Nicoletti

02/21/2023, 11:23 AM
How can the rule print out if not used? 🤔
It surely does use my rule since the prints have changed in time, and they are “update”, just not at “run-time” each time I change my code
b

Brais Gabin

02/21/2023, 11:27 AM
Yes, it uses your rule but maybe you have the rule on gradle cache. Or you have a private maven repository and it is getting from there. I mean. That’s only if
--rerun-tasks
doesn’t fix your issue.
m

mkrussel

02/21/2023, 1:12 PM
I've found doing a
gradle --stop
to have fixed this problem for me in the past.
l

Luca Nicoletti

02/24/2023, 10:33 AM
the stop worked, thanks
s

Sam Pengilly

03/03/2023, 1:23 AM
yea, this seems to be a persistent problem during development of custom rules. Something to do with things being cached in the Gradle Daemon if stop works? I used an Exception previously to debug something, removed the exception, changed the exception message, etc, but every time I ran detekt it was the original exception being thrown (and yes, I had set up my rule gradle project to build as a dependency of running the detekt task)
4 Views