-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27154b5
commit b27f49d
Showing
4 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: detekt | ||
name: detekt check | ||
description: Runs `detekt` on modified .kt files. | ||
language: script | ||
entry: config/detekt/detekt.sh | ||
files: \.kt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bash | ||
echo "Running detekt check..." | ||
OUTPUT="/tmp/detekt-$(date +%s)" | ||
COUNTER=0 | ||
EXIT_CODE=1 | ||
|
||
|
||
|
||
|
||
until [ $COUNTER -gt 5 ] || [ $EXIT_CODE -eq 0 ] | ||
do | ||
./gradlew detekt --auto-correct > $OUTPUT | ||
EXIT_CODE=$? | ||
echo "execute $COUNTER time" | ||
cat $OUTPUT | ||
COUNTER=$((COUNTER+1)) | ||
echo "detekt return $EXIT_CODE" | ||
done | ||
rm $OUTPUT | ||
|
||
if [ $EXIT_CODE -eq 0 ] && [ $COUNTER -eq 1 ]; then | ||
echo "***********************************************" | ||
echo " Validation succeeded " | ||
echo "***********************************************" | ||
echo "" | ||
exit 0 | ||
fi | ||
|
||
if [ $EXIT_CODE -eq 0 ] ; then | ||
echo "*************************************************" | ||
echo " Validation failed " | ||
echo " Fix succeeded " | ||
echo "" | ||
echo " The fix were successfully applied " | ||
echo "You can retry the commit with the applied changes" | ||
echo "*************************************************" | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
if [ $EXIT_CODE -eq 1 ]; then | ||
echo "***********************************************" | ||
echo " detekt failed " | ||
echo " unexpected error " | ||
echo "***********************************************" | ||
echo "" | ||
exit 1 | ||
fi | ||
|
||
if [ $EXIT_CODE -eq 2 ]; then | ||
echo "***********************************************" | ||
echo " detekt failed " | ||
echo " Please fix the above issues before committing " | ||
echo "***********************************************" | ||
exit 1 | ||
fi | ||
|
||
if [ $EXIT_CODE -eq 2 ]; then | ||
echo "***********************************************" | ||
echo " detekt failed " | ||
echo " Invalid detekt configuration file " | ||
echo "***********************************************" | ||
echo "" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters