diff --git a/core-common/src/main/kotlin/com/twitter/rules/core/util/Composables.kt b/core-common/src/main/kotlin/com/twitter/rules/core/util/Composables.kt index 0e1ffe0f..13bcfd66 100644 --- a/core-common/src/main/kotlin/com/twitter/rules/core/util/Composables.kt +++ b/core-common/src/main/kotlin/com/twitter/rules/core/util/Composables.kt @@ -64,7 +64,7 @@ private val KtCallExpression.containsComposablesWithModifiers: Boolean */ private val ComposableNonEmittersList = setOf( "AlertDialog", - "ModalBottomSheetLayout" + "ModalBottomSheetLayout", ) /** @@ -136,26 +136,26 @@ private val ComposableEmittersList by lazy { "TopAppBarSurface", "VerticalPager", "VerticalPagerIndicator", - "WebView" + "WebView", ) } val ComposableEmittersListRegex by lazy { Regex( listOf( - "Spacer\\d*" // Spacer() + SpacerNUM() + "Spacer\\d*", // Spacer() + SpacerNUM() ).joinToString( separator = "|", prefix = "(", - postfix = ")" - ) + postfix = ")", + ), ) } val ModifierNames by lazy(LazyThreadSafetyMode.NONE) { setOf( "Modifier", - "GlanceModifier" + "GlanceModifier", ) } @@ -176,13 +176,13 @@ val KtProperty.declaresCompositionLocal: Boolean hasInitializer() && initializer is KtCallExpression && CompositionLocalReferenceExpressions.contains( - (initializer as KtCallExpression).referenceExpression()?.text + (initializer as KtCallExpression).referenceExpression()?.text, ) private val CompositionLocalReferenceExpressions by lazy(LazyThreadSafetyMode.NONE) { setOf( "staticCompositionLocalOf", - "compositionLocalOf" + "compositionLocalOf", ) } @@ -194,6 +194,6 @@ private val RestartableEffects by lazy(LazyThreadSafetyMode.NONE) { setOf( "LaunchedEffect", "produceState", - "DisposableEffect" + "DisposableEffect", ) } diff --git a/core-common/src/main/kotlin/com/twitter/rules/core/util/KotlinUtils.kt b/core-common/src/main/kotlin/com/twitter/rules/core/util/KotlinUtils.kt index 267ff96b..93343ea5 100644 --- a/core-common/src/main/kotlin/com/twitter/rules/core/util/KotlinUtils.kt +++ b/core-common/src/main/kotlin/com/twitter/rules/core/util/KotlinUtils.kt @@ -19,7 +19,7 @@ fun String.toCamelCase() = split('_').joinToString( separator = "", transform = { original -> original.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } - } + }, ) fun String.toSnakeCase() = replace(humps, "_").lowercase(Locale.getDefault()) diff --git a/core-common/src/main/kotlin/com/twitter/rules/core/util/KtCallableDeclarations.kt b/core-common/src/main/kotlin/com/twitter/rules/core/util/KtCallableDeclarations.kt index f6e8e267..afbe6726 100644 --- a/core-common/src/main/kotlin/com/twitter/rules/core/util/KtCallableDeclarations.kt +++ b/core-common/src/main/kotlin/com/twitter/rules/core/util/KtCallableDeclarations.kt @@ -37,7 +37,7 @@ val KnownMutableCommonTypesRegex = sequenceOf( "ReplaySubject<.*>\\??", "PublishRelay<.*>\\??", "BehaviorRelay<.*>\\??", - "ReplayRelay<.*>\\??" + "ReplayRelay<.*>\\??", ).map { Regex(it) } val KtCallableDeclaration.isTypeUnstableCollection: Boolean @@ -46,5 +46,5 @@ val KtCallableDeclaration.isTypeUnstableCollection: Boolean val KnownUnstableCollectionTypesRegex = sequenceOf( "Set<.*>\\??", "List<.*>\\??", - "Map<.*>\\??" + "Map<.*>\\??", ).map { Regex(it) } diff --git a/core-detekt/src/main/kotlin/com/twitter/rules/core/detekt/DetektComposeKtConfig.kt b/core-detekt/src/main/kotlin/com/twitter/rules/core/detekt/DetektComposeKtConfig.kt index 6e3523d2..ef6813cb 100644 --- a/core-detekt/src/main/kotlin/com/twitter/rules/core/detekt/DetektComposeKtConfig.kt +++ b/core-detekt/src/main/kotlin/com/twitter/rules/core/detekt/DetektComposeKtConfig.kt @@ -11,7 +11,7 @@ import io.gitlab.arturbosch.detekt.api.internal.valueOrDefaultCommaSeparated * during the lifetime of a rule. */ internal class DetektComposeKtConfig( - private val config: Config + private val config: Config, ) : ComposeKtConfig { private val cache = mutableMapOf() diff --git a/core-detekt/src/main/kotlin/com/twitter/rules/core/detekt/TwitterDetektRule.kt b/core-detekt/src/main/kotlin/com/twitter/rules/core/detekt/TwitterDetektRule.kt index 1ffe8c38..a2156e08 100644 --- a/core-detekt/src/main/kotlin/com/twitter/rules/core/detekt/TwitterDetektRule.kt +++ b/core-detekt/src/main/kotlin/com/twitter/rules/core/detekt/TwitterDetektRule.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes import org.jetbrains.kotlin.utils.addToStdlib.cast abstract class TwitterDetektRule( - config: Config = Config.empty + config: Config = Config.empty, ) : Rule(config), ComposeKtVisitor { private val config: ComposeKtConfig by lazy { DetektComposeKtConfig(this) } @@ -38,13 +38,13 @@ abstract class TwitterDetektRule( issue = issue, entity = Entity.from(finalElement, Location.from(finalElement)), message = message, - autoCorrectEnabled = autoCorrect + autoCorrectEnabled = autoCorrect, ) else -> CodeSmell( issue = issue, entity = Entity.from(finalElement, Location.from(finalElement)), - message = message + message = message, ) } report(finding) diff --git a/core-ktlint/src/main/kotlin/com/twitter/rules/core/ktlint/KtlintComposeKtConfig.kt b/core-ktlint/src/main/kotlin/com/twitter/rules/core/ktlint/KtlintComposeKtConfig.kt index a4d07bbb..4465b70c 100644 --- a/core-ktlint/src/main/kotlin/com/twitter/rules/core/ktlint/KtlintComposeKtConfig.kt +++ b/core-ktlint/src/main/kotlin/com/twitter/rules/core/ktlint/KtlintComposeKtConfig.kt @@ -13,7 +13,7 @@ import com.twitter.rules.core.util.toSnakeCase * Results will be memoized as well, as config shouldn't be changing during the lifetime of a rule. */ internal class KtlintComposeKtConfig( - private val properties: EditorConfigProperties + private val properties: EditorConfigProperties, ) : ComposeKtConfig { private val cache = mutableMapOf() diff --git a/core-ktlint/src/main/kotlin/com/twitter/rules/core/ktlint/TwitterKtlintRule.kt b/core-ktlint/src/main/kotlin/com/twitter/rules/core/ktlint/TwitterKtlintRule.kt index d285e51f..48d0a855 100644 --- a/core-ktlint/src/main/kotlin/com/twitter/rules/core/ktlint/TwitterKtlintRule.kt +++ b/core-ktlint/src/main/kotlin/com/twitter/rules/core/ktlint/TwitterKtlintRule.kt @@ -27,10 +27,11 @@ abstract class TwitterKtlintRule(id: String) : Rule(id), ComposeKtVisitor { private val config: ComposeKtConfig by lazy { KtlintComposeKtConfig(properties) } + @Suppress("DEPRECATION") final override fun beforeVisitChildNodes( node: ASTNode, autoCorrect: Boolean, - emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit + emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit, ) { val psi = node.psi when (node.elementType) { diff --git a/core-ktlint/src/test/kotlin/com/twitter/rules/core/ktlint/KtlintComposeKtConfigTest.kt b/core-ktlint/src/test/kotlin/com/twitter/rules/core/ktlint/KtlintComposeKtConfigTest.kt index 5d834f95..e5ce43a7 100644 --- a/core-ktlint/src/test/kotlin/com/twitter/rules/core/ktlint/KtlintComposeKtConfigTest.kt +++ b/core-ktlint/src/test/kotlin/com/twitter/rules/core/ktlint/KtlintComposeKtConfigTest.kt @@ -94,7 +94,7 @@ class KtlintComposeKtConfigTest { when (this) { true -> PropertyType.PropertyValue.valid("true", true) false -> PropertyType.PropertyValue.valid("false", false) - } + }, ) .build() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4953c7b6..958f77a0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,8 @@ [versions] -kotlin = "1.7.21" -ktlint = "0.47.1" +kotlin = "1.8.0" +ktlint = "0.48.2" detekt = "1.22.0" -junit = "5.9.1" +junit = "5.9.2" [libraries] ktlint-core = { module = "com.pinterest.ktlint:ktlint-core", version.ref = "ktlint" } @@ -23,5 +23,5 @@ assertj = "org.assertj:assertj-core:3.23.1" reflections = "org.reflections:reflections:0.10.2" [plugins] -spotless = { id = "com.diffplug.spotless", version = "6.11.0" } +spotless = { id = "com.diffplug.spotless", version = "6.13.0" } shadowJar = { id = "com.github.johnrengelman.shadow", version = "7.1.2" } diff --git a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeModifierReused.kt b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeModifierReused.kt index 393348bf..35c5a20d 100644 --- a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeModifierReused.kt +++ b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeModifierReused.kt @@ -49,7 +49,7 @@ class ComposeModifierReused : ComposeKtVisitor { addAll( current.siblings() .filterIsInstance() - .filter { it.isUsingModifiers(modifierNames) } + .filter { it.isUsingModifiers(modifierNames) }, ) current = current.parent } diff --git a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeParameterOrder.kt b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeParameterOrder.kt index 60aefb2b..3a32aaf3 100644 --- a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeParameterOrder.kt +++ b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeParameterOrder.kt @@ -39,7 +39,7 @@ class ComposeParameterOrder : ComposeKtVisitor { // As ComposeModifierMissingCheck will catch modifiers without a Modifier default, we don't have to care // about that case. We will sort the params with defaults so that the modifier(s) go first. val sortedWithDefaults = withDefaults.sortedWith( - compareByDescending { it.isModifier }.thenByDescending { it.name == "modifier" } + compareByDescending { it.isModifier }.thenByDescending { it.name == "modifier" }, ) // We create our ideal ordering of params for the ideal composable. diff --git a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeRememberMissing.kt b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeRememberMissing.kt index df45c4dd..b3ce2657 100644 --- a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeRememberMissing.kt +++ b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeRememberMissing.kt @@ -41,7 +41,7 @@ class ComposeRememberMissing : ComposeKtVisitor { companion object { private val MethodsThatNeedRemembering = setOf( "derivedStateOf", - "mutableStateOf" + "mutableStateOf", ) val DerivedStateOfNotRemembered = errorMessage("derivedStateOf") val MutableStateOfNotRemembered = errorMessage("mutableStateOf") diff --git a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeUnstableCollections.kt b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeUnstableCollections.kt index 1a7ac402..9914643b 100644 --- a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeUnstableCollections.kt +++ b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeUnstableCollections.kt @@ -18,7 +18,7 @@ class ComposeUnstableCollections : ComposeKtVisitor { val message = createErrorMessage( type = type, rawType = type.replace(DiamondRegex, ""), - variable = variableName + variable = variableName, ) emitter.report(param.typeReference ?: param, message) } diff --git a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeViewModelInjection.kt b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeViewModelInjection.kt index 3c12330a..79877d7d 100644 --- a/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeViewModelInjection.kt +++ b/rules/common/src/main/kotlin/com/twitter/compose/rules/ComposeViewModelInjection.kt @@ -109,7 +109,7 @@ class ComposeViewModelInjection : ComposeKtVisitor { "weaverViewModel", // Weaver "hiltViewModel", // Hilt "injectedViewModel", // Whetstone - "mavericksViewModel" // Mavericks + "mavericksViewModel", // Mavericks ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalAllowlistCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalAllowlistCheck.kt index ed797d86..074db9ef 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalAllowlistCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalAllowlistCheck.kt @@ -18,6 +18,6 @@ class ComposeCompositionLocalAllowlistCheck(config: Config) : id = "CompositionLocalAllowlist", severity = Severity.CodeSmell, description = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist, - debt = Debt.FIVE_MINS + debt = Debt.FIVE_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalNamingCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalNamingCheck.kt index ffdaea9b..5fd86412 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalNamingCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalNamingCheck.kt @@ -18,6 +18,6 @@ class ComposeCompositionLocalNamingCheck(config: Config) : id = "CompositionLocalNaming", severity = Severity.CodeSmell, description = ComposeCompositionLocalNaming.CompositionLocalNeedsLocalPrefix, - debt = Debt.FIVE_MINS + debt = Debt.FIVE_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeContentEmitterReturningValuesCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeContentEmitterReturningValuesCheck.kt index 3a11f1ee..5f619fac 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeContentEmitterReturningValuesCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeContentEmitterReturningValuesCheck.kt @@ -18,6 +18,6 @@ class ComposeContentEmitterReturningValuesCheck(config: Config) : id = "ContentEmitterReturningValues", severity = Severity.Defect, description = ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo, - debt = Debt.TWENTY_MINS + debt = Debt.TWENTY_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierComposableCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierComposableCheck.kt index 827eab11..e5581019 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierComposableCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierComposableCheck.kt @@ -17,6 +17,6 @@ class ComposeModifierComposableCheck(config: Config) : id = "ModifierComposable", severity = Severity.Performance, description = ComposeModifierComposable.ComposableModifier, - debt = Debt.TEN_MINS + debt = Debt.TEN_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierMissingCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierMissingCheck.kt index 36f66fb3..6dff15f2 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierMissingCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierMissingCheck.kt @@ -17,6 +17,6 @@ class ComposeModifierMissingCheck(config: Config) : id = "ModifierMissing", severity = Severity.Defect, description = ComposeModifierMissing.MissingModifierContentComposable, - debt = Debt.TEN_MINS + debt = Debt.TEN_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierReusedCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierReusedCheck.kt index df11e13e..de67a3f2 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierReusedCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierReusedCheck.kt @@ -17,6 +17,6 @@ class ComposeModifierReusedCheck(config: Config) : id = "ModifierReused", severity = Severity.Defect, description = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, - debt = Debt.TWENTY_MINS + debt = Debt.TWENTY_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierWithoutDefaultCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierWithoutDefaultCheck.kt index 6d02e8ed..284b997b 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierWithoutDefaultCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeModifierWithoutDefaultCheck.kt @@ -18,6 +18,6 @@ class ComposeModifierWithoutDefaultCheck(config: Config) : id = "ModifierWithoutDefault", severity = Severity.CodeSmell, description = ComposeModifierWithoutDefault.MissingModifierDefaultParam, - debt = Debt.FIVE_MINS + debt = Debt.FIVE_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeMultipleContentEmittersCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeMultipleContentEmittersCheck.kt index 1c46f8d0..39fff647 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeMultipleContentEmittersCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeMultipleContentEmittersCheck.kt @@ -18,6 +18,6 @@ class ComposeMultipleContentEmittersCheck(config: Config) : id = "MultipleEmitters", severity = Severity.Defect, description = ComposeMultipleContentEmitters.MultipleContentEmittersDetected, - debt = Debt.TWENTY_MINS + debt = Debt.TWENTY_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeMutableParametersCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeMutableParametersCheck.kt index 9872df78..4c1f1039 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeMutableParametersCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeMutableParametersCheck.kt @@ -17,6 +17,6 @@ class ComposeMutableParametersCheck(config: Config) : id = "MutableParams", severity = Severity.Defect, description = ComposeMutableParameters.MutableParameterInCompose, - debt = Debt.TWENTY_MINS + debt = Debt.TWENTY_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeNamingCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeNamingCheck.kt index 616fb1a9..765d2c36 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeNamingCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeNamingCheck.kt @@ -21,6 +21,6 @@ class ComposeNamingCheck(config: Config) : However, Composable functions that return a value should start with a lowercase letter instead. They should follow the standard Kotlin Coding Conventions for the naming of functions for any function annotated @Composable that returns a value other than Unit """.trimIndent(), - debt = Debt.TEN_MINS + debt = Debt.TEN_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeParameterOrderCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeParameterOrderCheck.kt index 14b6c158..448dc8c1 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeParameterOrderCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeParameterOrderCheck.kt @@ -19,6 +19,6 @@ class ComposeParameterOrderCheck(config: Config) : description = "Parameters in a composable function should be ordered following this pattern: " + "params without defaults, modifiers, params with defaults and optionally, " + "a trailing function that might not have a default param.", - debt = Debt.TEN_MINS + debt = Debt.TEN_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposePreviewNamingCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposePreviewNamingCheck.kt index d40a4186..19ccb716 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposePreviewNamingCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposePreviewNamingCheck.kt @@ -18,6 +18,6 @@ class ComposePreviewNamingCheck(config: Config) : id = "PreviewNaming", severity = Severity.CodeSmell, description = "Multipreview annotations should end with the `Previews` suffix", - debt = Debt.FIVE_MINS + debt = Debt.FIVE_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposePreviewPublicCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposePreviewPublicCheck.kt index bb35c958..aa91460d 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposePreviewPublicCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposePreviewPublicCheck.kt @@ -18,6 +18,6 @@ class ComposePreviewPublicCheck(config: Config) : id = "PreviewPublic", severity = Severity.CodeSmell, description = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic, - debt = Debt.FIVE_MINS + debt = Debt.FIVE_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeRememberMissingCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeRememberMissingCheck.kt index 1d895dd6..23c25ae0 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeRememberMissingCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeRememberMissingCheck.kt @@ -21,6 +21,6 @@ class ComposeRememberMissingCheck(config: Config) : Using mutableStateOf/derivedStateOf in a @Composable function without it being inside of a remember function. If you don't remember the state instance, a new state instance will be created when the function is recomposed. """.trimIndent(), - debt = Debt.FIVE_MINS + debt = Debt.FIVE_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeUnstableCollectionsCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeUnstableCollectionsCheck.kt index 77aed9a0..2038b274 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeUnstableCollectionsCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeUnstableCollectionsCheck.kt @@ -22,6 +22,6 @@ class ComposeUnstableCollectionsCheck(config: Config) : See https://twitter.github.io/compose-rules/rules/#avoid-using-unstable-collections for more information. """.trimIndent(), - debt = Debt.TWENTY_MINS + debt = Debt.TWENTY_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelForwardingCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelForwardingCheck.kt index 669b6dfb..0f41d447 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelForwardingCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelForwardingCheck.kt @@ -17,6 +17,6 @@ class ComposeViewModelForwardingCheck(config: Config) : id = "ViewModelForwarding", severity = Severity.CodeSmell, description = ComposeViewModelForwarding.AvoidViewModelForwarding, - debt = Debt.TWENTY_MINS + debt = Debt.TWENTY_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelInjectionCheck.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelInjectionCheck.kt index d322b045..c174a72f 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelInjectionCheck.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelInjectionCheck.kt @@ -22,6 +22,6 @@ class ComposeViewModelInjectionCheck(config: Config) : Acquiring a ViewModel should be done in composable default parameters, so that it is more testable and flexible. """.trimIndent(), - debt = Debt.TEN_MINS + debt = Debt.TEN_MINS, ) } diff --git a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/TwitterComposeRuleSetProvider.kt b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/TwitterComposeRuleSetProvider.kt index bd3f796d..62315a34 100644 --- a/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/TwitterComposeRuleSetProvider.kt +++ b/rules/detekt/src/main/kotlin/com/twitter/compose/rules/detekt/TwitterComposeRuleSetProvider.kt @@ -28,8 +28,8 @@ class TwitterComposeRuleSetProvider : RuleSetProvider { ComposeRememberMissingCheck(config), ComposeUnstableCollectionsCheck(config), ComposeViewModelForwardingCheck(config), - ComposeViewModelInjectionCheck(config) - ) + ComposeViewModelInjectionCheck(config), + ), ) private companion object { diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalAllowlistCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalAllowlistCheckTest.kt index 2434ff7b..a5380ce7 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalAllowlistCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalAllowlistCheckTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test class ComposeCompositionLocalAllowlistCheckTest { private val testConfig = TestConfig( - "allowedCompositionLocals" to listOf("LocalBanana", "LocalPotato") + "allowedCompositionLocals" to listOf("LocalBanana", "LocalPotato"), ) private val rule = ComposeCompositionLocalAllowlistCheck(testConfig) @@ -33,7 +33,7 @@ class ComposeCompositionLocalAllowlistCheckTest { SourceLocation(1, 13), SourceLocation(2, 14), SourceLocation(3, 5), - SourceLocation(4, 13) + SourceLocation(4, 13), ) for (error in errors) { assertThat(error).hasMessage(ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalNamingCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalNamingCheckTest.kt index fd4fe0b7..426ce815 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalNamingCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeCompositionLocalNamingCheckTest.kt @@ -26,7 +26,7 @@ class ComposeCompositionLocalNamingCheckTest { assertThat(errors) .hasStartSourceLocations( SourceLocation(1, 5), - SourceLocation(2, 5) + SourceLocation(2, 5), ) for (error in errors) { assertThat(error).hasMessage(ComposeCompositionLocalNaming.CompositionLocalNeedsLocalPrefix) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeContentEmitterReturningValuesCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeContentEmitterReturningValuesCheckTest.kt index f1698c7e..cf690325 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeContentEmitterReturningValuesCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeContentEmitterReturningValuesCheckTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test class ComposeContentEmitterReturningValuesCheckTest { private val testConfig = TestConfig( - "contentEmitters" to listOf("Potato", "Banana") + "contentEmitters" to listOf("Potato", "Banana"), ) private val rule = ComposeContentEmitterReturningValuesCheck(testConfig) @@ -46,7 +46,7 @@ class ComposeContentEmitterReturningValuesCheckTest { .hasStartSourceLocations( SourceLocation(2, 5), SourceLocation(7, 5), - SourceLocation(16, 5) + SourceLocation(16, 5), ) for (error in errors) { assertThat(error).hasMessage(ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeModifierReusedCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeModifierReusedCheckTest.kt index 30be49ae..e9634eaf 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeModifierReusedCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeModifierReusedCheckTest.kt @@ -75,7 +75,7 @@ class ComposeModifierReusedCheckTest { SourceLocation(25, 9), SourceLocation(26, 9), SourceLocation(31, 5), - SourceLocation(37, 9) + SourceLocation(37, 9), ) for (error in errors) { assertThat(error).hasMessage(ComposeModifierReused.ModifierShouldBeUsedOnceOnly) @@ -116,7 +116,7 @@ class ComposeModifierReusedCheckTest { SourceLocation(9, 5), SourceLocation(11, 9), SourceLocation(17, 5), - SourceLocation(18, 9) + SourceLocation(18, 9), ) for (error in errors) { assertThat(error).hasMessage(ComposeModifierReused.ModifierShouldBeUsedOnceOnly) @@ -161,7 +161,7 @@ class ComposeModifierReusedCheckTest { SourceLocation(12, 5), SourceLocation(16, 5), SourceLocation(20, 9), - SourceLocation(21, 9) + SourceLocation(21, 9), ) for (error in errors) { assertThat(error).hasMessage(ComposeModifierReused.ModifierShouldBeUsedOnceOnly) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeModifierWithoutDefaultCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeModifierWithoutDefaultCheckTest.kt index cd27532b..515a07fa 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeModifierWithoutDefaultCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeModifierWithoutDefaultCheckTest.kt @@ -27,7 +27,7 @@ class ComposeModifierWithoutDefaultCheckTest { val errors = rule.lint(composableCode) assertThat(errors).hasStartSourceLocations( SourceLocation(2, 15), - SourceLocation(4, 46) + SourceLocation(4, 46), ) assertThat(errors[0]).hasMessage(ComposeModifierWithoutDefault.MissingModifierDefaultParam) assertThat(errors[1]).hasMessage(ComposeModifierWithoutDefault.MissingModifierDefaultParam) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeMultipleContentEmittersCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeMultipleContentEmittersCheckTest.kt index 043291df..cb512a43 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeMultipleContentEmittersCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeMultipleContentEmittersCheckTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test class ComposeMultipleContentEmittersCheckTest { private val testConfig = TestConfig( - "contentEmitters" to listOf("Potato", "Banana") + "contentEmitters" to listOf("Potato", "Banana"), ) private val rule = ComposeMultipleContentEmittersCheck(testConfig) @@ -77,7 +77,7 @@ class ComposeMultipleContentEmittersCheckTest { assertThat(errors).hasSize(2) .hasStartSourceLocations( SourceLocation(2, 5), - SourceLocation(7, 5) + SourceLocation(7, 5), ) for (error in errors) { assertThat(error).hasMessage(ComposeMultipleContentEmitters.MultipleContentEmittersDetected) @@ -116,7 +116,7 @@ class ComposeMultipleContentEmittersCheckTest { assertThat(errors).hasSize(2) .hasStartSourceLocations( SourceLocation(6, 5), - SourceLocation(19, 5) + SourceLocation(19, 5), ) for (error in errors) { assertThat(error).hasMessage(ComposeMultipleContentEmitters.MultipleContentEmittersDetected) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeMutableParametersCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeMutableParametersCheckTest.kt index ca95229c..42f277dc 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeMutableParametersCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeMutableParametersCheckTest.kt @@ -34,7 +34,7 @@ class ComposeMutableParametersCheckTest { SourceLocation(2, 15), SourceLocation(4, 15), SourceLocation(6, 15), - SourceLocation(8, 15) + SourceLocation(8, 15), ) for (error in errors) { assertThat(error).hasMessage(ComposeMutableParameters.MutableParameterInCompose) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeNamingCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeNamingCheckTest.kt index 3e7ab136..4416c27e 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeNamingCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeNamingCheckTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test class ComposeNamingCheckTest { private val testConfig = TestConfig( - "allowedComposableFunctionNames" to listOf(".*Presenter") + "allowedComposableFunctionNames" to listOf(".*Presenter"), ) private val rule = ComposeNamingCheck(testConfig) @@ -82,7 +82,7 @@ class ComposeNamingCheckTest { val errors = rule.lint(code) assertThat(errors).hasSize(1) .hasStartSourceLocations( - SourceLocation(2, 5) + SourceLocation(2, 5), ) assertThat(errors.first()).hasMessage(ComposeNaming.ComposablesThatReturnResultsShouldBeLowercase) } @@ -103,7 +103,7 @@ class ComposeNamingCheckTest { assertThat(errors).hasSize(2) .hasStartSourceLocations( SourceLocation(2, 5), - SourceLocation(5, 5) + SourceLocation(5, 5), ) for (error in errors) { assertThat(error).hasMessage(ComposeNaming.ComposablesThatDoNotReturnResultsShouldBeCapitalized) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeParameterOrderCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeParameterOrderCheckTest.kt index a415426e..9ec08a27 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeParameterOrderCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeParameterOrderCheckTest.kt @@ -58,7 +58,7 @@ class ComposeParameterOrderCheckTest { SourceLocation(5, 5), SourceLocation(8, 5), SourceLocation(11, 5), - SourceLocation(14, 5) + SourceLocation(14, 5), ) } } diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposePreviewNamingCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposePreviewNamingCheckTest.kt index 9fe10244..bd32a2bf 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposePreviewNamingCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposePreviewNamingCheckTest.kt @@ -64,7 +64,7 @@ class ComposePreviewNamingCheckTest { assertThat(errors).hasStartSourceLocations( SourceLocation(2, 18), SourceLocation(4, 18), - SourceLocation(6, 18) + SourceLocation(6, 18), ) for (error in errors) { assertThat(error).hasMessage(ComposePreviewNaming.createMessage(1, "Preview")) @@ -86,7 +86,7 @@ class ComposePreviewNamingCheckTest { val errors = rule.lint(code) assertThat(errors).hasStartSourceLocations( SourceLocation(3, 18), - SourceLocation(6, 18) + SourceLocation(6, 18), ) for (error in errors) { assertThat(error).hasMessage(ComposePreviewNaming.createMessage(2, "Previews")) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposePreviewPublicCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposePreviewPublicCheckTest.kt index 0ea304e2..3fcba071 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposePreviewPublicCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposePreviewPublicCheckTest.kt @@ -61,7 +61,7 @@ class ComposePreviewPublicCheckTest { val errors = ruleWithParams.lint(code) assertThat(errors).hasStartSourceLocations( SourceLocation(3, 5), - SourceLocation(6, 5) + SourceLocation(6, 5), ) for (error in errors) { assertThat(error).hasMessage(ComposePreviewPublic.ComposablesPreviewShouldNotBePublic) @@ -85,7 +85,7 @@ class ComposePreviewPublicCheckTest { val errors = rule.lint(code) assertThat(errors).hasStartSourceLocations( SourceLocation(3, 5), - SourceLocation(7, 5) + SourceLocation(7, 5), ) for (error in errors) { assertThat(error).hasMessage(ComposePreviewPublic.ComposablesPreviewShouldNotBePublic) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeRememberMissingCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeRememberMissingCheckTest.kt index c491d19e..d7ad2abd 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeRememberMissingCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeRememberMissingCheckTest.kt @@ -42,7 +42,7 @@ class ComposeRememberMissingCheckTest { assertThat(errors).hasSize(2) .hasStartSourceLocations( SourceLocation(3, 21), - SourceLocation(6, 45) + SourceLocation(6, 45), ) for (error in errors) { assertThat(error).hasMessage(ComposeRememberMissing.MutableStateOfNotRemembered) @@ -111,7 +111,7 @@ class ComposeRememberMissingCheckTest { assertThat(errors).hasSize(2) .hasStartSourceLocations( SourceLocation(3, 21), - SourceLocation(6, 45) + SourceLocation(6, 45), ) for (error in errors) { assertThat(error).hasMessage(ComposeRememberMissing.DerivedStateOfNotRemembered) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeUnstableCollectionsCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeUnstableCollectionsCheckTest.kt index 726bb9a5..1666642e 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeUnstableCollectionsCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeUnstableCollectionsCheckTest.kt @@ -31,7 +31,7 @@ class ComposeUnstableCollectionsCheckTest { .hasStartSourceLocations( SourceLocation(2, 18), SourceLocation(4, 18), - SourceLocation(6, 18) + SourceLocation(6, 18), ) assertThat(errors[0]).hasMessage(createErrorMessage("List", "List", "a")) assertThat(errors[1]).hasMessage(createErrorMessage("Set", "Set", "a")) diff --git a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelInjectionCheckTest.kt b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelInjectionCheckTest.kt index b29b981a..f278e080 100644 --- a/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelInjectionCheckTest.kt +++ b/rules/detekt/src/test/kotlin/com/twitter/compose/rules/detekt/ComposeViewModelInjectionCheckTest.kt @@ -71,7 +71,7 @@ class ComposeViewModelInjectionCheckTest { .hasStartSourceLocations( SourceLocation(3, 9), SourceLocation(7, 9), - SourceLocation(11, 9) + SourceLocation(11, 9), ) for (error in errors) { assertThat(error).hasMessage(ComposeViewModelInjection.errorMessage(viewModel)) @@ -97,7 +97,7 @@ class ComposeViewModelInjectionCheckTest { assertThat(errors).hasSize(2) .hasStartSourceLocations( SourceLocation(4, 13), - SourceLocation(6, 13) + SourceLocation(6, 13), ) for (error in errors) { assertThat(error).hasMessage(ComposeViewModelInjection.errorMessage(viewModel)) diff --git a/rules/ktlint/src/main/kotlin/com/twitter/compose/rules/ktlint/EditorConfigProperties.kt b/rules/ktlint/src/main/kotlin/com/twitter/compose/rules/ktlint/EditorConfigProperties.kt index f66a911b..10380f4a 100644 --- a/rules/ktlint/src/main/kotlin/com/twitter/compose/rules/ktlint/EditorConfigProperties.kt +++ b/rules/ktlint/src/main/kotlin/com/twitter/compose/rules/ktlint/EditorConfigProperties.kt @@ -1,18 +1,18 @@ // Copyright 2022 Twitter, Inc. // SPDX-License-Identifier: Apache-2.0 -package com.twitter.rules.core.ktlint +package com.twitter.compose.rules.ktlint -import com.pinterest.ktlint.core.api.UsesEditorConfigProperties +import com.pinterest.ktlint.core.api.editorconfig.EditorConfigProperty import org.ec4j.core.model.PropertyType import org.ec4j.core.model.PropertyType.PropertyValueParser -val contentEmittersProperty: UsesEditorConfigProperties.EditorConfigProperty = - UsesEditorConfigProperties.EditorConfigProperty( +val contentEmittersProperty: EditorConfigProperty = + EditorConfigProperty( type = PropertyType.LowerCasingPropertyType( "twitter_compose_content_emitters", "A comma separated list of composable functions that emit content (e.g. UI)", PropertyType.PropertyValueParser.IDENTITY_VALUE_PARSER, - emptySet() + emptySet(), ), defaultValue = "", propertyMapper = { property, _ -> @@ -21,16 +21,16 @@ val contentEmittersProperty: UsesEditorConfigProperties.EditorConfigProperty() != null -> property.getValueAs() else -> property?.getValueAs() } - } + }, ) -val compositionLocalAllowlistProperty: UsesEditorConfigProperties.EditorConfigProperty = - UsesEditorConfigProperties.EditorConfigProperty( +val compositionLocalAllowlistProperty: EditorConfigProperty = + EditorConfigProperty( type = PropertyType.LowerCasingPropertyType( "twitter_compose_allowed_composition_locals", "A comma separated list of allowed CompositionLocals", PropertyType.PropertyValueParser.IDENTITY_VALUE_PARSER, - emptySet() + emptySet(), ), defaultValue = "", propertyMapper = { property, _ -> @@ -39,29 +39,29 @@ val compositionLocalAllowlistProperty: UsesEditorConfigProperties.EditorConfigPr property?.getValueAs() != null -> property.getValueAs() else -> property?.getValueAs() } - } + }, ) -val previewPublicOnlyIfParams: UsesEditorConfigProperties.EditorConfigProperty = - UsesEditorConfigProperties.EditorConfigProperty( +val previewPublicOnlyIfParams: EditorConfigProperty = + EditorConfigProperty( type = PropertyType.LowerCasingPropertyType( "twitter_compose_preview_public_only_if_params", "If set to true, it means ", // PropertyValueParser.BOOLEAN_VALUE_PARSER, "true", - "false" + "false", ), - defaultValue = true + defaultValue = true, ) -val allowedComposeNamingNames: UsesEditorConfigProperties.EditorConfigProperty = - UsesEditorConfigProperties.EditorConfigProperty( +val allowedComposeNamingNames: EditorConfigProperty = + EditorConfigProperty( type = PropertyType.LowerCasingPropertyType( "twitter_compose_allowed_composable_function_names", "A comma separated list of regexes of allowed composable function names", PropertyType.PropertyValueParser.IDENTITY_VALUE_PARSER, - emptySet() + emptySet(), ), defaultValue = "", propertyMapper = { property, _ -> @@ -70,5 +70,5 @@ val allowedComposeNamingNames: UsesEditorConfigProperties.EditorConfigProperty() != null -> property.getValueAs() else -> property?.getValueAs() } - } + }, ) diff --git a/rules/ktlint/src/main/kotlin/com/twitter/compose/rules/ktlint/TwitterComposeRuleSetProvider.kt b/rules/ktlint/src/main/kotlin/com/twitter/compose/rules/ktlint/TwitterComposeRuleSetProvider.kt index f0ff2909..779689a3 100644 --- a/rules/ktlint/src/main/kotlin/com/twitter/compose/rules/ktlint/TwitterComposeRuleSetProvider.kt +++ b/rules/ktlint/src/main/kotlin/com/twitter/compose/rules/ktlint/TwitterComposeRuleSetProvider.kt @@ -5,41 +5,13 @@ package com.twitter.compose.rules.ktlint import com.pinterest.ktlint.core.RuleProvider -import com.pinterest.ktlint.core.RuleSet -import com.pinterest.ktlint.core.RuleSetProvider import com.pinterest.ktlint.core.RuleSetProviderV2 -class TwitterComposeRuleSetProvider : - RuleSetProviderV2( - CustomRuleSetId, - RuleSetAbout - ), - RuleSetProvider { +class TwitterComposeRuleSetProvider : RuleSetProviderV2( + CustomRuleSetId, + RuleSetAbout, +) { - // Pre-0.47.0 ruleset (will go away in 0.48.0) - @Suppress("OVERRIDE_DEPRECATION") - override fun get(): RuleSet = RuleSet( - CustomRuleSetId, - ComposeCompositionLocalAllowlistCheck(), - ComposeCompositionLocalNamingCheck(), - ComposeContentEmitterReturningValuesCheck(), - ComposeModifierComposableCheck(), - ComposeModifierMissingCheck(), - ComposeModifierReusedCheck(), - ComposeModifierWithoutDefaultCheck(), - ComposeMultipleContentEmittersCheck(), - ComposeMutableParametersCheck(), - ComposeNamingCheck(), - ComposeParameterOrderCheck(), - ComposePreviewNamingCheck(), - ComposePreviewPublicCheck(), - ComposeRememberMissingCheck(), - ComposeUnstableCollectionsCheck(), - ComposeViewModelForwardingCheck(), - ComposeViewModelInjectionCheck() - ) - - // 0.47.0+ ruleset override fun getRuleProviders(): Set = setOf( RuleProvider { ComposeCompositionLocalAllowlistCheck() }, RuleProvider { ComposeCompositionLocalNamingCheck() }, @@ -57,7 +29,7 @@ class TwitterComposeRuleSetProvider : RuleProvider { ComposeRememberMissingCheck() }, RuleProvider { ComposeUnstableCollectionsCheck() }, RuleProvider { ComposeViewModelForwardingCheck() }, - RuleProvider { ComposeViewModelInjectionCheck() } + RuleProvider { ComposeViewModelInjectionCheck() }, ) private companion object { @@ -66,7 +38,7 @@ class TwitterComposeRuleSetProvider : description = "Static checks to aid with a healthy adoption of Jetpack Compose", license = "Apache License, Version 2.0", repositoryUrl = "https://github.com/twitter/compose-rules/", - issueTrackerUrl = "https://github.com/twitter/compose-rules/issues" + issueTrackerUrl = "https://github.com/twitter/compose-rules/issues", ) const val CustomRuleSetId = "twitter-compose" } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeCompositionLocalAllowlistCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeCompositionLocalAllowlistCheckTest.kt index c2180e39..7ca7fa0d 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeCompositionLocalAllowlistCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeCompositionLocalAllowlistCheckTest.kt @@ -5,7 +5,6 @@ package com.twitter.compose.rules.ktlint import com.pinterest.ktlint.test.KtLintAssertThat.Companion.assertThatRule import com.pinterest.ktlint.test.LintViolation import com.twitter.compose.rules.ComposeCompositionLocalAllowlist -import com.twitter.rules.core.ktlint.compositionLocalAllowlistProperty import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Test @@ -28,23 +27,23 @@ class ComposeCompositionLocalAllowlistCheckTest { LintViolation( line = 1, col = 13, - detail = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist + detail = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist, ), LintViolation( line = 2, col = 14, - detail = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist + detail = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist, ), LintViolation( line = 3, col = 5, - detail = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist + detail = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist, ), LintViolation( line = 4, col = 13, - detail = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist - ) + detail = ComposeCompositionLocalAllowlist.CompositionLocalNotInAllowlist, + ), ) } @@ -58,7 +57,7 @@ class ComposeCompositionLocalAllowlistCheckTest { """.trimIndent() allowlistRuleAssertThat(code) .withEditorConfigOverride( - compositionLocalAllowlistProperty to "LocalPotato,LocalBanana" + compositionLocalAllowlistProperty to "LocalPotato,LocalBanana", ) .hasNoLintViolations() } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeCompositionLocalNamingCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeCompositionLocalNamingCheckTest.kt index 5e70c158..da2d2c17 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeCompositionLocalNamingCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeCompositionLocalNamingCheckTest.kt @@ -25,13 +25,13 @@ class ComposeCompositionLocalNamingCheckTest { LintViolation( line = 1, col = 5, - detail = ComposeCompositionLocalNaming.CompositionLocalNeedsLocalPrefix + detail = ComposeCompositionLocalNaming.CompositionLocalNeedsLocalPrefix, ), LintViolation( line = 2, col = 5, - detail = ComposeCompositionLocalNaming.CompositionLocalNeedsLocalPrefix - ) + detail = ComposeCompositionLocalNaming.CompositionLocalNeedsLocalPrefix, + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeContentEmitterReturningValuesCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeContentEmitterReturningValuesCheckTest.kt index bea7f560..5f3dc47d 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeContentEmitterReturningValuesCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeContentEmitterReturningValuesCheckTest.kt @@ -5,7 +5,6 @@ package com.twitter.compose.rules.ktlint import com.pinterest.ktlint.test.KtLintAssertThat.Companion.assertThatRule import com.pinterest.ktlint.test.LintViolation import com.twitter.compose.rules.ComposeContentEmitterReturningValues -import com.twitter.rules.core.ktlint.contentEmittersProperty import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Test @@ -39,24 +38,24 @@ class ComposeContentEmitterReturningValuesCheckTest { """.trimIndent() emittersRuleAssertThat(code) .withEditorConfigOverride( - contentEmittersProperty to "Potato,Banana" + contentEmittersProperty to "Potato,Banana", ) .hasLintViolationsWithoutAutoCorrect( LintViolation( line = 2, col = 5, - detail = ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo + detail = ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo, ), LintViolation( line = 7, col = 5, - detail = ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo + detail = ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo, ), LintViolation( line = 16, col = 5, - detail = ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo - ) + detail = ComposeContentEmitterReturningValues.ContentEmitterReturningValuesToo, + ), ) } } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierComposableCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierComposableCheckTest.kt index 044bde7e..ed08df69 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierComposableCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierComposableCheckTest.kt @@ -27,13 +27,13 @@ class ComposeModifierComposableCheckTest { LintViolation( line = 2, col = 14, - detail = ComposeModifierComposable.ComposableModifier + detail = ComposeModifierComposable.ComposableModifier, ), LintViolation( line = 4, col = 14, - detail = ComposeModifierComposable.ComposableModifier - ) + detail = ComposeModifierComposable.ComposableModifier, + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierMissingCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierMissingCheckTest.kt index 65c38dfb..67042e98 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierMissingCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierMissingCheckTest.kt @@ -46,18 +46,18 @@ class ComposeModifierMissingCheckTest { LintViolation( line = 2, col = 5, - detail = ComposeModifierMissing.MissingModifierContentComposable + detail = ComposeModifierMissing.MissingModifierContentComposable, ), LintViolation( line = 7, col = 5, - detail = ComposeModifierMissing.MissingModifierContentComposable + detail = ComposeModifierMissing.MissingModifierContentComposable, ), LintViolation( line = 12, col = 5, - detail = ComposeModifierMissing.MissingModifierContentComposable - ) + detail = ComposeModifierMissing.MissingModifierContentComposable, + ), ) } @@ -84,13 +84,13 @@ class ComposeModifierMissingCheckTest { LintViolation( line = 2, col = 5, - detail = ComposeModifierMissing.MissingModifierContentComposable + detail = ComposeModifierMissing.MissingModifierContentComposable, ), LintViolation( line = 7, col = 5, - detail = ComposeModifierMissing.MissingModifierContentComposable - ) + detail = ComposeModifierMissing.MissingModifierContentComposable, + ), ) } @@ -254,8 +254,8 @@ class ComposeModifierMissingCheckTest { LintViolation( line = 2, col = 5, - detail = ComposeModifierMissing.MissingModifierContentComposable - ) + detail = ComposeModifierMissing.MissingModifierContentComposable, + ), ) } } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierReusedCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierReusedCheckTest.kt index cbb96b9f..83bd53bc 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierReusedCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierReusedCheckTest.kt @@ -64,58 +64,58 @@ class ComposeModifierReusedCheckTest { LintViolation( line = 3, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 4, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 9, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 11, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 16, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 19, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 20, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 25, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 26, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 31, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 37, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly - ) + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, + ), ) } @@ -149,33 +149,33 @@ class ComposeModifierReusedCheckTest { LintViolation( line = 3, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 4, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 9, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 11, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 17, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 18, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly - ) + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, + ), ) } @@ -212,38 +212,38 @@ class ComposeModifierReusedCheckTest { LintViolation( line = 6, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 8, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 9, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 12, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 16, col = 5, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 20, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, ), LintViolation( line = 21, col = 9, - detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly - ) + detail = ComposeModifierReused.ModifierShouldBeUsedOnceOnly, + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierWithoutDefaultCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierWithoutDefaultCheckTest.kt index ba93bf04..7a320600 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierWithoutDefaultCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeModifierWithoutDefaultCheckTest.kt @@ -27,13 +27,13 @@ class ComposeModifierWithoutDefaultCheckTest { LintViolation( line = 2, col = 15, - detail = ComposeModifierWithoutDefault.MissingModifierDefaultParam + detail = ComposeModifierWithoutDefault.MissingModifierDefaultParam, ), LintViolation( line = 4, col = 46, - detail = ComposeModifierWithoutDefault.MissingModifierDefaultParam - ) + detail = ComposeModifierWithoutDefault.MissingModifierDefaultParam, + ), ) .isFormattedAs( """ @@ -41,7 +41,7 @@ class ComposeModifierWithoutDefaultCheckTest { fun Something(modifier: Modifier = Modifier) { } @Composable fun Something(modifier: Modifier = Modifier, modifier2: Modifier = Modifier) { } - """.trimIndent() + """.trimIndent(), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeMultipleContentEmittersCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeMultipleContentEmittersCheckTest.kt index 5aa94848..ee6cfe02 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeMultipleContentEmittersCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeMultipleContentEmittersCheckTest.kt @@ -5,7 +5,6 @@ package com.twitter.compose.rules.ktlint import com.pinterest.ktlint.test.KtLintAssertThat.Companion.assertThatRule import com.pinterest.ktlint.test.LintViolation import com.twitter.compose.rules.ComposeMultipleContentEmitters -import com.twitter.rules.core.ktlint.contentEmittersProperty import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Test @@ -71,13 +70,13 @@ class ComposeMultipleContentEmittersCheckTest { LintViolation( line = 2, col = 5, - detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected + detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected, ), LintViolation( line = 7, col = 5, - detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected - ) + detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected, + ), ) } @@ -111,19 +110,19 @@ class ComposeMultipleContentEmittersCheckTest { """.trimIndent() emittersRuleAssertThat(code) .withEditorConfigOverride( - contentEmittersProperty to "Potato,Banana" + contentEmittersProperty to "Potato,Banana", ) .hasLintViolationsWithoutAutoCorrect( LintViolation( line = 6, col = 5, - detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected + detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected, ), LintViolation( line = 19, col = 5, - detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected - ) + detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected, + ), ) } @@ -147,8 +146,8 @@ class ComposeMultipleContentEmittersCheckTest { LintViolation( line = 2, col = 5, - detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected - ) + detail = ComposeMultipleContentEmitters.MultipleContentEmittersDetected, + ), ) } } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeMutableParametersCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeMutableParametersCheckTest.kt index fd1c6686..5c8f51fa 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeMutableParametersCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeMutableParametersCheckTest.kt @@ -30,23 +30,23 @@ class ComposeMutableParametersCheckTest { LintViolation( line = 2, col = 15, - detail = ComposeMutableParameters.MutableParameterInCompose + detail = ComposeMutableParameters.MutableParameterInCompose, ), LintViolation( line = 4, col = 15, - detail = ComposeMutableParameters.MutableParameterInCompose + detail = ComposeMutableParameters.MutableParameterInCompose, ), LintViolation( line = 6, col = 15, - detail = ComposeMutableParameters.MutableParameterInCompose + detail = ComposeMutableParameters.MutableParameterInCompose, ), LintViolation( line = 8, col = 15, - detail = ComposeMutableParameters.MutableParameterInCompose - ) + detail = ComposeMutableParameters.MutableParameterInCompose, + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeNamingCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeNamingCheckTest.kt index 13071a86..f5b2ac27 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeNamingCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeNamingCheckTest.kt @@ -5,7 +5,6 @@ package com.twitter.compose.rules.ktlint import com.pinterest.ktlint.test.KtLintAssertThat.Companion.assertThatRule import com.pinterest.ktlint.test.LintViolation import com.twitter.compose.rules.ComposeNaming -import com.twitter.rules.core.ktlint.allowedComposeNamingNames import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Test @@ -34,7 +33,7 @@ class ComposeNamingCheckTest { """.trimIndent() namingRuleAssertThat(code) .withEditorConfigOverride( - allowedComposeNamingNames to ".*Presenter" + allowedComposeNamingNames to ".*Presenter", ) .hasNoLintViolations() } @@ -83,8 +82,8 @@ class ComposeNamingCheckTest { LintViolation( line = 2, col = 5, - detail = ComposeNaming.ComposablesThatReturnResultsShouldBeLowercase - ) + detail = ComposeNaming.ComposablesThatReturnResultsShouldBeLowercase, + ), ) } @@ -103,13 +102,13 @@ class ComposeNamingCheckTest { LintViolation( line = 2, col = 5, - detail = ComposeNaming.ComposablesThatDoNotReturnResultsShouldBeCapitalized + detail = ComposeNaming.ComposablesThatDoNotReturnResultsShouldBeCapitalized, ), LintViolation( line = 5, col = 5, - detail = ComposeNaming.ComposablesThatDoNotReturnResultsShouldBeCapitalized - ) + detail = ComposeNaming.ComposablesThatDoNotReturnResultsShouldBeCapitalized, + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeParameterOrderCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeParameterOrderCheckTest.kt index b3c75864..57bca86a 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeParameterOrderCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeParameterOrderCheckTest.kt @@ -55,41 +55,45 @@ class ComposeParameterOrderCheckTest { col = 5, detail = ComposeParameterOrder.createErrorMessage( currentOrder = "modifier: Modifier = Modifier, other: String, other2: String", - properOrder = "other: String, other2: String, modifier: Modifier = Modifier" - ) + properOrder = "other: String, other2: String, modifier: Modifier = Modifier", + ), ), LintViolation( line = 5, col = 5, detail = ComposeParameterOrder.createErrorMessage( currentOrder = "text: String = \"deffo\", modifier: Modifier = Modifier", - properOrder = "modifier: Modifier = Modifier, text: String = \"deffo\"" - ) + properOrder = "modifier: Modifier = Modifier, text: String = \"deffo\"", + ), ), LintViolation( line = 8, col = 5, detail = ComposeParameterOrder.createErrorMessage( - currentOrder = "modifier: Modifier = Modifier, text: String = \"123\", modifier2: Modifier = Modifier", - properOrder = "modifier: Modifier = Modifier, modifier2: Modifier = Modifier, text: String = \"123\"" - ) + currentOrder = + "modifier: Modifier = Modifier, text: String = \"123\", modifier2: Modifier = Modifier", + properOrder = + "modifier: Modifier = Modifier, modifier2: Modifier = Modifier, text: String = \"123\"", + ), ), LintViolation( line = 11, col = 5, detail = ComposeParameterOrder.createErrorMessage( currentOrder = "text: String = \"123\", modifier: Modifier = Modifier, lambda: () -> Unit", - properOrder = "modifier: Modifier = Modifier, text: String = \"123\", lambda: () -> Unit" - ) + properOrder = "modifier: Modifier = Modifier, text: String = \"123\", lambda: () -> Unit", + ), ), LintViolation( line = 14, col = 5, detail = ComposeParameterOrder.createErrorMessage( - currentOrder = "text1: String, m2: Modifier = Modifier, modifier: Modifier = Modifier, trailing: () -> Unit", - properOrder = "text1: String, modifier: Modifier = Modifier, m2: Modifier = Modifier, trailing: () -> Unit" - ) - ) + currentOrder = + "text1: String, m2: Modifier = Modifier, modifier: Modifier = Modifier, trailing: () -> Unit", + properOrder = + "text1: String, modifier: Modifier = Modifier, m2: Modifier = Modifier, trailing: () -> Unit", + ), + ), ) } } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposePreviewNamingCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposePreviewNamingCheckTest.kt index ad801c5b..b98ed4b4 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposePreviewNamingCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposePreviewNamingCheckTest.kt @@ -60,18 +60,18 @@ class ComposePreviewNamingCheckTest { LintViolation( line = 2, col = 18, - detail = ComposePreviewNaming.createMessage(1, "Preview") + detail = ComposePreviewNaming.createMessage(1, "Preview"), ), LintViolation( line = 4, col = 18, - detail = ComposePreviewNaming.createMessage(1, "Preview") + detail = ComposePreviewNaming.createMessage(1, "Preview"), ), LintViolation( line = 6, col = 18, - detail = ComposePreviewNaming.createMessage(1, "Preview") - ) + detail = ComposePreviewNaming.createMessage(1, "Preview"), + ), ) } @@ -91,13 +91,13 @@ class ComposePreviewNamingCheckTest { LintViolation( line = 3, col = 18, - detail = ComposePreviewNaming.createMessage(2, "Previews") + detail = ComposePreviewNaming.createMessage(2, "Previews"), ), LintViolation( line = 6, col = 18, - detail = ComposePreviewNaming.createMessage(2, "Previews") - ) + detail = ComposePreviewNaming.createMessage(2, "Previews"), + ), ) } } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposePreviewPublicCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposePreviewPublicCheckTest.kt index ef736aaa..d963f9d6 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposePreviewPublicCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposePreviewPublicCheckTest.kt @@ -5,7 +5,6 @@ package com.twitter.compose.rules.ktlint import com.pinterest.ktlint.test.KtLintAssertThat.Companion.assertThatRule import com.pinterest.ktlint.test.LintViolation import com.twitter.compose.rules.ComposePreviewPublic -import com.twitter.rules.core.ktlint.previewPublicOnlyIfParams import org.intellij.lang.annotations.Language import org.junit.jupiter.api.Test @@ -57,13 +56,13 @@ class ComposePreviewPublicCheckTest { LintViolation( line = 3, col = 5, - detail = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic + detail = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic, ), LintViolation( line = 7, col = 5, - detail = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic - ) + detail = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic, + ), ) } @@ -85,13 +84,13 @@ class ComposePreviewPublicCheckTest { LintViolation( line = 3, col = 5, - detail = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic + detail = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic, ), LintViolation( line = 6, col = 5, - detail = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic - ) + detail = ComposePreviewPublic.ComposablesPreviewShouldNotBePublic, + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeRememberMissingCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeRememberMissingCheckTest.kt index c1b75444..fa31ba8f 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeRememberMissingCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeRememberMissingCheckTest.kt @@ -39,13 +39,13 @@ class ComposeRememberMissingCheckTest { LintViolation( line = 3, col = 21, - detail = ComposeRememberMissing.MutableStateOfNotRemembered + detail = ComposeRememberMissing.MutableStateOfNotRemembered, ), LintViolation( line = 6, col = 45, - detail = ComposeRememberMissing.MutableStateOfNotRemembered - ) + detail = ComposeRememberMissing.MutableStateOfNotRemembered, + ), ) } @@ -108,13 +108,13 @@ class ComposeRememberMissingCheckTest { LintViolation( line = 3, col = 21, - detail = ComposeRememberMissing.DerivedStateOfNotRemembered + detail = ComposeRememberMissing.DerivedStateOfNotRemembered, ), LintViolation( line = 6, col = 45, - detail = ComposeRememberMissing.DerivedStateOfNotRemembered - ) + detail = ComposeRememberMissing.DerivedStateOfNotRemembered, + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeUnstableCollectionsCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeUnstableCollectionsCheckTest.kt index cbf11828..0f1e85c1 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeUnstableCollectionsCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeUnstableCollectionsCheckTest.kt @@ -28,18 +28,18 @@ class ComposeUnstableCollectionsCheckTest { LintViolation( line = 2, col = 18, - detail = createErrorMessage("List", "List", "a") + detail = createErrorMessage("List", "List", "a"), ), LintViolation( line = 4, col = 18, - detail = createErrorMessage("Set", "Set", "a") + detail = createErrorMessage("Set", "Set", "a"), ), LintViolation( line = 6, col = 18, - detail = createErrorMessage("Map", "Map", "a") - ) + detail = createErrorMessage("Map", "Map", "a"), + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeViewModelForwardingCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeViewModelForwardingCheckTest.kt index 682fa054..97aae764 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeViewModelForwardingCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeViewModelForwardingCheckTest.kt @@ -70,8 +70,8 @@ class ComposeViewModelForwardingCheckTest { LintViolation( line = 3, col = 5, - detail = ComposeViewModelForwarding.AvoidViewModelForwarding - ) + detail = ComposeViewModelForwarding.AvoidViewModelForwarding, + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeViewModelInjectionCheckTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeViewModelInjectionCheckTest.kt index 840cb462..4deede72 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeViewModelInjectionCheckTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/ComposeViewModelInjectionCheckTest.kt @@ -66,18 +66,18 @@ class ComposeViewModelInjectionCheckTest { LintViolation( line = 3, col = 9, - detail = ComposeViewModelInjection.errorMessage(viewModel) + detail = ComposeViewModelInjection.errorMessage(viewModel), ), LintViolation( line = 7, col = 9, - detail = ComposeViewModelInjection.errorMessage(viewModel) + detail = ComposeViewModelInjection.errorMessage(viewModel), ), LintViolation( line = 11, col = 9, - detail = ComposeViewModelInjection.errorMessage(viewModel) - ) + detail = ComposeViewModelInjection.errorMessage(viewModel), + ), ) } @@ -100,13 +100,13 @@ class ComposeViewModelInjectionCheckTest { LintViolation( line = 4, col = 13, - detail = ComposeViewModelInjection.errorMessage(viewModel) + detail = ComposeViewModelInjection.errorMessage(viewModel), ), LintViolation( line = 6, col = 13, - detail = ComposeViewModelInjection.errorMessage(viewModel) - ) + detail = ComposeViewModelInjection.errorMessage(viewModel), + ), ) } diff --git a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/TwitterComposeRuleSetProviderTest.kt b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/TwitterComposeRuleSetProviderTest.kt index a9c6aa4a..c785ad26 100644 --- a/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/TwitterComposeRuleSetProviderTest.kt +++ b/rules/ktlint/src/test/kotlin/com/twitter/compose/rules/ktlint/TwitterComposeRuleSetProviderTest.kt @@ -14,15 +14,7 @@ class TwitterComposeRuleSetProviderTest { .getSubTypesOf(TwitterKtlintRule::class.java) @Test - fun `ensure all rules in the package are represented in the old ruleset`() { - @Suppress("DEPRECATION") - val ruleSet = ruleSetProvider.get() - val ruleClassesInRuleSet = ruleSet.rules.filterIsInstance().map { it::class.java }.toSet() - assertThat(ruleClassesInRuleSet).containsExactlyInAnyOrderElementsOf(ruleClassesInPackage) - } - - @Test - fun `ensure all rules in the package are represented in the new ruleset`() { + fun `ensure all rules in the package are represented in the ruleset`() { val ruleSet = ruleSetProvider.getRuleProviders() val ruleClassesInRuleSet = ruleSet.map { it.createNewRuleInstance() } .filterIsInstance()