Skip to content

Commit

Permalink
Apply changes from ktlintFormat
Browse files Browse the repository at this point in the history
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
renovate[bot] authored and github-actions[bot] committed Nov 9, 2023
1 parent 9d58969 commit ef26e44
Show file tree
Hide file tree
Showing 36 changed files with 444 additions and 405 deletions.
49 changes: 37 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,18 @@ tasks.withType<DetektCreateBaselineTask>().configureEach {
this.jvmTarget = "1.8"
}

val detektLibraries = libs.detekt.rules.libraries.get()
val detektId = libs.plugins.detekt.get().pluginId
val detektLibraries =
libs
.detekt
.rules
.libraries
.get()
val detektId =
libs
.plugins
.detekt
.get()
.pluginId

tasks.register("detektReportMerge", ReportMergeTask::class.java) {

Expand Down Expand Up @@ -118,15 +128,18 @@ allprojects {
target.tasks.register("detektAll", Detekt::class.java) {
description = "runs the standard PSI Detekt as well as all type resolution tasks"
dependsOn(
target.tasks.withType(Detekt::class.java)
target
.tasks
.withType(Detekt::class.java)
.matching { it != this@register }
)
}
}
}

subprojects {
tasks.withType<KotlinCompile>()
tasks
.withType<KotlinCompile>()
.configureEach {

kotlinOptions {
Expand Down Expand Up @@ -155,16 +168,28 @@ fun isNonStable(version: String): Boolean {
return isStable.not()
}

tasks.named(
"dependencyUpdates",
com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask::class.java
).configure {
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
tasks
.named(
"dependencyUpdates",
com
.github
.benmanes
.gradle
.versions
.updates
.DependencyUpdatesTask::class.java
).configure {
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
}

val ktlintVersion = libs.versions.ktlint.lib.get()
val ktlintVersion =
libs
.versions
.ktlint
.lib
.get()
val ktrules = libs.rickBusarow.ktrules.get()

allprojects {
Expand Down
1 change: 0 additions & 1 deletion hermit-core/src/main/kotlin/hermit/test/Hermit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ package hermit.test
public open class Hermit(
private val delegates: MutableCollection<Resets> = mutableListOf()
) : ResetManager {

override fun register(delegate: Resets) {
synchronized(delegates) {
delegates.add(delegate)
Expand Down
27 changes: 16 additions & 11 deletions hermit-core/src/main/kotlin/hermit/test/LazyResets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public inline fun <reified T : Any> ResetManager.resets(
*
* @see Class.newInstance
*/
public class LazyResetDelegateNonDefaultConstructorException(problemClass: KClass<*>) :
LazyResetDelegateException(
public class LazyResetDelegateNonDefaultConstructorException(
problemClass: KClass<*>
) : LazyResetDelegateException(
problemClass,
"Classes without a default constructor cannot be used with a 'by resets' delegate."
)
Expand All @@ -91,8 +92,9 @@ public class LazyResetDelegateNonDefaultConstructorException(problemClass: KClas
*
* @see Class.newInstance
*/
public class LazyResetDelegateInterfaceException(problemClass: KClass<*>) :
LazyResetDelegateException(
public class LazyResetDelegateInterfaceException(
problemClass: KClass<*>
) : LazyResetDelegateException(
problemClass,
"Interfaces cannot be used with a 'by resets' delegate since they cannot be instantiated."
)
Expand All @@ -102,8 +104,9 @@ public class LazyResetDelegateInterfaceException(problemClass: KClass<*>) :
*
* @see Class.newInstance
*/
public class LazyResetDelegateAbstractException(problemClass: KClass<*>) :
LazyResetDelegateException(
public class LazyResetDelegateAbstractException(
problemClass: KClass<*>
) : LazyResetDelegateException(
problemClass,
"Abstract classes cannot be used with a 'by resets' delegate since they cannot be instantiated."
)
Expand All @@ -114,11 +117,13 @@ public class LazyResetDelegateAbstractException(problemClass: KClass<*>) :
*
* @see KClass.objectInstance
*/
public class LazyResetDelegateObjectException(problemClass: KClass<*>) : LazyResetDelegateException(
problemClass,
"Objects may not be used with a 'by resets' delegate " +
"unless they implement the LazyReset interface."
)
public class LazyResetDelegateObjectException(
problemClass: KClass<*>
) : LazyResetDelegateException(
problemClass,
"Objects may not be used with a 'by resets' delegate " +
"unless they implement the LazyReset interface."
)

public open class LazyResetDelegateException(
problemClass: KClass<*>,
Expand Down
2 changes: 1 addition & 1 deletion hermit-core/src/main/kotlin/hermit/test/ResetManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package hermit.test
* @see [ResetManager]
*/
public interface ResetManager {

public fun register(delegate: Resets)

public fun resetAll()
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ internal class LazyResetsImpl<out T : Any>(
private val resetManager: ResetManager,
private val valueFactory: suspend () -> T
) : LazyResets<T> {

private var lazyHolder: Lazy<T> = createLazy()

override val value: T
get() = lazyHolder.value

override fun isInitialized(): Boolean = lazyHolder.isInitialized()

private fun createLazy() = lazy {
resetManager.register(this)
runBlocking { valueFactory() }
}
private fun createLazy() =
lazy {
resetManager.register(this)
runBlocking { valueFactory() }
}

override fun reset() {
lazyHolder = createLazy()
Expand Down
89 changes: 47 additions & 42 deletions hermit-core/src/test/kotlin/hermit/test/ExceptionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,76 @@ import io.kotest.matchers.shouldBe
import io.kotest.matchers.types.shouldBeInstanceOf

@Suppress("MaxLineLength", "Unused")
class ExceptionsTest : FreeSpec({
class ExceptionsTest :
FreeSpec({

"types" - {
"types" - {

"should all be Exception" - {
"should all be Exception" - {

forAll(
row(object : LazyResetDelegateException(String::class, "") {}),
row(LazyResetDelegateNonDefaultConstructorException(String::class)),
row(LazyResetDelegateInterfaceException(String::class)),
row(LazyResetDelegateAbstractException(String::class)),
row(LazyResetDelegateObjectException(String::class))
) { exception ->
forAll(
row(object : LazyResetDelegateException(String::class, "") {}),
row(LazyResetDelegateNonDefaultConstructorException(String::class)),
row(LazyResetDelegateInterfaceException(String::class)),
row(LazyResetDelegateAbstractException(String::class)),
row(LazyResetDelegateObjectException(String::class))
) { exception ->

exception.shouldBeInstanceOf<Exception>()
exception.shouldBeInstanceOf<Exception>()
}
}
}

"should all be LazyResetDelegateException" - {
"should all be LazyResetDelegateException" - {

forAll(
row(LazyResetDelegateNonDefaultConstructorException(String::class)),
row(LazyResetDelegateInterfaceException(String::class)),
row(LazyResetDelegateAbstractException(String::class)),
row(LazyResetDelegateObjectException(String::class))
) { exception ->
forAll(
row(LazyResetDelegateNonDefaultConstructorException(String::class)),
row(LazyResetDelegateInterfaceException(String::class)),
row(LazyResetDelegateAbstractException(String::class)),
row(LazyResetDelegateObjectException(String::class))
) { exception ->

exception.shouldBeInstanceOf<LazyResetDelegateException>()
exception.shouldBeInstanceOf<LazyResetDelegateException>()
}
}
}
}

"non default constructor exception message" - {
"non default constructor exception message" - {

LazyResetDelegateNonDefaultConstructorException(String::class).message shouldBe """
LazyResetDelegateNonDefaultConstructorException(String::class).message shouldBe
"""
error initializing <kotlin.String>. Classes without a default constructor cannot be used with a 'by resets' delegate.
""".trimIndent()
}
error initializing <kotlin.String>. Classes without a default constructor cannot be used with a 'by resets' delegate.
""".trimIndent()
}

"interface exception message" - {
"interface exception message" - {

LazyResetDelegateInterfaceException(String::class).message shouldBe """
LazyResetDelegateInterfaceException(String::class).message shouldBe
"""
error initializing <kotlin.String>. Interfaces cannot be used with a 'by resets' delegate since they cannot be instantiated.
""".trimIndent()
}
error initializing <kotlin.String>. Interfaces cannot be used with a 'by resets' delegate since they cannot be instantiated.
""".trimIndent()
}

"abstract class exception message" - {
"abstract class exception message" - {

LazyResetDelegateAbstractException(String::class).message shouldBe """
LazyResetDelegateAbstractException(String::class).message shouldBe
"""
error initializing <kotlin.String>. Abstract classes cannot be used with a 'by resets' delegate since they cannot be instantiated.
""".trimIndent()
}
error initializing <kotlin.String>. Abstract classes cannot be used with a 'by resets' delegate since they cannot be instantiated.
""".trimIndent()
}

"object without Resets implementation exception message" - {
"object without Resets implementation exception message" - {

LazyResetDelegateObjectException(String::class).message shouldBe """
LazyResetDelegateObjectException(String::class).message shouldBe
"""
error initializing <kotlin.String>. Objects may not be used with a 'by resets' delegate unless they implement the LazyReset interface.
""".trimIndent()
}
})
error initializing <kotlin.String>. Objects may not be used with a 'by resets' delegate unless they implement the LazyReset interface.
""".trimIndent()
}
})
Loading

0 comments on commit ef26e44

Please sign in to comment.