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

GurpreetSK

04/09/2020, 6:44 AM
Hey! Is it possible to run detekt only on a given set of files? (something like 
./gradlew detekt {list of files}
) Context: I want to write a git hook which runs detekt on all the changed files (only the changed files) and fail if the task fails.
d

dead.fish

04/09/2020, 10:01 AM
You probably need a custom task definition that only includes the files that changed. Guess you'd feed whatever git status reports to you as list in there.
a

Artur Bosch

04/11/2020, 6:07 PM
Hey, you could create a custom detekt task and provide the changed files via the
source
property (https://github.com/detekt/detekt/blob/master/build.gradle.kts#L347). Also please search the issues. @schalkms somewhere answed on how to write a git hook.
s

schalkms

04/11/2020, 6:45 PM
Yes, there is a guide on how to write a Git commit hook. You can essentially copy and paste the code from the homepage.
g

GurpreetSK

04/13/2020, 8:38 AM
Thanks everyone for the replies. We decided to run the analysis on the entire project due to the concerns mentioned in the PR, and also because of how quick the analysis runs on the codebase (it takes ~10 seconds to run, which is extremely fast!). Thanks for the amazing tool!
👍 1
@Artur Bosch I was wondering why do we not have a cli flag to ignore failures but it is supported in gradle task? https://arturbosch.github.io/detekt/cli.html
a

Artur Bosch

04/16/2020, 10:29 AM
I guess you can do everything with the exit codes, don't you? If you really need to you can increase the build failure threshold in the config file to like 9999 and always get exit code 0 🙂
g

GurpreetSK

04/20/2020, 5:16 AM
So, I want to run the same task on local and on CI, but with different
ignoreFailures
value. On CI, it should ignore failures but on local it should not.
99 Views