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

Czar

12/08/2019, 11:39 AM
Can I disable a rule only in IntelliJ, without affecting gradle build and committing anything? So far I've thought of following options (both of which I don't like): 1. copy-paste my detekt.yml from the project to a place outside project, make the change I want, configure plugin with that file while leaving gradle config intact. Negative here is that I have to be on lookout for additional changes to detekt.yml from the repo and not forget to update my local file 2. change the file in the project and move it to a separate "local only" changelist to avoid commiting it. Downside: bit risky, at some point can still commit it unintentionally, e.g. from command line. I need this to suppress ForbiddenComments for
todo:
, but only in IntelliJ, because I use
todo:
comments when working on a changeset. Showing those as errors kinda messes with the flow. On the other hand I wouldn't want to commit them, so I need them to be reported when I run gradle check
p

plastiv

12/08/2019, 6:27 PM
It should be possible to check ide run at gradle script.
Copy code
if (project.hasProperty('android.injected.invoked.from.ide') || System.getProperty('idea.version') != null) {
    config = files("ide-detekt-config.yml")
} else {
    config = files("normal-detekt-config.yml")
}
m

Mike

12/08/2019, 7:43 PM
Alternatively, just show Detekt issues as warnings in the IDE, and you know to ignore it. Even if you make it an error in IDE, does it actually prevent anything, or just change the color? I generally leave it as a warning, so haven't tried it as an error.
c

Czar

12/09/2019, 6:54 AM
I also have it as a warning, but that's not usable for me, as I don't usually tolerate warnings, whereas TODOs are other kind of beast. @plastiv Gradle suggestion is definitely an option, heh, should've thought of that, thanks.
4 Views