diff --git a/build-support/src/main/kotlin/app/cash/redwood/buildsupport/RedwoodBuildPlugin.kt b/build-support/src/main/kotlin/app/cash/redwood/buildsupport/RedwoodBuildPlugin.kt index 6933297591..64ecf9a989 100644 --- a/build-support/src/main/kotlin/app/cash/redwood/buildsupport/RedwoodBuildPlugin.kt +++ b/build-support/src/main/kotlin/app/cash/redwood/buildsupport/RedwoodBuildPlugin.kt @@ -47,18 +47,18 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile -private const val redwoodGroupId = "app.cash.redwood" +private const val REDWOOD_GROUP_ID = "app.cash.redwood" // HEY! If you change the major version update release.yaml doc folder. -private const val redwoodVersion = "0.8.0-SNAPSHOT" +private const val REDWOOD_VERSION = "0.8.0-SNAPSHOT" @Suppress("unused") // Invoked reflectively by Gradle. class RedwoodBuildPlugin : Plugin { private lateinit var libs: LibrariesForLibs override fun apply(target: Project) { - target.group = redwoodGroupId - target.version = redwoodVersion + target.group = REDWOOD_GROUP_ID + target.version = REDWOOD_VERSION libs = target.extensions.getByName("libs") as LibrariesForLibs @@ -101,7 +101,10 @@ class RedwoodBuildPlugin : Plugin { it.targetExclude("src/test/fixture/**/build/**") } it.ktlint(libs.ktlint.get().version).editorConfigOverride( - mapOf("ktlint_standard_filename" to "disabled"), + mapOf( + "ktlint_standard_filename" to "disabled", + "ktlint_function_naming_ignore_when_annotated_with" to "Composable", + ), ) it.licenseHeaderFile(licenseHeaderFile) } @@ -200,7 +203,8 @@ class RedwoodBuildPlugin : Plugin { private fun Project.configureCommonKotlin() { tasks.withType(KotlinCompile::class.java).configureEach { it.kotlinOptions.freeCompilerArgs += listOf( - "-progressive", // https://kotlinlang.org/docs/whatsnew13.html#progressive-mode + // https://kotlinlang.org/docs/whatsnew13.html#progressive-mode + "-progressive", "-Xexpect-actual-classes", ) } @@ -307,7 +311,7 @@ private class RedwoodBuildExtensionImpl(private val project: Project) : RedwoodB signAllPublications() } - coordinates(redwoodGroupId, project.name, redwoodVersion) + coordinates(REDWOOD_GROUP_ID, project.name, REDWOOD_VERSION) pom { pom -> pom.name.set(project.name) @@ -424,7 +428,7 @@ private class RedwoodBuildExtensionImpl(private val project: Project) : RedwoodB it.isCanBeResolved = false it.isCanBeConsumed = true it.attributes { - it.attribute(ziplineAttribute, ziplineAttributeValue) + it.attribute(ziplineAttribute, ZIPLINE_ATTRIBUTE_VALUE) } } project.artifacts.add(ziplineConfiguration.name, zipTask) @@ -447,7 +451,7 @@ private class RedwoodBuildExtensionImpl(private val project: Project) : RedwoodB it.isCanBeResolved = true it.isCanBeConsumed = false it.attributes { - it.attribute(ziplineAttribute, ziplineAttributeValue) + it.attribute(ziplineAttribute, ZIPLINE_ATTRIBUTE_VALUE) } } project.dependencies.add(ziplineConfiguration.name, dependencyNotation) @@ -468,4 +472,4 @@ private class RedwoodBuildExtensionImpl(private val project: Project) : RedwoodB } private val ziplineAttribute = Attribute.of("zipline", String::class.java) -private const val ziplineAttributeValue = "yep" +private const val ZIPLINE_ATTRIBUTE_VALUE = "yep" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7d8ea86667..1936d65106 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -78,7 +78,7 @@ jimfs = "com.google.jimfs:jimfs:1.3.0" coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" } coil-core = { module = "io.coil-kt:coil", version.ref = "coil" } turbine = "app.cash.turbine:turbine:1.0.0" -ktlint = "com.pinterest:ktlint:0.50.0" +ktlint = "com.pinterest.ktlint:ktlint-cli:1.0.1" googleJavaFormat = "com.google.googlejavaformat:google-java-format:1.18.1" poko-gradlePlugin = "dev.drewhamilton.poko:poko-gradle-plugin:0.15.0" diff --git a/redwood-compose/src/commonMain/kotlin/app/cash/redwood/compose/RedwoodComposition.kt b/redwood-compose/src/commonMain/kotlin/app/cash/redwood/compose/RedwoodComposition.kt index 2b31f41085..d9fa2d3288 100644 --- a/redwood-compose/src/commonMain/kotlin/app/cash/redwood/compose/RedwoodComposition.kt +++ b/redwood-compose/src/commonMain/kotlin/app/cash/redwood/compose/RedwoodComposition.kt @@ -198,13 +198,15 @@ public inline fun

, W : Widget<*>> RedwoodComposeNode( // Perform an explicit !! on the return value to avoid the Kotlin compiler inserting a huge // string into the output as an error message for an otherwise implicit null check. @Suppress( - "UNCHECKED_CAST", // Safe so long as you use generated composition function. + // Safe so long as you use generated composition function. + "UNCHECKED_CAST", "UNNECESSARY_NOT_NULL_ASSERTION", ) val applier = currentComposer.applier!! as RedwoodApplier currentComposer.createNode { - @Suppress("UNCHECKED_CAST") // Safe so long as you use generated composition function. + // Safe so long as you use generated composition function. + @Suppress("UNCHECKED_CAST") WidgetNode(applier, factory(applier.provider as P) as Widget) } } else { diff --git a/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodComposePlugin.kt b/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodComposePlugin.kt index a98da47ec6..3721578224 100644 --- a/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodComposePlugin.kt +++ b/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodComposePlugin.kt @@ -29,8 +29,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.wasm import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact import org.jetbrains.kotlin.gradle.plugin.SubpluginOption -private const val extensionName = "redwood" -private const val redwoodComposeArtifactId = "redwood-compose" +private const val EXTENSION_NAME = "redwood" +private const val REDWOOD_COMPOSE_ARTIFACT_ID = "redwood-compose" public class RedwoodComposePlugin : KotlinCompilerPluginSupportPlugin { private lateinit var extension: RedwoodComposeExtension @@ -38,7 +38,7 @@ public class RedwoodComposePlugin : KotlinCompilerPluginSupportPlugin { override fun apply(target: Project) { super.apply(target) - extension = target.extensions.create(extensionName, RedwoodComposeExtension::class.java) + extension = target.extensions.create(EXTENSION_NAME, RedwoodComposeExtension::class.java) target.plugins.withId("org.jetbrains.compose") { throw IllegalStateException( @@ -52,7 +52,7 @@ public class RedwoodComposePlugin : KotlinCompilerPluginSupportPlugin { | sourceSets { | commonMain { | dependencies { - | implementation("${target.redwoodDependency(redwoodComposeArtifactId)}") + | implementation("${target.redwoodDependency(REDWOOD_COMPOSE_ARTIFACT_ID)}") | } | } | } @@ -71,7 +71,7 @@ public class RedwoodComposePlugin : KotlinCompilerPluginSupportPlugin { |within an Android Compose-based project you only need to add the runtime dependency: | | dependencies { - | implementation("${target.redwoodDependency(redwoodComposeArtifactId)}") + | implementation("${target.redwoodDependency(REDWOOD_COMPOSE_ARTIFACT_ID)}") | } """.trimMargin() } @@ -94,7 +94,7 @@ public class RedwoodComposePlugin : KotlinCompilerPluginSupportPlugin { 3 -> SubpluginArtifact(parts[0], parts[1], parts[2]) else -> error( """ - |Illegal format of '$extensionName.${RedwoodComposeExtension::kotlinCompilerPlugin.name}' property. + |Illegal format of '$EXTENSION_NAME.${RedwoodComposeExtension::kotlinCompilerPlugin.name}' property. |Expected format: either '' or '::' |Actual value: '$plugin' """.trimMargin(), @@ -104,7 +104,7 @@ public class RedwoodComposePlugin : KotlinCompilerPluginSupportPlugin { override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider> { kotlinCompilation.dependencies { - api(project.redwoodDependency(redwoodComposeArtifactId)) + api(project.redwoodDependency(REDWOOD_COMPOSE_ARTIFACT_ID)) } when (kotlinCompilation.platformType) { diff --git a/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodLintPlugin.kt b/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodLintPlugin.kt index 4c5afcfd61..c4ab3d185a 100644 --- a/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodLintPlugin.kt +++ b/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodLintPlugin.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.androidJvm import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.common import org.jetbrains.kotlin.gradle.plugin.KotlinTarget -private const val baseTaskName = "redwoodLint" +private const val BASE_TASK_NAME = "redwoodLint" @Suppress("unused") // Invoked reflectively by Gradle. public class RedwoodLintPlugin : Plugin { @@ -51,7 +51,7 @@ public class RedwoodLintPlugin : Plugin { } val task = if (project.plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) { - val rootTask = project.tasks.register(baseTaskName) { + val rootTask = project.tasks.register(BASE_TASK_NAME) { it.group = VERIFICATION_GROUP it.description = taskDescription("all Kotlin targets") } @@ -68,7 +68,7 @@ public class RedwoodLintPlugin : Plugin { checkNotNull(androidPlugin) { "Kotlin Android plugin requires either Android application or library plugin" } - val rootTask = project.tasks.register(baseTaskName) { + val rootTask = project.tasks.register(BASE_TASK_NAME) { it.group = VERIFICATION_GROUP it.description = taskDescription("all Kotlin targets") } @@ -110,7 +110,7 @@ private fun configureKotlinAndroidVariants( } variants.configureEach { variant -> val taskName = buildString { - append(baseTaskName) + append(BASE_TASK_NAME) if (prefix) { append("Android") } @@ -146,7 +146,7 @@ private fun configureKotlinMultiplatformTargets( val task = createKotlinTargetRedwoodLintTask( project, target, - taskName = baseTaskName + target.name.replaceFirstChar { it.titlecase(ROOT) }, + taskName = BASE_TASK_NAME + target.name.replaceFirstChar { it.titlecase(ROOT) }, ) rootTask.configure { it.dependsOn(task) @@ -158,7 +158,7 @@ private fun configureKotlinJvmProject( project: Project, ): TaskProvider { val kotlin = project.extensions.getByType(KotlinJvmProjectExtension::class.java) - return createKotlinTargetRedwoodLintTask(project, kotlin.target, baseTaskName) + return createKotlinTargetRedwoodLintTask(project, kotlin.target, BASE_TASK_NAME) } private fun createKotlinTargetRedwoodLintTask( diff --git a/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodSchemaApiTasks.kt b/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodSchemaApiTasks.kt index 77c3dca4e6..dfe04dc88e 100644 --- a/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodSchemaApiTasks.kt +++ b/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodSchemaApiTasks.kt @@ -128,7 +128,7 @@ private abstract class RedwoodSchemaApiWorker @Inject constructor( "--file", parameters.apiFile.get().asFile.absolutePath, "--fix-with", - RedwoodApiGenerateTaskName, + REDWOOD_API_GENERATE_TASK_NAME, "--class-path", parameters.classpath.files.joinToString(File.pathSeparator), parameters.schemaType.get(), diff --git a/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodSchemaPlugin.kt b/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodSchemaPlugin.kt index 6213a8108b..990081c33c 100644 --- a/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodSchemaPlugin.kt +++ b/redwood-gradle-plugin/src/main/kotlin/app/cash/redwood/gradle/RedwoodSchemaPlugin.kt @@ -75,7 +75,7 @@ public class RedwoodSchemaPlugin : Plugin { if (extension.apiTracking.get()) { val apiFile = project.layout.projectDirectory.file("redwood-api.xml") - project.tasks.register(RedwoodApiGenerateTaskName, RedwoodSchemaApiGenerateTask::class.java) { + project.tasks.register(REDWOOD_API_GENERATE_TASK_NAME, RedwoodSchemaApiGenerateTask::class.java) { it.group = BUILD_GROUP it.description = "Write an updated API tracking file for the current schema" @@ -110,4 +110,4 @@ public class RedwoodSchemaPlugin : Plugin { } } -internal const val RedwoodApiGenerateTaskName = "redwoodApiGenerate" +internal const val REDWOOD_API_GENERATE_TASK_NAME = "redwoodApiGenerate" diff --git a/redwood-layout-composeui/src/commonMain/kotlin/app/cash/redwood/layout/composeui/ComposeUiFlexContainer.kt b/redwood-layout-composeui/src/commonMain/kotlin/app/cash/redwood/layout/composeui/ComposeUiFlexContainer.kt index 586a8af0b4..fe3c55e324 100644 --- a/redwood-layout-composeui/src/commonMain/kotlin/app/cash/redwood/layout/composeui/ComposeUiFlexContainer.kt +++ b/redwood-layout-composeui/src/commonMain/kotlin/app/cash/redwood/layout/composeui/ComposeUiFlexContainer.kt @@ -162,12 +162,12 @@ internal class ComposeUiFlexContainer( val constrainedWidth = if (constraints.hasFixedWidth) { constraints.maxWidth.toFloat() } else { - Size.Undefined + Size.UNDEFINED } val constrainedHeight = if (constraints.hasFixedHeight) { constraints.maxHeight.toFloat() } else { - Size.Undefined + Size.UNDEFINED } rootNode.measure(constrainedWidth, constrainedHeight) diff --git a/redwood-layout-uiview/src/commonMain/kotlin/app/cash/redwood/layout/uiview/YogaUIView.kt b/redwood-layout-uiview/src/commonMain/kotlin/app/cash/redwood/layout/uiview/YogaUIView.kt index f58cbdde0d..075a39db9d 100644 --- a/redwood-layout-uiview/src/commonMain/kotlin/app/cash/redwood/layout/uiview/YogaUIView.kt +++ b/redwood-layout-uiview/src/commonMain/kotlin/app/cash/redwood/layout/uiview/YogaUIView.kt @@ -38,7 +38,7 @@ internal class YogaUIView( } override fun intrinsicContentSize(): CValue { - return calculateLayoutWithSize(CGSizeMake(Size.Undefined.toDouble(), Size.Undefined.toDouble())) + return calculateLayoutWithSize(CGSizeMake(Size.UNDEFINED.toDouble(), Size.UNDEFINED.toDouble())) } override fun sizeThatFits(size: CValue): CValue { @@ -62,9 +62,9 @@ internal class YogaUIView( // combined into one call. val scrollSize = bounds.useContents { if (rootNode.flexDirection == FlexDirection.Column) { - CGSizeMake(width, Size.Undefined.toDouble()) + CGSizeMake(width, Size.UNDEFINED.toDouble()) } else { - CGSizeMake(Size.Undefined.toDouble(), height) + CGSizeMake(Size.UNDEFINED.toDouble(), height) } } val contentSize = calculateLayoutWithSize(scrollSize) @@ -113,7 +113,7 @@ internal class YogaUIView( private fun sizeForConstraintsDimension(constraint: Constraint, dimension: Double): Double { if (constraint == Constraint.Wrap || dimension == UIViewNoIntrinsicMetric) { - return Size.Undefined.toDouble() + return Size.UNDEFINED.toDouble() } else { return dimension } diff --git a/redwood-layout-view/src/main/kotlin/app/cash/redwood/layout/view/YogaLayout.kt b/redwood-layout-view/src/main/kotlin/app/cash/redwood/layout/view/YogaLayout.kt index 763ba74875..adab3e9f12 100644 --- a/redwood-layout-view/src/main/kotlin/app/cash/redwood/layout/view/YogaLayout.kt +++ b/redwood-layout-view/src/main/kotlin/app/cash/redwood/layout/view/YogaLayout.kt @@ -67,10 +67,10 @@ internal class YogaLayout( } private fun calculateLayout(widthSpec: Int, heightSpec: Int) { - rootNode.requestedWidth = Size.Undefined - rootNode.requestedMaxWidth = Size.Undefined - rootNode.requestedHeight = Size.Undefined - rootNode.requestedMaxHeight = Size.Undefined + rootNode.requestedWidth = Size.UNDEFINED + rootNode.requestedMaxWidth = Size.UNDEFINED + rootNode.requestedHeight = Size.UNDEFINED + rootNode.requestedMaxHeight = Size.UNDEFINED val widthSize = MeasureSpec.getSize(widthSpec).toFloat() when (MeasureSpec.getMode(widthSpec)) { @@ -90,7 +90,7 @@ internal class YogaLayout( applyModifier(node, index) } - rootNode.measure(Size.Undefined, Size.Undefined) + rootNode.measure(Size.UNDEFINED, Size.UNDEFINED) } } diff --git a/redwood-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt b/redwood-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt index 73eef988b4..6cedec7f70 100644 --- a/redwood-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt +++ b/redwood-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt @@ -29,7 +29,7 @@ import app.cash.redwood.layout.api.CrossAxisAlignment import app.cash.redwood.ui.Margin import kotlin.jvm.JvmName -private const val OffscreenItemsBufferCount = 30 +private const val OFFSCREEN_ITEMS_BUFFER_COUNT = 30 @Composable internal fun LazyList( @@ -45,8 +45,8 @@ internal fun LazyList( ) { val itemProvider = rememberLazyListItemProvider(content) val itemCount = itemProvider.itemCount - val itemsBefore = (state.firstIndex - OffscreenItemsBufferCount / 2).coerceAtLeast(0) - val itemsAfter = (itemCount - (state.lastIndex + OffscreenItemsBufferCount / 2).coerceAtMost(itemCount)).coerceAtLeast(0) + val itemsBefore = (state.firstIndex - OFFSCREEN_ITEMS_BUFFER_COUNT / 2).coerceAtLeast(0) + val itemsAfter = (itemCount - (state.lastIndex + OFFSCREEN_ITEMS_BUFFER_COUNT / 2).coerceAtMost(itemCount)).coerceAtLeast(0) // TODO(jwilson): drop this down to 20 once this is fixed: // https://github.com/cashapp/redwood/issues/1551 var placeholderPoolSize by remember { mutableStateOf(30) } @@ -98,8 +98,8 @@ internal fun RefreshableLazyList( ) { val itemProvider = rememberLazyListItemProvider(content) val itemCount = itemProvider.itemCount - val itemsBefore = (state.firstIndex - OffscreenItemsBufferCount / 2).coerceAtLeast(0) - val itemsAfter = (itemCount - (state.lastIndex + OffscreenItemsBufferCount / 2).coerceAtMost(itemCount)).coerceAtLeast(0) + val itemsBefore = (state.firstIndex - OFFSCREEN_ITEMS_BUFFER_COUNT / 2).coerceAtLeast(0) + val itemsAfter = (itemCount - (state.lastIndex + OFFSCREEN_ITEMS_BUFFER_COUNT / 2).coerceAtMost(itemCount)).coerceAtLeast(0) var placeholderPoolSize by remember { mutableStateOf(20) } RefreshableLazyList( isVertical, diff --git a/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt b/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt index a48f162202..5cbb13284d 100644 --- a/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt +++ b/redwood-lazylayout-uiview/src/commonMain/kotlin/app/cash/redwood/lazylayout/uiview/UIViewLazyList.kt @@ -138,7 +138,7 @@ internal open class UIViewLazyList( index: Int, ): LazyListContainerCell { val result = tableView.dequeueReusableCellWithIdentifier( - identifier = reuseIdentifier, + identifier = REUSE_IDENTIFIER, forIndexPath = NSIndexPath.indexPathForItem(index.convert(), 0.convert()), ) as LazyListContainerCell require(result.binding == null) @@ -181,9 +181,9 @@ internal open class UIViewLazyList( separatorStyle = UITableViewCellSeparatorStyleNone registerClass( - cellClass = LazyListContainerCell(UITableViewCellStyle.UITableViewCellStyleDefault, reuseIdentifier) + cellClass = LazyListContainerCell(UITableViewCellStyle.UITableViewCellStyleDefault, REUSE_IDENTIFIER) .initWithFrame(CGRectZero.readValue()).classForCoder() as ObjCClass?, - forCellReuseIdentifier = reuseIdentifier, + forCellReuseIdentifier = REUSE_IDENTIFIER, ) } } @@ -232,7 +232,7 @@ internal open class UIViewLazyList( } } -private const val reuseIdentifier = "LazyListContainerCell" +private const val REUSE_IDENTIFIER = "LazyListContainerCell" internal class LazyListContainerCell( style: UITableViewCellStyle, diff --git a/redwood-protocol-guest/src/commonMain/kotlin/app/cash/redwood/protocol/guest/ProtocolRedwoodComposition.kt b/redwood-protocol-guest/src/commonMain/kotlin/app/cash/redwood/protocol/guest/ProtocolRedwoodComposition.kt index dcc2e94cad..e5bce221f3 100644 --- a/redwood-protocol-guest/src/commonMain/kotlin/app/cash/redwood/protocol/guest/ProtocolRedwoodComposition.kt +++ b/redwood-protocol-guest/src/commonMain/kotlin/app/cash/redwood/protocol/guest/ProtocolRedwoodComposition.kt @@ -31,6 +31,7 @@ import kotlinx.coroutines.flow.StateFlow * @param scope A [CoroutineScope] whose [coroutineContext][kotlin.coroutines.CoroutineContext] * must have a [MonotonicFrameClock] key which is being ticked. */ +@Suppress("FunctionName") public fun ProtocolRedwoodComposition( scope: CoroutineScope, bridge: ProtocolBridge, diff --git a/redwood-protocol-guest/src/commonTest/kotlin/app/cash/redwood/protocol/guest/ProtocolTest.kt b/redwood-protocol-guest/src/commonTest/kotlin/app/cash/redwood/protocol/guest/ProtocolTest.kt index 5f197120a0..8ee5b5beff 100644 --- a/redwood-protocol-guest/src/commonTest/kotlin/app/cash/redwood/protocol/guest/ProtocolTest.kt +++ b/redwood-protocol-guest/src/commonTest/kotlin/app/cash/redwood/protocol/guest/ProtocolTest.kt @@ -95,17 +95,23 @@ class ProtocolTest { assertThat(composition.awaitSnapshot()).isEqualTo( listOf( - Create(Id(1), WidgetTag(1)), // Row + // Row + Create(Id(1), WidgetTag(1)), ModifierChange(Id(1)), - Create(Id(2), WidgetTag(3)), // Text + // Text + Create(Id(2), WidgetTag(3)), ModifierChange(Id(2)), - PropertyChange(Id(2), PropertyTag(1), JsonPrimitive("hey")), // text + // text + PropertyChange(Id(2), PropertyTag(1), JsonPrimitive("hey")), ChildrenChange.Add(Id(1), ChildrenTag(1), Id(2), 0), - Create(Id(3), WidgetTag(1)), // Row + // Row + Create(Id(3), WidgetTag(1)), ModifierChange(Id(3)), - Create(Id(4), WidgetTag(3)), // Text + // Text + Create(Id(4), WidgetTag(3)), ModifierChange(Id(4)), - PropertyChange(Id(4), PropertyTag(1), JsonPrimitive("hello")), // text + // text + PropertyChange(Id(4), PropertyTag(1), JsonPrimitive("hello")), ChildrenChange.Add(Id(3), ChildrenTag(1), Id(4), 0), ChildrenChange.Add(Id(1), ChildrenTag(1), Id(3), 1), ChildrenChange.Add(Id.Root, ChildrenTag.Root, Id(1), 0), @@ -123,20 +129,29 @@ class ProtocolTest { assertThat(composition.awaitSnapshot()).isEqualTo( listOf( - Create(Id(1), WidgetTag(4)), // Button + // Button + Create(Id(1), WidgetTag(4)), ModifierChange(Id(1)), - PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("hi")), // text - PropertyChange(Id(1), PropertyTag(2), JsonPrimitive(false)), // onClick + // text + PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("hi")), + // onClick + PropertyChange(Id(1), PropertyTag(2), JsonPrimitive(false)), ChildrenChange.Add(Id.Root, ChildrenTag.Root, Id(1), 0), - Create(Id(2), WidgetTag(4)), // Button + // Button + Create(Id(2), WidgetTag(4)), ModifierChange(Id(2)), - PropertyChange(Id(2), PropertyTag(1), JsonPrimitive("hi")), // text - PropertyChange(Id(2), PropertyTag(2), JsonPrimitive(true)), // onClick + // text + PropertyChange(Id(2), PropertyTag(1), JsonPrimitive("hi")), + // onClick + PropertyChange(Id(2), PropertyTag(2), JsonPrimitive(true)), ChildrenChange.Add(Id.Root, ChildrenTag.Root, Id(2), 1), - Create(Id(3), WidgetTag(7)), // Button2 + // Button2 + Create(Id(3), WidgetTag(7)), ModifierChange(Id(3)), - PropertyChange(Id(3), PropertyTag(1), JsonPrimitive("hi")), // text - PropertyChange(Id(3), PropertyTag(2), JsonPrimitive(true)), // onClick + // text + PropertyChange(Id(3), PropertyTag(1), JsonPrimitive("hi")), + // onClick + PropertyChange(Id(3), PropertyTag(2), JsonPrimitive(true)), ChildrenChange.Add(Id.Root, ChildrenTag.Root, Id(3), 2), ), ) @@ -150,10 +165,18 @@ class ProtocolTest { Button( "state: $state", onClick = when (state) { - 0 -> { { state = 1 } } - 1 -> { { state = 2 } } - 2 -> { null } - 3 -> { null } + 0 -> { + { state = 1 } + } + 1 -> { + { state = 2 } + } + 2 -> { + null + } + 3 -> { + null + } else -> fail() }, ) @@ -161,10 +184,13 @@ class ProtocolTest { assertThat(composition.awaitSnapshot()).isEqualTo( listOf( - Create(Id(1), WidgetTag(4)), // Button + // Button + Create(Id(1), WidgetTag(4)), ModifierChange(Id(1)), - PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 0")), // text - PropertyChange(Id(1), PropertyTag(2), JsonPrimitive(true)), // onClick + // text + PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 0")), + // onClick + PropertyChange(Id(1), PropertyTag(2), JsonPrimitive(true)), ChildrenChange.Add(Id.Root, ChildrenTag.Root, Id(1), 0), ), ) @@ -174,7 +200,8 @@ class ProtocolTest { assertThat(composition.awaitSnapshot()).isEqualTo( listOf( - PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 1")), // text + // text + PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 1")), ), ) @@ -183,8 +210,10 @@ class ProtocolTest { assertThat(composition.awaitSnapshot()).isEqualTo( listOf( - PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 2")), // text - PropertyChange(Id(1), PropertyTag(2), JsonPrimitive(false)), // text + // text + PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 2")), + // text + PropertyChange(Id(1), PropertyTag(2), JsonPrimitive(false)), ), ) @@ -193,7 +222,8 @@ class ProtocolTest { assertThat(composition.awaitSnapshot()).isEqualTo( listOf( - PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 3")), // text + // text + PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 3")), ), ) } @@ -206,8 +236,12 @@ class ProtocolTest { Button2( "state: $state", onClick = when (state) { - 0 -> { { state = 1 } } - 1 -> { { state = 2 } } + 0 -> { + { state = 1 } + } + 1 -> { + { state = 2 } + } else -> fail() }, ) @@ -215,10 +249,13 @@ class ProtocolTest { assertThat(composition.awaitSnapshot()).isEqualTo( listOf( - Create(Id(1), WidgetTag(7)), // Button2 + // Button2 + Create(Id(1), WidgetTag(7)), ModifierChange(Id(1)), - PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 0")), // text - PropertyChange(Id(1), PropertyTag(2), JsonPrimitive(true)), // onClick + // text + PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 0")), + // onClick + PropertyChange(Id(1), PropertyTag(2), JsonPrimitive(true)), ChildrenChange.Add(Id.Root, ChildrenTag.Root, Id(1), 0), ), ) @@ -228,7 +265,8 @@ class ProtocolTest { assertThat(composition.awaitSnapshot()).isEqualTo( listOf( - PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 1")), // text + // text + PropertyChange(Id(1), PropertyTag(1), JsonPrimitive("state: 1")), ), ) } diff --git a/redwood-protocol-guest/src/nonJsMain/kotlin/app/cash/redwood/protocol/guest/PlatformList.kt b/redwood-protocol-guest/src/nonJsMain/kotlin/app/cash/redwood/protocol/guest/PlatformList.kt index 8c164e3f94..623eec1638 100644 --- a/redwood-protocol-guest/src/nonJsMain/kotlin/app/cash/redwood/protocol/guest/PlatformList.kt +++ b/redwood-protocol-guest/src/nonJsMain/kotlin/app/cash/redwood/protocol/guest/PlatformList.kt @@ -16,14 +16,18 @@ package app.cash.redwood.protocol.guest @Suppress( - "ACTUAL_TYPE_ALIAS_NOT_TO_CLASS", // ArrayList itself aliases to j.u.ArrayList on JVM. - "ACTUAL_WITHOUT_EXPECT", // https://youtrack.jetbrains.com/issue/KT-37316 + // ArrayList itself aliases to j.u.ArrayList on JVM. + "ACTUAL_TYPE_ALIAS_NOT_TO_CLASS", + // https://youtrack.jetbrains.com/issue/KT-37316 + "ACTUAL_WITHOUT_EXPECT", ) internal actual typealias PlatformList = ArrayList @Suppress( - "NOTHING_TO_INLINE", // Explicitly trying to be zero-overhead. - "KotlinRedundantDiagnosticSuppress", // Inline warning only happens on JVM source set. + // Explicitly trying to be zero-overhead. + "NOTHING_TO_INLINE", + // Inline warning only happens on JVM source set. + "KotlinRedundantDiagnosticSuppress", ) internal actual inline fun PlatformList.asList(): List { return this diff --git a/redwood-protocol-guest/src/nonJsMain/kotlin/app/cash/redwood/protocol/guest/PlatformMap.kt b/redwood-protocol-guest/src/nonJsMain/kotlin/app/cash/redwood/protocol/guest/PlatformMap.kt index 2fecbf41c3..057e16624d 100644 --- a/redwood-protocol-guest/src/nonJsMain/kotlin/app/cash/redwood/protocol/guest/PlatformMap.kt +++ b/redwood-protocol-guest/src/nonJsMain/kotlin/app/cash/redwood/protocol/guest/PlatformMap.kt @@ -16,7 +16,9 @@ package app.cash.redwood.protocol.guest @Suppress( - "ACTUAL_TYPE_ALIAS_NOT_TO_CLASS", // LinkedHashMap itself aliases to j.u.LinkedHashMap on JVM. - "ACTUAL_WITHOUT_EXPECT", // https://youtrack.jetbrains.com/issue/KT-37316 + // LinkedHashMap itself aliases to j.u.LinkedHashMap on JVM. + "ACTUAL_TYPE_ALIAS_NOT_TO_CLASS", + // https://youtrack.jetbrains.com/issue/KT-37316 + "ACTUAL_WITHOUT_EXPECT", ) internal actual typealias PlatformMap = LinkedHashMap diff --git a/redwood-protocol-host/src/commonTest/kotlin/app/cash/redwood/protocol/widget/ProtocolBridgeTest.kt b/redwood-protocol-host/src/commonTest/kotlin/app/cash/redwood/protocol/widget/ProtocolBridgeTest.kt index e87b60393e..f9564d2ce9 100644 --- a/redwood-protocol-host/src/commonTest/kotlin/app/cash/redwood/protocol/widget/ProtocolBridgeTest.kt +++ b/redwood-protocol-host/src/commonTest/kotlin/app/cash/redwood/protocol/widget/ProtocolBridgeTest.kt @@ -50,7 +50,8 @@ class ProtocolBridgeTest { val changes = listOf( Create( id = Id.Root, - tag = WidgetTag(4), // Button + // Button + tag = WidgetTag(4), ), ) val t = assertFailsWith { @@ -74,7 +75,8 @@ class ProtocolBridgeTest { val changes = listOf( Create( id = Id(1), - tag = WidgetTag(4), // Button + // Button + tag = WidgetTag(4), ), ) bridge.sendChanges(changes) @@ -102,7 +104,8 @@ class ProtocolBridgeTest { listOf( Create( id = Id(1), - tag = WidgetTag(4), // Button + // Button + tag = WidgetTag(4), ), Add( id = Id.Root, @@ -130,7 +133,8 @@ class ProtocolBridgeTest { val updateButtonText = listOf( PropertyChange( id = Id(1), - tag = PropertyTag(1), // text + // text + tag = PropertyTag(1), value = JsonPrimitive("hello"), ), ) @@ -157,7 +161,8 @@ class ProtocolBridgeTest { // Initial Button add does not trigger update callback (it's implicit because of insert). bridge.sendChanges( listOf( - Create(Id(1), WidgetTag(4)), // Button + // Button + Create(Id(1), WidgetTag(4)), ModifierChange(Id(1)), Add(Id.Root, ChildrenTag.Root, Id(1), 0), ), diff --git a/redwood-runtime/src/androidMain/kotlin/app/cash/redwood/ui/density.kt b/redwood-runtime/src/androidMain/kotlin/app/cash/redwood/ui/density.kt index 40b7652bd6..0b20f154f9 100644 --- a/redwood-runtime/src/androidMain/kotlin/app/cash/redwood/ui/density.kt +++ b/redwood-runtime/src/androidMain/kotlin/app/cash/redwood/ui/density.kt @@ -20,7 +20,7 @@ import android.content.res.Resources // Android uses 2.75 as a density scale for most recent Pixel devices and iOS // uses 3. This aligns the two so the generic values used by Redwood layout are // visually similar on both platforms. -internal actual const val DensityMultiplier = 1.1 +internal actual const val DENSITY_MULTIPLIER = 1.1 /** * Create a [Density] from the device's [Resources]. diff --git a/redwood-runtime/src/commonMain/kotlin/app/cash/redwood/ui/Density.kt b/redwood-runtime/src/commonMain/kotlin/app/cash/redwood/ui/Density.kt index a6006b5f90..51828f1e52 100644 --- a/redwood-runtime/src/commonMain/kotlin/app/cash/redwood/ui/Density.kt +++ b/redwood-runtime/src/commonMain/kotlin/app/cash/redwood/ui/Density.kt @@ -38,7 +38,7 @@ public value class Density( /** Convert a [Dp] into a pixel value. */ public fun Dp.toPx(): Double { - return value * DensityMultiplier * rawDensity + return value * DENSITY_MULTIPLIER * rawDensity } /** Convert a [Dp] into the nearest integer pixel value. */ @@ -48,17 +48,17 @@ public value class Density( /** Convert a pixel value into a [Dp]. */ public fun Int.toDp(): Dp { - return Dp(this / DensityMultiplier / rawDensity) + return Dp(this / DENSITY_MULTIPLIER / rawDensity) } /** Convert a pixel value into a [Dp]. */ public fun Float.toDp(): Dp { - return Dp(this / DensityMultiplier / rawDensity) + return Dp(this / DENSITY_MULTIPLIER / rawDensity) } /** Convert a pixel value into a [Dp]. */ public fun Double.toDp(): Dp { - return Dp(this / DensityMultiplier / rawDensity) + return Dp(this / DENSITY_MULTIPLIER / rawDensity) } /** Empty companion object used for extensions. */ @@ -69,4 +69,4 @@ public value class Density( * A multiplier that's used to normalize the density values of each * target platform so [Dp] values look similar on each device. */ -internal expect val DensityMultiplier: Double +internal expect val DENSITY_MULTIPLIER: Double diff --git a/redwood-runtime/src/commonMain/kotlin/app/cash/redwood/ui/Dp.kt b/redwood-runtime/src/commonMain/kotlin/app/cash/redwood/ui/Dp.kt index 74a480aaac..a9de14a6e9 100644 --- a/redwood-runtime/src/commonMain/kotlin/app/cash/redwood/ui/Dp.kt +++ b/redwood-runtime/src/commonMain/kotlin/app/cash/redwood/ui/Dp.kt @@ -57,7 +57,7 @@ public inline val Double.dp: Dp get() = Dp(toDouble()) * device-specific density-independent pixel value. */ public fun Dp.toPlatformDp(): Double { - return value / DensityMultiplier + return value / DENSITY_MULTIPLIER } /** @@ -65,5 +65,5 @@ public fun Dp.toPlatformDp(): Double { * device-agnostic density-independent pixel value. */ public fun Dp.Companion.fromPlatformDp(value: Double): Dp { - return Dp(value * DensityMultiplier) + return Dp(value * DENSITY_MULTIPLIER) } diff --git a/redwood-runtime/src/iosMain/kotlin/app/cash/redwood/ui/density.kt b/redwood-runtime/src/iosMain/kotlin/app/cash/redwood/ui/density.kt index 9d43407e28..2ca411dbf2 100644 --- a/redwood-runtime/src/iosMain/kotlin/app/cash/redwood/ui/density.kt +++ b/redwood-runtime/src/iosMain/kotlin/app/cash/redwood/ui/density.kt @@ -20,4 +20,4 @@ public val Density.Companion.Default: Density get() = DefaultDensity private val DefaultDensity = Density(1.0) -internal actual const val DensityMultiplier = 1.0 +internal actual const val DENSITY_MULTIPLIER = 1.0 diff --git a/redwood-runtime/src/jsMain/kotlin/app/cash/redwood/ui/density.kt b/redwood-runtime/src/jsMain/kotlin/app/cash/redwood/ui/density.kt index e02e4a84a9..4d3a7460d3 100644 --- a/redwood-runtime/src/jsMain/kotlin/app/cash/redwood/ui/density.kt +++ b/redwood-runtime/src/jsMain/kotlin/app/cash/redwood/ui/density.kt @@ -15,4 +15,4 @@ */ package app.cash.redwood.ui -internal actual const val DensityMultiplier = 1.0 +internal actual const val DENSITY_MULTIPLIER = 1.0 diff --git a/redwood-runtime/src/jvmMain/kotlin/app/cash/redwood/ui/density.kt b/redwood-runtime/src/jvmMain/kotlin/app/cash/redwood/ui/density.kt index e02e4a84a9..4d3a7460d3 100644 --- a/redwood-runtime/src/jvmMain/kotlin/app/cash/redwood/ui/density.kt +++ b/redwood-runtime/src/jvmMain/kotlin/app/cash/redwood/ui/density.kt @@ -15,4 +15,4 @@ */ package app.cash.redwood.ui -internal actual const val DensityMultiplier = 1.0 +internal actual const val DENSITY_MULTIPLIER = 1.0 diff --git a/redwood-runtime/src/macosMain/kotlin/app/cash/redwood/ui/density.kt b/redwood-runtime/src/macosMain/kotlin/app/cash/redwood/ui/density.kt index 5b19c469d4..40ebfc52a5 100644 --- a/redwood-runtime/src/macosMain/kotlin/app/cash/redwood/ui/density.kt +++ b/redwood-runtime/src/macosMain/kotlin/app/cash/redwood/ui/density.kt @@ -20,4 +20,4 @@ public val Density.Companion.Default: Density get() = DefaultDensity private val DefaultDensity = Density(1.0) -internal actual const val DensityMultiplier = 1.0 +internal actual const val DENSITY_MULTIPLIER = 1.0 diff --git a/redwood-testing/src/commonMain/kotlin/app/cash/redwood/testing/TestRedwoodComposition.kt b/redwood-testing/src/commonMain/kotlin/app/cash/redwood/testing/TestRedwoodComposition.kt index 6a9c45c6f4..03d90c828a 100644 --- a/redwood-testing/src/commonMain/kotlin/app/cash/redwood/testing/TestRedwoodComposition.kt +++ b/redwood-testing/src/commonMain/kotlin/app/cash/redwood/testing/TestRedwoodComposition.kt @@ -40,6 +40,8 @@ import kotlinx.coroutines.withTimeout /** * Performs Redwood composition strictly for testing. */ + +@Suppress("FunctionName") // ktlint bug public fun TestRedwoodComposition( scope: CoroutineScope, provider: Widget.Provider, diff --git a/redwood-tooling-codegen/src/main/kotlin/app/cash/redwood/tooling/codegen/sharedHelpers.kt b/redwood-tooling-codegen/src/main/kotlin/app/cash/redwood/tooling/codegen/sharedHelpers.kt index a12fdbc73f..4816e95d41 100644 --- a/redwood-tooling-codegen/src/main/kotlin/app/cash/redwood/tooling/codegen/sharedHelpers.kt +++ b/redwood-tooling-codegen/src/main/kotlin/app/cash/redwood/tooling/codegen/sharedHelpers.kt @@ -60,8 +60,8 @@ internal val Event.lambdaType: TypeName internal fun Schema.composePackage(host: Schema? = null): String { return if (host == null) { - val `package` = type.names[0] - "$`package`.compose" + val packageName = type.names[0] + "$packageName.compose" } else { val hostPackage = host.type.names[0] "$hostPackage.compose.${type.flatName.lowercase()}" @@ -118,8 +118,8 @@ internal fun Schema.getWidgetFactoriesType(): ClassName { internal fun Schema.widgetPackage(host: Schema? = null): String { return if (host == null) { - val `package` = type.names[0] - "$`package`.widget" + val packageName = type.names[0] + "$packageName.widget" } else { val hostPackage = host.type.names[0] "$hostPackage.widget.${type.flatName.lowercase()}" diff --git a/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParser.kt b/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParser.kt index 3b9eecdf6b..d7c7391665 100644 --- a/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParser.kt +++ b/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParser.kt @@ -41,8 +41,8 @@ private val childrenType = Function::class.starProjectedType private val eventType = Function::class.starProjectedType private val optionalEventType = eventType.withNullability(true) -private const val maxSchemaTag = 2_000 -internal const val maxMemberTag = 1_000_000 +private const val MAX_SCHEMA_TAG = 2_000 +internal const val MAX_MEMBER_TAG = 1_000_000 private val KClass<*>.schemaAnnotation: SchemaAnnotation get() { return requireNotNull(findAnnotation()) { "Schema $qualifiedName missing @Schema annotation" } @@ -67,10 +67,10 @@ internal fun loadProtocolSchema( classLoader: ClassLoader, tag: Int = 0, ): ProtocolSchema { - require(tag in 0..maxSchemaTag) { - "$type tag must be 0 for the root or in range (0, $maxSchemaTag] as a dependency: $tag" + require(tag in 0..MAX_SCHEMA_TAG) { + "$type tag must be 0 for the root or in range (0, $MAX_SCHEMA_TAG] as a dependency: $tag" } - val tagOffset = tag * maxMemberTag + val tagOffset = tag * MAX_MEMBER_TAG val path = ParsedProtocolSchema.toEmbeddedPath(type) val schema = classLoader @@ -244,8 +244,8 @@ private fun parseWidget( ): ParsedProtocolWidget { val memberFqType = memberType.toFqType() val tag = annotation.tag - require(tag in 1 until maxMemberTag) { - "@Widget $memberFqType tag must be in range [1, $maxMemberTag): $tag" + require(tag in 1 until MAX_MEMBER_TAG) { + "@Widget $memberFqType tag must be in range [1, $MAX_MEMBER_TAG): $tag" } val traits = if (memberType.isData) { @@ -360,8 +360,8 @@ private fun parseModifier( ): ParsedProtocolModifier { val memberFqType = memberType.toFqType() val tag = annotation.tag - require(tag in 1 until maxMemberTag) { - "@Modifier $memberFqType tag must be in range [1, $maxMemberTag): $tag" + require(tag in 1 until MAX_MEMBER_TAG) { + "@Modifier $memberFqType tag must be in range [1, $MAX_MEMBER_TAG): $tag" } require(annotation.scopes.isNotEmpty()) { "@Modifier $memberFqType must have at least one scope." diff --git a/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParserFir.kt b/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParserFir.kt index d6f0eada4e..0245f1d7c0 100644 --- a/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParserFir.kt +++ b/redwood-tooling-schema/src/main/kotlin/app/cash/redwood/tooling/schema/schemaParserFir.kt @@ -369,8 +369,8 @@ private fun FirContext.parseWidget( annotation: WidgetAnnotation, ): ParsedProtocolWidget { val tag = annotation.tag - require(tag in 1 until maxMemberTag) { - "@Widget $memberType tag must be in range [1, $maxMemberTag): $tag" + require(tag in 1 until MAX_MEMBER_TAG) { + "@Widget $memberType tag must be in range [1, $MAX_MEMBER_TAG): $tag" } val traits = if (firClass.isData) { @@ -494,8 +494,8 @@ private fun FirContext.parseModifier( annotation: ModifierAnnotation, ): ParsedProtocolModifier { val tag = annotation.tag - require(tag in 1 until maxMemberTag) { - "@Modifier $memberType tag must be in range [1, $maxMemberTag): $tag" + require(tag in 1 until MAX_MEMBER_TAG) { + "@Modifier $memberType tag must be in range [1, $MAX_MEMBER_TAG): $tag" } require(annotation.scopes.isNotEmpty()) { "@Modifier $memberType must have at least one scope." @@ -515,7 +515,8 @@ private fun FirContext.parseModifier( name = name, documentation = documentation, type = parameterType, - isSerializable = false, // TODO Parse @Serializable on parameter type. + // TODO Parse @Serializable on parameter type. + isSerializable = false, defaultExpression = defaultAnnotation?.expression, deprecation = deprecation, ) diff --git a/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryAndroid.kt b/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryAndroid.kt index c2dcdf04ad..0d02c702d8 100644 --- a/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryAndroid.kt +++ b/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryAndroid.kt @@ -22,6 +22,7 @@ import okhttp3.OkHttpClient import okio.FileSystem import okio.Path +@Suppress("FunctionName") public fun TreehouseAppFactory( context: Context, httpClient: OkHttpClient, diff --git a/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/IosTreehouseDispatchers.kt b/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/IosTreehouseDispatchers.kt index d400971e29..0bd81c2701 100644 --- a/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/IosTreehouseDispatchers.kt +++ b/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/IosTreehouseDispatchers.kt @@ -29,22 +29,22 @@ import platform.Foundation.NSThread internal class IosTreehouseDispatchers : TreehouseDispatchers { override val ui: CoroutineDispatcher get() = Dispatchers.Main - private val zipline_ = SingleThreadCoroutineDispatcher().also { + private val _zipline = SingleThreadCoroutineDispatcher().also { it.thread.start() } - override val zipline: CoroutineDispatcher get() = zipline_ + override val zipline: CoroutineDispatcher get() = _zipline override fun checkUi() { check(NSThread.isMainThread) } override fun checkZipline() { - check(NSThread.currentThread == zipline_.thread) + check(NSThread.currentThread == _zipline.thread) } override fun close() { - zipline_.close() + _zipline.close() } } diff --git a/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryIos.kt b/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryIos.kt index 193576b0d6..62156b8169 100644 --- a/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryIos.kt +++ b/redwood-treehouse-host/src/iosMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryIos.kt @@ -20,6 +20,7 @@ import app.cash.zipline.loader.ZiplineHttpClient import okio.FileSystem import okio.Path +@Suppress("FunctionName") public fun TreehouseAppFactory( httpClient: ZiplineHttpClient, manifestVerifier: ManifestVerifier, diff --git a/redwood-yoga/src/commonMain/kotlin/app/cash/redwood/yoga/measure.kt b/redwood-yoga/src/commonMain/kotlin/app/cash/redwood/yoga/measure.kt index fda81c0b71..d8070e7048 100644 --- a/redwood-yoga/src/commonMain/kotlin/app/cash/redwood/yoga/measure.kt +++ b/redwood-yoga/src/commonMain/kotlin/app/cash/redwood/yoga/measure.kt @@ -34,7 +34,7 @@ public fun interface MeasureCallback { public val height: Float, ) { public companion object { - public const val Undefined: Float = Yoga.YGUndefined + public const val UNDEFINED: Float = Yoga.YGUndefined } } diff --git a/renovate.json5 b/renovate.json5 index d0048f5eea..62c67607de 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -15,13 +15,5 @@ "org.jetbrains.kotlin:kotlin", ], }, - { - // ktlint breaks their API constantly and regularly needs a Spotless update to work. - "groupName": "Spotless/ktlint", - "matchPackagePrefixes": [ - "com.diffplug.spotless", - "com.pinterest:ktlint", - ], - } ], } diff --git a/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/EmojiSearch.kt b/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/EmojiSearch.kt index 99407b94df..b7adbe073a 100644 --- a/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/EmojiSearch.kt +++ b/samples/emoji-search/presenter/src/commonMain/kotlin/com/example/redwood/emojisearch/presenter/EmojiSearch.kt @@ -65,7 +65,9 @@ interface Navigator { } enum class Variant { - LAZY_COLUMN, SCROLLABLE_FLEXBOX, BUGGY_COLUMNS + LAZY_COLUMN, + SCROLLABLE_FLEXBOX, + BUGGY_COLUMNS, } @Composable