Hey! Is it possible to run detekt only on a given ...
# detekt
g
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
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
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
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
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
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
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.
290 Views