From edc7095b4bff2cb93afa6ec4a37a26e46d2c240c Mon Sep 17 00:00:00 2001 From: Alexandre Favre <82375771+alexandrefavre4@users.noreply.github.com> Date: Thu, 24 Mar 2022 21:39:52 +0100 Subject: [PATCH] Add Android support for Kotlin (#2670) * Fix Kotlin good test case (incorrect filename) * Add Android support for Kotlin Co-authored-by: Lukas Gravley --- .../test/kotlin/{kotlint_good_1.kt => kotlin_good_1.kt} | 0 .automation/test/kotlin_android/kotlin_android_bad_1.kt | 9 +++++++++ .automation/test/kotlin_android/kotlin_android_good_1.kt | 9 +++++++++ README.md | 1 + lib/functions/buildFileList.sh | 1 + lib/linter.sh | 2 ++ 6 files changed, 22 insertions(+) rename .automation/test/kotlin/{kotlint_good_1.kt => kotlin_good_1.kt} (100%) create mode 100644 .automation/test/kotlin_android/kotlin_android_bad_1.kt create mode 100644 .automation/test/kotlin_android/kotlin_android_good_1.kt diff --git a/.automation/test/kotlin/kotlint_good_1.kt b/.automation/test/kotlin/kotlin_good_1.kt similarity index 100% rename from .automation/test/kotlin/kotlint_good_1.kt rename to .automation/test/kotlin/kotlin_good_1.kt diff --git a/.automation/test/kotlin_android/kotlin_android_bad_1.kt b/.automation/test/kotlin_android/kotlin_android_bad_1.kt new file mode 100644 index 00000000..87014265 --- /dev/null +++ b/.automation/test/kotlin_android/kotlin_android_bad_1.kt @@ -0,0 +1,9 @@ +import pkg.PkgClass +import java.JavaClass + +fun main(str1: String, str2: String, str3: String) { + val j = JavaClass() + val p = PkgClass() + + println(p) +} diff --git a/.automation/test/kotlin_android/kotlin_android_good_1.kt b/.automation/test/kotlin_android/kotlin_android_good_1.kt new file mode 100644 index 00000000..0f375843 --- /dev/null +++ b/.automation/test/kotlin_android/kotlin_android_good_1.kt @@ -0,0 +1,9 @@ +import java.JavaClass +import pkg.PkgClass + +fun main(str1: String, str2: String, str3: String) { + val j = JavaClass() + val p = PkgClass() + + println(p) +} diff --git a/README.md b/README.md index 0bb4e48f..7c7bc9af 100644 --- a/README.md +++ b/README.md @@ -365,6 +365,7 @@ But if you wish to select or exclude specific linters, we give you full control | **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the JSON language. | | **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: eslint) | | **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the Kotlin language. | +| **VALIDATE_KOTLIN_ANDROID** | `true` | Flag to enable or disable the linting process of the Kotlin language. (Utilizing: `ktlint --android`) | | **VALIDATE_KUBERNETES_KUBEVAL** | `true` | Flag to enable or disable the linting process of Kubernetes descriptors with Kubeval | | **VALIDATE_LATEX** | `true` | Flag to enable or disable the linting process of the LaTeX language. | | **VALIDATE_LUA** | `true` | Flag to enable or disable the linting process of the language. | diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index afb88679..4b87b69b 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -562,6 +562,7 @@ function BuildFileList() { # Append the file to the array # ################################ FILE_ARRAY_KOTLIN+=("${FILE}") + FILE_ARRAY_KOTLIN_ANDROID+=("${FILE}") ##################### # Get the LUA files # diff --git a/lib/linter.sh b/lib/linter.sh index 354eb57f..74c7f449 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -290,6 +290,7 @@ LINTER_NAMES_ARRAY['JSON']="eslint" LINTER_NAMES_ARRAY['JSONC']="eslint" LINTER_NAMES_ARRAY['JSX']="eslint" LINTER_NAMES_ARRAY['KOTLIN']="ktlint" +LINTER_NAMES_ARRAY['KOTLIN_ANDROID']="ktlint" LINTER_NAMES_ARRAY['KUBERNETES_KUBEVAL']="kubeval" LINTER_NAMES_ARRAY['LATEX']="chktex" LINTER_NAMES_ARRAY['LUA']="lua" @@ -908,6 +909,7 @@ LINTER_COMMANDS_ARRAY['JSON']="eslint --no-eslintrc -c ${JAVASCRIPT_ES_LINTER_RU LINTER_COMMANDS_ARRAY['JSONC']="eslint --no-eslintrc -c ${JAVASCRIPT_ES_LINTER_RULES} --ext .json5,.jsonc" LINTER_COMMANDS_ARRAY['JSX']="eslint --no-eslintrc -c ${JSX_LINTER_RULES}" LINTER_COMMANDS_ARRAY['KOTLIN']="ktlint" +LINTER_COMMANDS_ARRAY['KOTLIN_ANDROID']="ktlint --android" if [ "${KUBERNETES_KUBEVAL_OPTIONS}" == "null" ] || [ -z "${KUBERNETES_KUBEVAL_OPTIONS}" ]; then LINTER_COMMANDS_ARRAY['KUBERNETES_KUBEVAL']="kubeval --strict" else