I'm getting weird exception when trying to run ./gradlew spotlessApply
on my project in Kotlin.
Class causing the problem:
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class CurrentFluttering(
@PrimaryKey var id: Long = 0,
var currentCoinsHeap: Int = 0,
var currentEarnedCoins: Int = 0,
var startTime: Long = 0,
var pauseTime: Long = 0,
var time: Long = 0,
var firstCycle: Boolean = true,
var inBackground: Boolean = false,
var currentMissedCoins: Int = 0,
var isPaused: Boolean = false,
) : RealmObject()
Stack trace:
> Task :spotlessKotlin FAILED
Step 'ktlint' found problem in 'app/src/main/java/com/cfhero/android/model/state/CurrentFluttering.kt':
Expecting a parameter declaration
com.pinterest.ktlint.core.ParseException: Expecting a parameter declaration
at com.pinterest.ktlint.core.KtLint.format(KtLint.kt:357)
at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.diffplug.spotless.kotlin.KtLintStep$State.lambda$createFormat$1(KtLintStep.java:173)
at com.diffplug.spotless.FormatterFunc.apply(FormatterFunc.java:31)
at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:78)
at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:76)
at com.diffplug.spotless.Formatter.compute(Formatter.java:230)
at com.diffplug.spotless.Formatter.applyToAndReturnResultIfDirty(Formatter.java:192)
at com.di
Have anybody experienced same or similar problem?
I found it. The problem was dangling ',' after last parameter in constructor (which Kotlin allows ).
var isPaused: Boolean = false, <- here ლ(ಠ益ಠლ)
) : RealmObject()