diff --git a/.githooks/linkHooks.bat b/.githooks/linkHooks.bat new file mode 100755 index 0000000000..589f9358f3 --- /dev/null +++ b/.githooks/linkHooks.bat @@ -0,0 +1,4 @@ +@echo off +echo Changing git config for hooks to .githooks +call git config --local core.hooksPath .githooks/ +echo Complete! diff --git a/.githooks/linkHooks.sh b/.githooks/linkHooks.sh new file mode 100755 index 0000000000..91d239b1aa --- /dev/null +++ b/.githooks/linkHooks.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set echo off +echo Changing git config for hooks to .githooks +git config --local core.hooksPath .githooks/ +echo Complete! diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000000..4b93da9b5f --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,17 @@ +#!/bin/sh + +echo "Running detekt check" +OUTPUT="/tmp/detekt-$(date +%s)" +./gradlew detekt > $OUTPUT +EXIT_CODE=$? +if [ $EXIT_CODE -ne 0 ]; then + cat $OUTPUT + rm $OUTPUT + echo + echo "***********************************************" + echo " Detekt failed " + echo " Please fix the above issues before committing " + echo "***********************************************" + exit $EXIT_CODE +fi +rm $OUTPUT diff --git a/build.gradle.kts b/build.gradle.kts index bee117591d..c62b45fb0d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,15 +21,6 @@ repositories { mavenCentral() } -subprojects { - afterEvaluate { - if (tasks.findByName("detekt") != null) { - tasks.withType { - dependsOn(tasks["detekt"]) - } - } - } -} tasks.named("dependencyUpdates", DependencyUpdatesTask::class.java).configure { diff --git a/config/detekt.yml b/config/detekt.yml index ea4700d87a..50da7640a1 100644 --- a/config/detekt.yml +++ b/config/detekt.yml @@ -189,7 +189,7 @@ formatting: autoCorrect: true ParameterListWrapping: excludes: ['**/test/**', '**/*.Test.kt', '**/*.Spec.kt'] - active: false + active: true autoCorrect: true indentSize: 4 SpacingAroundColon: diff --git a/docs/onboarding/1_environment_setup.md b/docs/onboarding/1_environment_setup.md index 050c822eeb..b2b17fb2b5 100644 --- a/docs/onboarding/1_environment_setup.md +++ b/docs/onboarding/1_environment_setup.md @@ -46,3 +46,7 @@ export GITHUB_TOKEN="type your gihub token here" 1. You can clone https://github.com/Flank/gcloud_cli 1. Or follow official instruction https://cloud.google.com/sdk/docs/quickstarts 1. Don't forget about exports for python and gcloud +1. Ensure Git hooks is configured correctly so detekt is run on a commit + 1. Navigate to the .githooks folder + 1. Execute linkHooks.sh or linkHooks.bat (depends on the current development OS) + 1. Attempting a `git commit ...` should now trigger a detekt check and will not allow committing until it is successful diff --git a/test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt b/test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt index 52e6e29869..cbd783f120 100644 --- a/test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt +++ b/test_runner/src/main/kotlin/ftl/ios/Xctestrun.kt @@ -92,8 +92,8 @@ object Xctestrun { } private fun findTestNamesForTarget( - testTarget: String, - xctestrun: File + testTarget: String, + xctestrun: File ): List = testsForTarget( testDictionary = parse(xctestrun)[testTarget]