From 14c5c55434b8bd699604b97a320e75267acb262a Mon Sep 17 00:00:00 2001 From: JUUL Mobile Bot Date: Tue, 2 Jul 2024 10:17:02 -0700 Subject: [PATCH] Update plugin kotlinter to v4.4.0 (#306) * Update plugin kotlinter to v4.4.0 * Run `./gradlew formatKotlin` --------- Co-authored-by: Cedrick Cooke --- .../src/main/java/com/juul/exercise/annotations/AsStub.kt | 5 ++++- .../main/java/com/juul/exercise/annotations/Exercise.kt | 4 +++- .../main/java/com/juul/exercise/annotations/FromStub.kt | 4 +++- .../java/com/juul/exercise/annotations/ResultContract.kt | 4 +++- .../main/java/com/juul/exercise/annotations/ResultKind.kt | 5 ++++- compile/src/main/kotlin/ExerciseProcessor.kt | 3 ++- compile/src/main/kotlin/read/KspExtensions.kt | 8 ++++++-- compile/src/main/kotlin/read/Parameters.kt | 3 ++- gradle/libs.versions.toml | 2 +- .../com/juul/exercise/runtime/ParcelerExtensionTests.kt | 4 +++- 10 files changed, 31 insertions(+), 11 deletions(-) diff --git a/annotations/src/main/java/com/juul/exercise/annotations/AsStub.kt b/annotations/src/main/java/com/juul/exercise/annotations/AsStub.kt index 6a1e020..532a651 100644 --- a/annotations/src/main/java/com/juul/exercise/annotations/AsStub.kt +++ b/annotations/src/main/java/com/juul/exercise/annotations/AsStub.kt @@ -3,4 +3,7 @@ package com.juul.exercise.annotations @MustBeDocumented @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) -annotation class AsStub(val packageName: String, val className: String) +annotation class AsStub( + val packageName: String, + val className: String, +) diff --git a/annotations/src/main/java/com/juul/exercise/annotations/Exercise.kt b/annotations/src/main/java/com/juul/exercise/annotations/Exercise.kt index 448775b..46d3b7f 100644 --- a/annotations/src/main/java/com/juul/exercise/annotations/Exercise.kt +++ b/annotations/src/main/java/com/juul/exercise/annotations/Exercise.kt @@ -3,4 +3,6 @@ package com.juul.exercise.annotations @MustBeDocumented @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) -annotation class Exercise(vararg val params: ExerciseParameter) +annotation class Exercise( + vararg val params: ExerciseParameter, +) diff --git a/annotations/src/main/java/com/juul/exercise/annotations/FromStub.kt b/annotations/src/main/java/com/juul/exercise/annotations/FromStub.kt index 7e2f5d3..26e2682 100644 --- a/annotations/src/main/java/com/juul/exercise/annotations/FromStub.kt +++ b/annotations/src/main/java/com/juul/exercise/annotations/FromStub.kt @@ -5,4 +5,6 @@ import kotlin.reflect.KClass @MustBeDocumented @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) -annotation class FromStub(val source: KClass<*>) +annotation class FromStub( + val source: KClass<*>, +) diff --git a/annotations/src/main/java/com/juul/exercise/annotations/ResultContract.kt b/annotations/src/main/java/com/juul/exercise/annotations/ResultContract.kt index 1389b1e..a39590c 100644 --- a/annotations/src/main/java/com/juul/exercise/annotations/ResultContract.kt +++ b/annotations/src/main/java/com/juul/exercise/annotations/ResultContract.kt @@ -3,4 +3,6 @@ package com.juul.exercise.annotations @MustBeDocumented @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) -annotation class ResultContract(vararg val kinds: ResultKind) +annotation class ResultContract( + vararg val kinds: ResultKind, +) diff --git a/annotations/src/main/java/com/juul/exercise/annotations/ResultKind.kt b/annotations/src/main/java/com/juul/exercise/annotations/ResultKind.kt index 8c6e520..50c3b67 100644 --- a/annotations/src/main/java/com/juul/exercise/annotations/ResultKind.kt +++ b/annotations/src/main/java/com/juul/exercise/annotations/ResultKind.kt @@ -3,4 +3,7 @@ package com.juul.exercise.annotations @MustBeDocumented @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) -annotation class ResultKind(val name: String, vararg val params: ExerciseParameter) +annotation class ResultKind( + val name: String, + vararg val params: ExerciseParameter, +) diff --git a/compile/src/main/kotlin/ExerciseProcessor.kt b/compile/src/main/kotlin/ExerciseProcessor.kt index bed7b4d..8ee2053 100644 --- a/compile/src/main/kotlin/ExerciseProcessor.kt +++ b/compile/src/main/kotlin/ExerciseProcessor.kt @@ -24,7 +24,8 @@ internal class ExerciseProcessor( // where we see `NoDescriptorForDeclarationException: Descriptor wasn't found for declaration CLASS` if (!isFirstRound) return emptyList() - val symbols = resolver.getSymbolsWithAnnotation(Exercise::class.java.name) + val symbols = resolver + .getSymbolsWithAnnotation(Exercise::class.java.name) .filterIsInstance() if (symbols.any()) { Log.info { "Found @Exercise annotated classes: ${symbols.joinToString()}" } diff --git a/compile/src/main/kotlin/read/KspExtensions.kt b/compile/src/main/kotlin/read/KspExtensions.kt index 9eb52ad..8bc47e5 100644 --- a/compile/src/main/kotlin/read/KspExtensions.kt +++ b/compile/src/main/kotlin/read/KspExtensions.kt @@ -8,14 +8,18 @@ import com.squareup.kotlinpoet.ClassName internal inline fun KSAnnotated.getAnnotation(): KSAnnotation? = annotations.singleOrNull { - it.annotationType.resolve().declaration.qualifiedName?.asString() == T::class.qualifiedName + it.annotationType + .resolve() + .declaration.qualifiedName + ?.asString() == T::class.qualifiedName } internal fun KSAnnotation.getArgument(name: String): Any? = arguments.firstOrNull { it.name?.asString() == name }?.value internal val KSClassDeclaration.superClass: KSClassDeclaration? - get() = superTypes.asSequence() + get() = superTypes + .asSequence() .map { it.resolve().declaration } .filterIsInstance() .singleOrNull { it.classKind == ClassKind.CLASS } diff --git a/compile/src/main/kotlin/read/Parameters.kt b/compile/src/main/kotlin/read/Parameters.kt index ba87919..998e99c 100644 --- a/compile/src/main/kotlin/read/Parameters.kt +++ b/compile/src/main/kotlin/read/Parameters.kt @@ -40,7 +40,8 @@ internal fun KSAnnotation.toParameter(): Parameter = Parameter( name = getArgument(NAME) as String, nonNullTypeName = run { val targetClass = getArgument(TYPE) as KSType - val typeArguments = (getArgument(TYPE_ARGUMENTS) as List<*>).asSequence() + val typeArguments = (getArgument(TYPE_ARGUMENTS) as List<*>) + .asSequence() .filterIsInstance() .map { it.asTypeName() } .toList() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ffd4115..1fb1c2e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,5 +20,5 @@ android-library = { id = "com.android.library", version.ref = "agp" } api = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.14.0" } dokka = { id = "org.jetbrains.dokka", version = "1.9.20" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -kotlinter = { id = "org.jmailen.kotlinter", version = "4.3.0" } +kotlinter = { id = "org.jmailen.kotlinter", version = "4.4.0" } maven-publish = { id = "com.vanniktech.maven.publish", version = "0.29.0" } diff --git a/runtime/src/test/java/com/juul/exercise/runtime/ParcelerExtensionTests.kt b/runtime/src/test/java/com/juul/exercise/runtime/ParcelerExtensionTests.kt index 547613c..acc3b92 100644 --- a/runtime/src/test/java/com/juul/exercise/runtime/ParcelerExtensionTests.kt +++ b/runtime/src/test/java/com/juul/exercise/runtime/ParcelerExtensionTests.kt @@ -9,7 +9,9 @@ import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config import org.robolectric.annotation.Config.NONE -data class Sample(val value: String) +data class Sample( + val value: String, +) object SampleParceler : Parceler { override fun create(parcel: Parcel): Sample = Sample(checkNotNull(parcel.readString()))