Skip to content

Commit

Permalink
Update plugin kotlinter to v4.4.0 (#306)
Browse files Browse the repository at this point in the history
* Update plugin kotlinter to v4.4.0

* Run `./gradlew formatKotlin`

---------

Co-authored-by: Cedrick Cooke <[email protected]>
  • Loading branch information
juul-mobile-bot and cedrickcooke authored Jul 2, 2024
1 parent 7bd9c2b commit 14c5c55
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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<*>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
3 changes: 2 additions & 1 deletion compile/src/main/kotlin/ExerciseProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<KSClassDeclaration>()
if (symbols.any()) {
Log.info { "Found @Exercise annotated classes: ${symbols.joinToString()}" }
Expand Down
8 changes: 6 additions & 2 deletions compile/src/main/kotlin/read/KspExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import com.squareup.kotlinpoet.ClassName

internal inline fun <reified T : Annotation> 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<KSClassDeclaration>()
.singleOrNull { it.classKind == ClassKind.CLASS }
Expand Down
3 changes: 2 additions & 1 deletion compile/src/main/kotlin/read/Parameters.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<KSType>()
.map { it.asTypeName() }
.toList()
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Original file line number Diff line number Diff line change
Expand Up @@ -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<Sample> {
override fun create(parcel: Parcel): Sample = Sample(checkNotNull(parcel.readString()))
Expand Down

0 comments on commit 14c5c55

Please sign in to comment.