I’m running `detekt` and updating a rule (custom),...
# detekt
l
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
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
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
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
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
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
I've found doing a
gradle --stop
to have fixed this problem for me in the past.
l
the stop worked, thanks
s
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)