From 0490e014f6b1e99811d26dacff92268c6704f29d Mon Sep 17 00:00:00 2001 From: lihenggui Date: Thu, 14 Dec 2023 14:26:34 -0800 Subject: [PATCH 1/9] Update Spotless and ktlint --- .editorconfig | 1 + gradle/init.gradle.kts | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 83be1d5a0..2d5a46b3c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,3 +4,4 @@ [*.{kt,kts}] ij_kotlin_allow_trailing_comma=true ij_kotlin_allow_trailing_comma_on_call_site=true +ktlint_function_naming_ignore_when_annotated_with=Composable diff --git a/gradle/init.gradle.kts b/gradle/init.gradle.kts index 72f3eebe0..fe79fa01e 100644 --- a/gradle/init.gradle.kts +++ b/gradle/init.gradle.kts @@ -14,10 +14,10 @@ * limitations under the License. */ -val ktlintVersion = "0.48.1" +val ktlintVersion = "1.0.1" initscript { - val spotlessVersion = "6.22.0" + val spotlessVersion = "6.23.3" repositories { mavenCentral() @@ -35,7 +35,11 @@ rootProject { kotlin { target("**/*.kt") targetExclude("**/build/**/*.kt") - ktlint(ktlintVersion).userData(mapOf("android" to "true")) + ktlint(ktlintVersion).editorConfigOverride( + mapOf( + "android" to "true", + ), + ) licenseHeaderFile(rootProject.file("spotless/copyright.kt")) } format("kts") { From ff599eac37ad179fbf2bdcc1783f4c3493c972af Mon Sep 17 00:00:00 2001 From: lihenggui Date: Thu, 14 Dec 2023 14:46:37 -0800 Subject: [PATCH 2/9] Ignore property-naming and discouraged-comment-location --- gradle/init.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gradle/init.gradle.kts b/gradle/init.gradle.kts index fe79fa01e..a06d659fa 100644 --- a/gradle/init.gradle.kts +++ b/gradle/init.gradle.kts @@ -38,6 +38,8 @@ rootProject { ktlint(ktlintVersion).editorConfigOverride( mapOf( "android" to "true", + "ktlint_standard_property-naming" to "disabled", + "ktlint_standard_discouraged-comment-location" to "disabled", ), ) licenseHeaderFile(rootProject.file("spotless/copyright.kt")) From fb5bd225be83aff2c444aca999c92986c793a11f Mon Sep 17 00:00:00 2001 From: lihenggui Date: Thu, 14 Dec 2023 14:49:25 -0800 Subject: [PATCH 3/9] Spotless --- .../samples/apps/nowinandroid/MainActivity.kt | 2 +- .../core/analytics/AnalyticsModule.kt | 4 +- .../nowinandroid/core/result/ResultKtTest.kt | 2 +- .../datastore/IntToStringIdsMigrationTest.kt | 4 +- .../core/datastore/ListToMapMigrationTest.kt | 6 +- .../core/designsystem/component/Button.kt | 2 +- .../component/scrollbar/AppScrollbars.kt | 4 +- .../LoadingWheelScreenshotTests.kt | 2 +- .../core/designsystem/TagScreenshotTests.kt | 2 +- .../core/model/data/DarkThemeConfig.kt | 4 +- .../core/model/data/ThemeBrand.kt | 3 +- .../fake/FakeNiaNetworkDataSourceTest.kt | 80 +++++++++---------- .../testing/data/FollowableTopicTestData.kt | 3 +- .../testing/data/NewsResourcesTestData.kt | 3 +- .../core/testing/data/TopicsTestData.kt | 3 +- .../testing/data/UserNewsResourcesTestData.kt | 3 +- ...FollowableTopicPreviewParameterProvider.kt | 3 +- ...serNewsResourcePreviewParameterProvider.kt | 3 +- .../SearchUiStatePreviewParameterProvider.kt | 3 +- .../feature/settings/SettingsDialog.kt | 3 +- 20 files changed, 77 insertions(+), 62 deletions(-) diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt index 7fe1bc674..1f2bc49b9 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt @@ -179,7 +179,7 @@ class MainActivity : ComponentActivity() { To see quick turnaround of the ProfileVerifier, we recommend using `speed-profile`. If you don't do either of these steps, you might only see the profile status reported as "enqueued for compilation" when running the sample locally. - */ + */ withContext(Dispatchers.IO) { val status = ProfileVerifier.getCompilationStatusAsync().await() Log.d(TAG, "ProfileInstaller status code: ${status.profileInstallResultCode}") diff --git a/core/analytics/src/prod/kotlin/com/google/samples/apps/nowinandroid/core/analytics/AnalyticsModule.kt b/core/analytics/src/prod/kotlin/com/google/samples/apps/nowinandroid/core/analytics/AnalyticsModule.kt index 9f875ae6d..0d2e0e274 100644 --- a/core/analytics/src/prod/kotlin/com/google/samples/apps/nowinandroid/core/analytics/AnalyticsModule.kt +++ b/core/analytics/src/prod/kotlin/com/google/samples/apps/nowinandroid/core/analytics/AnalyticsModule.kt @@ -35,6 +35,8 @@ abstract class AnalyticsModule { companion object { @Provides @Singleton - fun provideFirebaseAnalytics(): FirebaseAnalytics { return Firebase.analytics } + fun provideFirebaseAnalytics(): FirebaseAnalytics { + return Firebase.analytics + } } } diff --git a/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt b/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt index 4f1229e9d..512a1a2f2 100644 --- a/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt +++ b/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt @@ -25,7 +25,7 @@ import kotlin.test.assertEquals class ResultKtTest { @Test - fun Result_catches_errors() = runTest { + fun result_catches_errors() = runTest { flow { emit(1) throw Exception("Test Done") diff --git a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/IntToStringIdsMigrationTest.kt b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/IntToStringIdsMigrationTest.kt index 8b97cff34..392ca2550 100644 --- a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/IntToStringIdsMigrationTest.kt +++ b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/IntToStringIdsMigrationTest.kt @@ -27,7 +27,7 @@ import kotlin.test.assertTrue class IntToStringIdsMigrationTest { @Test - fun IntToStringIdsMigration_should_migrate_topic_ids() = runTest { + fun intToStringIdsMigration_should_migrate_topic_ids() = runTest { // Set up existing preferences with topic int ids val preMigrationUserPreferences = userPreferences { deprecatedIntFollowedTopicIds.addAll(listOf(1, 2, 3)) @@ -56,7 +56,7 @@ class IntToStringIdsMigrationTest { } @Test - fun IntToStringIdsMigration_should_migrate_author_ids() = runTest { + fun intToStringIdsMigration_should_migrate_author_ids() = runTest { // Set up existing preferences with author int ids val preMigrationUserPreferences = userPreferences { deprecatedIntFollowedAuthorIds.addAll(listOf(4, 5, 6)) diff --git a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ListToMapMigrationTest.kt b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ListToMapMigrationTest.kt index f7e083b45..41404d6a9 100644 --- a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ListToMapMigrationTest.kt +++ b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ListToMapMigrationTest.kt @@ -24,7 +24,7 @@ import kotlin.test.assertTrue class ListToMapMigrationTest { @Test - fun ListToMapMigration_should_migrate_topic_ids() = runTest { + fun listToMapMigration_should_migrate_topic_ids() = runTest { // Set up existing preferences with topic ids val preMigrationUserPreferences = userPreferences { deprecatedFollowedTopicIds.addAll(listOf("1", "2", "3")) @@ -50,7 +50,7 @@ class ListToMapMigrationTest { } @Test - fun ListToMapMigration_should_migrate_author_ids() = runTest { + fun listToMapMigration_should_migrate_author_ids() = runTest { // Set up existing preferences with author ids val preMigrationUserPreferences = userPreferences { deprecatedFollowedAuthorIds.addAll(listOf("4", "5", "6")) @@ -76,7 +76,7 @@ class ListToMapMigrationTest { } @Test - fun ListToMapMigration_should_migrate_bookmarks() = runTest { + fun listToMapMigration_should_migrate_bookmarks() = runTest { // Set up existing preferences with bookmarks val preMigrationUserPreferences = userPreferences { deprecatedBookmarkedNewsResourceIds.addAll(listOf("7", "8", "9")) diff --git a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Button.kt b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Button.kt index 966014fd9..a5ecc86c1 100644 --- a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Button.kt +++ b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Button.kt @@ -278,7 +278,7 @@ fun NiaButtonPreview() { @ThemePreviews @Composable fun NiaOutlinedButtonPreview() { - NiaTheme() { + NiaTheme { NiaBackground(modifier = Modifier.size(150.dp, 50.dp)) { NiaOutlinedButton(onClick = {}, text = { Text("Test button") }) } diff --git a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/AppScrollbars.kt b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/AppScrollbars.kt index fe14bce14..c8102073a 100644 --- a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/AppScrollbars.kt +++ b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/AppScrollbars.kt @@ -251,5 +251,7 @@ private fun scrollbarThumbColor( } private enum class ThumbState { - Active, Inactive, Dormant + Active, + Inactive, + Dormant, } diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/LoadingWheelScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/LoadingWheelScreenshotTests.kt index 75a4aec3a..9f80d04e5 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/LoadingWheelScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/LoadingWheelScreenshotTests.kt @@ -66,7 +66,7 @@ class LoadingWheelScreenshotTests() { fun loadingWheelAnimation() { composeTestRule.mainClock.autoAdvance = false composeTestRule.setContent { - NiaTheme() { + NiaTheme { NiaLoadingWheel(contentDesc = "") } } diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt index d9edfd6c6..16ed71aeb 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt @@ -47,7 +47,7 @@ class TagScreenshotTests() { val composeTestRule = createAndroidComposeRule() @Test - fun Tag_multipleThemes() { + fun tag_multipleThemes() { composeTestRule.captureMultiTheme("Tag") { NiaTopicTag(followed = true, onClick = {}) { Text("TOPIC") diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/DarkThemeConfig.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/DarkThemeConfig.kt index f130a70db..dcbcaa531 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/DarkThemeConfig.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/DarkThemeConfig.kt @@ -17,5 +17,7 @@ package com.google.samples.apps.nowinandroid.core.model.data enum class DarkThemeConfig { - FOLLOW_SYSTEM, LIGHT, DARK + FOLLOW_SYSTEM, + LIGHT, + DARK, } diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/ThemeBrand.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/ThemeBrand.kt index d8953df3c..431d4b573 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/ThemeBrand.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/ThemeBrand.kt @@ -17,5 +17,6 @@ package com.google.samples.apps.nowinandroid.core.model.data enum class ThemeBrand { - DEFAULT, ANDROID + DEFAULT, + ANDROID, } diff --git a/core/network/src/test/kotlin/com/google/samples/apps/nowinandroid/core/network/fake/FakeNiaNetworkDataSourceTest.kt b/core/network/src/test/kotlin/com/google/samples/apps/nowinandroid/core/network/fake/FakeNiaNetworkDataSourceTest.kt index 76c2accf2..147252cf1 100644 --- a/core/network/src/test/kotlin/com/google/samples/apps/nowinandroid/core/network/fake/FakeNiaNetworkDataSourceTest.kt +++ b/core/network/src/test/kotlin/com/google/samples/apps/nowinandroid/core/network/fake/FakeNiaNetworkDataSourceTest.kt @@ -45,46 +45,46 @@ class FakeNiaNetworkDataSourceTest { } @Test - fun testDeserializationOfTopics() = runTest(testDispatcher) { - assertEquals( - /* ktlint-disable max-line-length */ - NetworkTopic( - id = "1", - name = "Headlines", - shortDescription = "News you'll definitely be interested in", - longDescription = "The latest events and announcements from the world of Android development.", - url = "", - imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f", - ), - /* ktlint-enable max-line-length */ - subject.getTopics().first(), - ) - } + fun testDeserializationOfTopics() = + @Suppress("ktlint:standard:max-line-length") + runTest(testDispatcher) { + assertEquals( + NetworkTopic( + id = "1", + name = "Headlines", + shortDescription = "News you'll definitely be interested in", + longDescription = "The latest events and announcements from the world of Android development.", + url = "", + imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f", + ), + subject.getTopics().first(), + ) + } @Test - fun testDeserializationOfNewsResources() = runTest(testDispatcher) { - assertEquals( - /* ktlint-disable max-line-length */ - NetworkNewsResource( - id = "125", - title = "Android Basics with Compose", - content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. ", - url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html", - headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg", - publishDate = LocalDateTime( - year = 2022, - monthNumber = 5, - dayOfMonth = 4, - hour = 23, - minute = 0, - second = 0, - nanosecond = 0, - ).toInstant(TimeZone.UTC), - type = "Codelab", - topics = listOf("2", "3", "10"), - ), - /* ktlint-enable max-line-length */ - subject.getNewsResources().find { it.id == "125" }, - ) - } + fun testDeserializationOfNewsResources() = + @Suppress("ktlint:standard:max-line-length") + runTest(testDispatcher) { + assertEquals( + NetworkNewsResource( + id = "125", + title = "Android Basics with Compose", + content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. ", + url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html", + headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg", + publishDate = LocalDateTime( + year = 2022, + monthNumber = 5, + dayOfMonth = 4, + hour = 23, + minute = 0, + second = 0, + nanosecond = 0, + ).toInstant(TimeZone.UTC), + type = "Codelab", + topics = listOf("2", "3", "10"), + ), + subject.getNewsResources().find { it.id == "125" }, + ) + } } diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/FollowableTopicTestData.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/FollowableTopicTestData.kt index a96326a62..9b85516e7 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/FollowableTopicTestData.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/FollowableTopicTestData.kt @@ -14,12 +14,13 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:max-line-length") + package com.google.samples.apps.nowinandroid.core.testing.data import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic import com.google.samples.apps.nowinandroid.core.model.data.Topic -/* ktlint-disable max-line-length */ val followableTopicTestData: List = listOf( FollowableTopic( topic = Topic( diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/NewsResourcesTestData.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/NewsResourcesTestData.kt index ef845dc58..b3fff7ca0 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/NewsResourcesTestData.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/NewsResourcesTestData.kt @@ -14,12 +14,13 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:max-line-length") + package com.google.samples.apps.nowinandroid.core.testing.data import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import kotlinx.datetime.Instant -/* ktlint-disable max-line-length */ val newsResourcesTestData: List = listOf( NewsResource( id = "1", diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/TopicsTestData.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/TopicsTestData.kt index 90e9166a5..fc6ef62a6 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/TopicsTestData.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/TopicsTestData.kt @@ -14,11 +14,12 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:max-line-length") + package com.google.samples.apps.nowinandroid.core.testing.data import com.google.samples.apps.nowinandroid.core.model.data.Topic -/* ktlint-disable max-line-length */ val topicsTestData: List = listOf( Topic( id = "2", diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/UserNewsResourcesTestData.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/UserNewsResourcesTestData.kt index 97acad088..4174391df 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/UserNewsResourcesTestData.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/UserNewsResourcesTestData.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:max-line-length") + package com.google.samples.apps.nowinandroid.core.testing.data import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig @@ -26,7 +28,6 @@ import kotlinx.datetime.LocalDateTime import kotlinx.datetime.TimeZone import kotlinx.datetime.toInstant -/* ktlint-disable max-line-length */ val userNewsResourcesTestData: List = UserData( bookmarkedNewsResources = setOf("1", "4"), viewedNewsResources = setOf("1", "2", "4"), diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/FollowableTopicPreviewParameterProvider.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/FollowableTopicPreviewParameterProvider.kt index 2132f5b16..16ae1eced 100644 --- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/FollowableTopicPreviewParameterProvider.kt +++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/FollowableTopicPreviewParameterProvider.kt @@ -14,13 +14,14 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:max-line-length") + package com.google.samples.apps.nowinandroid.core.ui import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic import com.google.samples.apps.nowinandroid.core.model.data.Topic -/* ktlint-disable max-line-length */ /** * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * provides list of [FollowableTopic] for Composable previews. diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/UserNewsResourcePreviewParameterProvider.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/UserNewsResourcePreviewParameterProvider.kt index 493788314..3189e8403 100644 --- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/UserNewsResourcePreviewParameterProvider.kt +++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/UserNewsResourcePreviewParameterProvider.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:max-line-length") + package com.google.samples.apps.nowinandroid.core.ui import androidx.compose.ui.tooling.preview.PreviewParameterProvider @@ -29,7 +31,6 @@ import kotlinx.datetime.LocalDateTime import kotlinx.datetime.TimeZone import kotlinx.datetime.toInstant -/* ktlint-disable max-line-length */ /** * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * provides list of [UserNewsResource] for Composable previews. diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchUiStatePreviewParameterProvider.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchUiStatePreviewParameterProvider.kt index 4268893da..257d8b68e 100644 --- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchUiStatePreviewParameterProvider.kt +++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchUiStatePreviewParameterProvider.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:max-line-length") + package com.google.samples.apps.nowinandroid.feature.search import androidx.compose.ui.tooling.preview.PreviewParameterProvider @@ -21,7 +23,6 @@ import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.newsResources import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.topics -/* ktlint-disable max-line-length */ /** * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * provides list of [SearchResultUiState] for Composable previews. diff --git a/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt b/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt index 01ec30e74..b6ce77d1a 100644 --- a/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt +++ b/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt @@ -14,6 +14,8 @@ * limitations under the License. */ +@file:Suppress("ktlint:standard:max-line-length") + package com.google.samples.apps.nowinandroid.feature.settings import android.content.Intent @@ -316,7 +318,6 @@ private fun PreviewSettingsDialogLoading() { } } -/* ktlint-disable max-line-length */ private const val PRIVACY_POLICY_URL = "https://policies.google.com/privacy" private const val BRAND_GUIDELINES_URL = "https://developer.android.com/distribute/marketing-tools/brand-guidelines" private const val FEEDBACK_URL = "https://goo.gle/nia-app-feedback" From f8f932705a71d47f4925f5cad9bbbcacdb3cc0c1 Mon Sep 17 00:00:00 2001 From: lihenggui Date: Thu, 14 Dec 2023 14:56:11 -0800 Subject: [PATCH 4/9] Remove violations: discouraged-comment-location --- .../samples/apps/nowinandroid/startup/StartupBenchmark.kt | 3 ++- .../apps/nowinandroid/core/model/data/FollowableTopic.kt | 3 ++- .../apps/nowinandroid/core/testing/util/ScreenshotHelper.kt | 6 ++++-- .../samples/apps/nowinandroid/core/ui/NewsResourceCard.kt | 6 ++++-- .../apps/nowinandroid/feature/foryou/ForYouScreen.kt | 3 ++- .../apps/nowinandroid/feature/interests/InterestsItem.kt | 3 ++- .../apps/nowinandroid/feature/search/SearchScreen.kt | 3 ++- gradle/init.gradle.kts | 1 - 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/benchmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt b/benchmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt index ace7f14e4..96bea89b8 100644 --- a/benchmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt +++ b/benchmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/startup/StartupBenchmark.kt @@ -60,7 +60,8 @@ class StartupBenchmark { packageName = PACKAGE_NAME, metrics = listOf(StartupTimingMetric()), compilationMode = compilationMode, - iterations = 20, // More iterations result in higher statistical significance. + // More iterations result in higher statistical significance. + iterations = 20, startupMode = COLD, setupBlock = { pressHome() diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/FollowableTopic.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/FollowableTopic.kt index cef319c5f..ae1d525c5 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/FollowableTopic.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/FollowableTopic.kt @@ -19,7 +19,8 @@ package com.google.samples.apps.nowinandroid.core.model.data /** * A [topic] with the additional information for whether or not it is followed. */ -data class FollowableTopic( // TODO consider changing to UserTopic and flattening +// TODO consider changing to UserTopic and flattening +data class FollowableTopic( val topic: Topic, val isFollowed: Boolean, ) diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt index e84fe7d33..0f00ff16d 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt @@ -38,8 +38,10 @@ import org.robolectric.RuntimeEnvironment val DefaultRoborazziOptions = RoborazziOptions( - compareOptions = CompareOptions(changeThreshold = 0f), // Pixel-perfect matching - recordOptions = RecordOptions(resizeScale = 0.5), // Reduce the size of the PNGs + // Pixel-perfect matching + compareOptions = CompareOptions(changeThreshold = 0f), + // Reduce the size of the PNGs + recordOptions = RecordOptions(resizeScale = 0.5), ) enum class DefaultTestDevices(val description: String, val spec: String) { diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt index de4aec9d7..114e845d4 100644 --- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt +++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt @@ -186,7 +186,8 @@ fun NewsResourceHeaderImage( painterResource(drawable.ic_placeholder_default) }, // TODO b/226661685: Investigate using alt text of image to populate content description - contentDescription = null, // decorative image, + // decorative image, + contentDescription = null, ) } } @@ -295,7 +296,8 @@ fun NewsResourceTopics( modifier: Modifier = Modifier, ) { Row( - modifier = modifier.horizontalScroll(rememberScrollState()), // causes narrow chips + // causes narrow chips + modifier = modifier.horizontalScroll(rememberScrollState()), horizontalArrangement = Arrangement.spacedBy(4.dp), ) { for (followableTopic in topics) { diff --git a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt index 65b5ecbc4..f0899b448 100644 --- a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt +++ b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt @@ -437,7 +437,8 @@ fun TopicIcon( DynamicAsyncImage( placeholder = painterResource(R.drawable.ic_icon_placeholder), imageUrl = imageUrl, - contentDescription = null, // decorative + // decorative + contentDescription = null, modifier = modifier .padding(10.dp) .size(32.dp), diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt index 7456ba92b..a9e329e9c 100644 --- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt +++ b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt @@ -99,7 +99,8 @@ private fun InterestsIcon(topicImageUrl: String, modifier: Modifier = Modifier) .background(MaterialTheme.colorScheme.surface) .padding(4.dp), imageVector = NiaIcons.Person, - contentDescription = null, // decorative image + // decorative image + contentDescription = null, ) } else { DynamicAsyncImage( diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt index 65b65f61d..72842ec61 100644 --- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt +++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt @@ -328,7 +328,8 @@ private fun SearchResultBody( topics.forEach { followableTopic -> val topicId = followableTopic.topic.id item( - key = "topic-$topicId", // Append a prefix to distinguish a key for news resources + // Append a prefix to distinguish a key for news resources + key = "topic-$topicId", span = StaggeredGridItemSpan.FullLine, ) { InterestsItem( diff --git a/gradle/init.gradle.kts b/gradle/init.gradle.kts index a06d659fa..f2e6114aa 100644 --- a/gradle/init.gradle.kts +++ b/gradle/init.gradle.kts @@ -39,7 +39,6 @@ rootProject { mapOf( "android" to "true", "ktlint_standard_property-naming" to "disabled", - "ktlint_standard_discouraged-comment-location" to "disabled", ), ) licenseHeaderFile(rootProject.file("spotless/copyright.kt")) From 32e1ec0447294ada76c83bc1f54a88f3487b0e04 Mon Sep 17 00:00:00 2001 From: lihenggui Date: Thu, 14 Dec 2023 16:18:27 -0800 Subject: [PATCH 5/9] Remove violations: property-naming --- .../apps/nowinandroid/navigation/NiaNavHost.kt | 4 ++-- .../samples/apps/nowinandroid/ui/NiaAppState.kt | 12 ++++++------ .../core/designsystem/component/Button.kt | 4 ++-- .../core/designsystem/component/Chip.kt | 14 +++++++------- .../core/designsystem/component/IconButton.kt | 4 ++-- .../core/designsystem/component/Tag.kt | 8 ++++---- .../bookmarks/navigation/BookmarksNavigation.kt | 6 +++--- .../feature/foryou/navigation/ForYouNavigation.kt | 6 +++--- .../interests/navigation/InterestsNavigation.kt | 6 +++--- .../feature/search/navigation/SearchNavigation.kt | 6 +++--- .../feature/topic/navigation/TopicNavigation.kt | 8 ++++---- .../feature/topic/TopicViewModelTest.kt | 4 ++-- gradle/init.gradle.kts | 1 - .../sync/initializers/SyncInitializer.kt | 4 ++-- .../sync/status/WorkManagerSyncManager.kt | 6 +++--- 15 files changed, 46 insertions(+), 47 deletions(-) diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt index 3d58ed5a6..70651ed12 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt @@ -20,7 +20,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.navigation.compose.NavHost import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.bookmarksScreen -import com.google.samples.apps.nowinandroid.feature.foryou.navigation.forYouNavigationRoute +import com.google.samples.apps.nowinandroid.feature.foryou.navigation.FOR_YOU_NAVIGATION_ROUTE import com.google.samples.apps.nowinandroid.feature.foryou.navigation.forYouScreen import com.google.samples.apps.nowinandroid.feature.interests.navigation.interestsGraph import com.google.samples.apps.nowinandroid.feature.search.navigation.searchScreen @@ -41,7 +41,7 @@ fun NiaNavHost( appState: NiaAppState, onShowSnackbar: suspend (String, String?) -> Boolean, modifier: Modifier = Modifier, - startDestination: String = forYouNavigationRoute, + startDestination: String = FOR_YOU_NAVIGATION_ROUTE, ) { val navController = appState.navController NavHost( diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt index 09e70069e..9c587cc5c 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt @@ -33,11 +33,11 @@ import androidx.tracing.trace import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor import com.google.samples.apps.nowinandroid.core.ui.TrackDisposableJank -import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.bookmarksRoute +import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.BOOKMARKS_ROUTE import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.navigateToBookmarks -import com.google.samples.apps.nowinandroid.feature.foryou.navigation.forYouNavigationRoute +import com.google.samples.apps.nowinandroid.feature.foryou.navigation.FOR_YOU_NAVIGATION_ROUTE import com.google.samples.apps.nowinandroid.feature.foryou.navigation.navigateToForYou -import com.google.samples.apps.nowinandroid.feature.interests.navigation.interestsRoute +import com.google.samples.apps.nowinandroid.feature.interests.navigation.INTERESTS_ROUTE import com.google.samples.apps.nowinandroid.feature.interests.navigation.navigateToInterestsGraph import com.google.samples.apps.nowinandroid.feature.search.navigation.navigateToSearch import com.google.samples.apps.nowinandroid.navigation.TopLevelDestination @@ -91,9 +91,9 @@ class NiaAppState( val currentTopLevelDestination: TopLevelDestination? @Composable get() = when (currentDestination?.route) { - forYouNavigationRoute -> FOR_YOU - bookmarksRoute -> BOOKMARKS - interestsRoute -> INTERESTS + FOR_YOU_NAVIGATION_ROUTE -> FOR_YOU + BOOKMARKS_ROUTE -> BOOKMARKS + INTERESTS_ROUTE -> INTERESTS else -> null } diff --git a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Button.kt b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Button.kt index a5ecc86c1..d490ff13e 100644 --- a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Button.kt +++ b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Button.kt @@ -134,7 +134,7 @@ fun NiaOutlinedButton( MaterialTheme.colorScheme.outline } else { MaterialTheme.colorScheme.onSurface.copy( - alpha = NiaButtonDefaults.DisabledOutlinedButtonBorderAlpha, + alpha = NiaButtonDefaults.DISABLED_OUTLINED_BUTTON_BORDER_ALPHA, ) }, ), @@ -315,7 +315,7 @@ fun NiaButtonLeadingIconPreview() { object NiaButtonDefaults { // TODO: File bug // OutlinedButton border color doesn't respect disabled state by default - const val DisabledOutlinedButtonBorderAlpha = 0.12f + const val DISABLED_OUTLINED_BUTTON_BORDER_ALPHA = 0.12f // TODO: File bug // OutlinedButton default border width isn't exposed via ButtonDefaults diff --git a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Chip.kt b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Chip.kt index d1b7d124d..106f0b839 100644 --- a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Chip.kt +++ b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Chip.kt @@ -76,10 +76,10 @@ fun NiaFilterChip( borderColor = MaterialTheme.colorScheme.onBackground, selectedBorderColor = MaterialTheme.colorScheme.onBackground, disabledBorderColor = MaterialTheme.colorScheme.onBackground.copy( - alpha = NiaChipDefaults.DisabledChipContentAlpha, + alpha = NiaChipDefaults.DISABLED_CHIP_CONTENT_ALPHA, ), disabledSelectedBorderColor = MaterialTheme.colorScheme.onBackground.copy( - alpha = NiaChipDefaults.DisabledChipContentAlpha, + alpha = NiaChipDefaults.DISABLED_CHIP_CONTENT_ALPHA, ), selectedBorderWidth = NiaChipDefaults.ChipBorderWidth, ), @@ -88,16 +88,16 @@ fun NiaFilterChip( iconColor = MaterialTheme.colorScheme.onBackground, disabledContainerColor = if (selected) { MaterialTheme.colorScheme.onBackground.copy( - alpha = NiaChipDefaults.DisabledChipContainerAlpha, + alpha = NiaChipDefaults.DISABLED_CHIP_CONTAINER_ALPHA, ) } else { Color.Transparent }, disabledLabelColor = MaterialTheme.colorScheme.onBackground.copy( - alpha = NiaChipDefaults.DisabledChipContentAlpha, + alpha = NiaChipDefaults.DISABLED_CHIP_CONTENT_ALPHA, ), disabledLeadingIconColor = MaterialTheme.colorScheme.onBackground.copy( - alpha = NiaChipDefaults.DisabledChipContentAlpha, + alpha = NiaChipDefaults.DISABLED_CHIP_CONTENT_ALPHA, ), selectedContainerColor = MaterialTheme.colorScheme.primaryContainer, selectedLabelColor = MaterialTheme.colorScheme.onBackground, @@ -124,7 +124,7 @@ fun ChipPreview() { object NiaChipDefaults { // TODO: File bug // FilterChip default values aren't exposed via FilterChipDefaults - const val DisabledChipContainerAlpha = 0.12f - const val DisabledChipContentAlpha = 0.38f + const val DISABLED_CHIP_CONTAINER_ALPHA = 0.12f + const val DISABLED_CHIP_CONTENT_ALPHA = 0.38f val ChipBorderWidth = 1.dp } diff --git a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/IconButton.kt b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/IconButton.kt index 503342d30..43ec11f0b 100644 --- a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/IconButton.kt +++ b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/IconButton.kt @@ -60,7 +60,7 @@ fun NiaIconToggleButton( checkedContentColor = MaterialTheme.colorScheme.onPrimaryContainer, disabledContainerColor = if (checked) { MaterialTheme.colorScheme.onBackground.copy( - alpha = NiaIconButtonDefaults.DisabledIconButtonContainerAlpha, + alpha = NiaIconButtonDefaults.DISABLED_ICON_BUTTON_CONTAINER_ALPHA, ) } else { Color.Transparent @@ -123,5 +123,5 @@ fun IconButtonPreviewUnchecked() { object NiaIconButtonDefaults { // TODO: File bug // IconToggleButton disabled container alpha not exposed by IconButtonDefaults - const val DisabledIconButtonContainerAlpha = 0.12f + const val DISABLED_ICON_BUTTON_CONTAINER_ALPHA = 0.12f } diff --git a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Tag.kt b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Tag.kt index 8ca1588a8..290845936 100644 --- a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Tag.kt +++ b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/component/Tag.kt @@ -40,7 +40,7 @@ fun NiaTopicTag( MaterialTheme.colorScheme.primaryContainer } else { MaterialTheme.colorScheme.surfaceVariant.copy( - alpha = NiaTagDefaults.UnfollowedTopicTagContainerAlpha, + alpha = NiaTagDefaults.UNFOLLOWED_TOPIC_TAG_CONTAINER_ALPHA, ) } TextButton( @@ -50,7 +50,7 @@ fun NiaTopicTag( containerColor = containerColor, contentColor = contentColorFor(backgroundColor = containerColor), disabledContainerColor = MaterialTheme.colorScheme.onSurface.copy( - alpha = NiaTagDefaults.DisabledTopicTagContainerAlpha, + alpha = NiaTagDefaults.DISABLED_TOPIC_TAG_CONTAINER_ALPHA, ), ), ) { @@ -75,9 +75,9 @@ fun TagPreview() { * Now in Android tag default values. */ object NiaTagDefaults { - const val UnfollowedTopicTagContainerAlpha = 0.5f + const val UNFOLLOWED_TOPIC_TAG_CONTAINER_ALPHA = 0.5f // TODO: File bug // Button disabled container alpha value not exposed by ButtonDefaults - const val DisabledTopicTagContainerAlpha = 0.12f + const val DISABLED_TOPIC_TAG_CONTAINER_ALPHA = 0.12f } diff --git a/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/navigation/BookmarksNavigation.kt b/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/navigation/BookmarksNavigation.kt index ebcde4ab1..81fa114e2 100644 --- a/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/navigation/BookmarksNavigation.kt +++ b/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/navigation/BookmarksNavigation.kt @@ -22,17 +22,17 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import com.google.samples.apps.nowinandroid.feature.bookmarks.BookmarksRoute -const val bookmarksRoute = "bookmarks_route" +const val BOOKMARKS_ROUTE = "bookmarks_route" fun NavController.navigateToBookmarks(navOptions: NavOptions? = null) { - this.navigate(bookmarksRoute, navOptions) + this.navigate(BOOKMARKS_ROUTE, navOptions) } fun NavGraphBuilder.bookmarksScreen( onTopicClick: (String) -> Unit, onShowSnackbar: suspend (String, String?) -> Boolean, ) { - composable(route = bookmarksRoute) { + composable(route = BOOKMARKS_ROUTE) { BookmarksRoute(onTopicClick, onShowSnackbar) } } diff --git a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/navigation/ForYouNavigation.kt b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/navigation/ForYouNavigation.kt index 705495cc2..264345be4 100644 --- a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/navigation/ForYouNavigation.kt +++ b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/navigation/ForYouNavigation.kt @@ -26,17 +26,17 @@ import androidx.navigation.navDeepLink import com.google.samples.apps.nowinandroid.feature.foryou.ForYouRoute const val LINKED_NEWS_RESOURCE_ID = "linkedNewsResourceId" -const val forYouNavigationRoute = "for_you_route/{$LINKED_NEWS_RESOURCE_ID}" +const val FOR_YOU_NAVIGATION_ROUTE = "for_you_route/{$LINKED_NEWS_RESOURCE_ID}" private const val DEEP_LINK_URI_PATTERN = "https://www.nowinandroid.apps.samples.google.com/foryou/{$LINKED_NEWS_RESOURCE_ID}" fun NavController.navigateToForYou(navOptions: NavOptions? = null) { - this.navigate(forYouNavigationRoute, navOptions) + this.navigate(FOR_YOU_NAVIGATION_ROUTE, navOptions) } fun NavGraphBuilder.forYouScreen(onTopicClick: (String) -> Unit) { composable( - route = forYouNavigationRoute, + route = FOR_YOU_NAVIGATION_ROUTE, deepLinks = listOf( navDeepLink { uriPattern = DEEP_LINK_URI_PATTERN }, ), diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/navigation/InterestsNavigation.kt b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/navigation/InterestsNavigation.kt index 7558ec48d..831247e27 100644 --- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/navigation/InterestsNavigation.kt +++ b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/navigation/InterestsNavigation.kt @@ -24,7 +24,7 @@ import androidx.navigation.navigation import com.google.samples.apps.nowinandroid.feature.interests.InterestsRoute private const val INTERESTS_GRAPH_ROUTE_PATTERN = "interests_graph" -const val interestsRoute = "interests_route" +const val INTERESTS_ROUTE = "interests_route" fun NavController.navigateToInterestsGraph(navOptions: NavOptions? = null) { this.navigate(INTERESTS_GRAPH_ROUTE_PATTERN, navOptions) @@ -36,9 +36,9 @@ fun NavGraphBuilder.interestsGraph( ) { navigation( route = INTERESTS_GRAPH_ROUTE_PATTERN, - startDestination = interestsRoute, + startDestination = INTERESTS_ROUTE, ) { - composable(route = interestsRoute) { + composable(route = INTERESTS_ROUTE) { InterestsRoute(onTopicClick) } nestedGraphs() diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/navigation/SearchNavigation.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/navigation/SearchNavigation.kt index 42bf3f475..a449600b2 100644 --- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/navigation/SearchNavigation.kt +++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/navigation/SearchNavigation.kt @@ -22,10 +22,10 @@ import androidx.navigation.NavOptions import androidx.navigation.compose.composable import com.google.samples.apps.nowinandroid.feature.search.SearchRoute -const val searchRoute = "search_route" +const val SEARCH_ROUTE = "search_route" fun NavController.navigateToSearch(navOptions: NavOptions? = null) { - this.navigate(searchRoute, navOptions) + this.navigate(SEARCH_ROUTE, navOptions) } fun NavGraphBuilder.searchScreen( @@ -35,7 +35,7 @@ fun NavGraphBuilder.searchScreen( ) { // TODO: Handle back stack for each top-level destination. At the moment each top-level // destination may have own search screen's back stack. - composable(route = searchRoute) { + composable(route = SEARCH_ROUTE) { SearchRoute( onBackClick = onBackClick, onInterestsClick = onInterestsClick, diff --git a/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/navigation/TopicNavigation.kt b/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/navigation/TopicNavigation.kt index c29b57d47..8052f766e 100644 --- a/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/navigation/TopicNavigation.kt +++ b/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/navigation/TopicNavigation.kt @@ -31,11 +31,11 @@ import kotlin.text.Charsets.UTF_8 private val URL_CHARACTER_ENCODING = UTF_8.name() @VisibleForTesting -internal const val topicIdArg = "topicId" +internal const val TOPIC_ID_ARG = "topicId" internal class TopicArgs(val topicId: String) { constructor(savedStateHandle: SavedStateHandle) : - this(URLDecoder.decode(checkNotNull(savedStateHandle[topicIdArg]), URL_CHARACTER_ENCODING)) + this(URLDecoder.decode(checkNotNull(savedStateHandle[TOPIC_ID_ARG]), URL_CHARACTER_ENCODING)) } fun NavController.navigateToTopic(topicId: String) { @@ -50,9 +50,9 @@ fun NavGraphBuilder.topicScreen( onTopicClick: (String) -> Unit, ) { composable( - route = "topic_route/{$topicIdArg}", + route = "topic_route/{$TOPIC_ID_ARG}", arguments = listOf( - navArgument(topicIdArg) { type = NavType.StringType }, + navArgument(TOPIC_ID_ARG) { type = NavType.StringType }, ), ) { TopicRoute(onBackClick = onBackClick, onTopicClick = onTopicClick) diff --git a/feature/topic/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt b/feature/topic/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt index 8c6253d60..a9c9d96dc 100644 --- a/feature/topic/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt +++ b/feature/topic/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt @@ -25,7 +25,7 @@ import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepo import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule -import com.google.samples.apps.nowinandroid.feature.topic.navigation.topicIdArg +import com.google.samples.apps.nowinandroid.feature.topic.navigation.TOPIC_ID_ARG import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.first @@ -60,7 +60,7 @@ class TopicViewModelTest { @Before fun setup() { viewModel = TopicViewModel( - savedStateHandle = SavedStateHandle(mapOf(topicIdArg to testInputTopics[0].topic.id)), + savedStateHandle = SavedStateHandle(mapOf(TOPIC_ID_ARG to testInputTopics[0].topic.id)), userDataRepository = userDataRepository, topicsRepository = topicsRepository, userNewsResourceRepository = userNewsResourceRepository, diff --git a/gradle/init.gradle.kts b/gradle/init.gradle.kts index f2e6114aa..fe79fa01e 100644 --- a/gradle/init.gradle.kts +++ b/gradle/init.gradle.kts @@ -38,7 +38,6 @@ rootProject { ktlint(ktlintVersion).editorConfigOverride( mapOf( "android" to "true", - "ktlint_standard_property-naming" to "disabled", ), ) licenseHeaderFile(rootProject.file("spotless/copyright.kt")) diff --git a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncInitializer.kt b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncInitializer.kt index 00f61f17d..0a631534b 100644 --- a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncInitializer.kt +++ b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncInitializer.kt @@ -28,7 +28,7 @@ object Sync { WorkManager.getInstance(context).apply { // Run sync on app startup and ensure only one sync worker runs at any time enqueueUniqueWork( - SyncWorkName, + SYNC_WORK_NAME, ExistingWorkPolicy.KEEP, SyncWorker.startUpSyncWork(), ) @@ -37,4 +37,4 @@ object Sync { } // This name should not be changed otherwise the app may have concurrent sync requests running -internal const val SyncWorkName = "SyncWorkName" +internal const val SYNC_WORK_NAME = "SyncWorkName" diff --git a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/status/WorkManagerSyncManager.kt b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/status/WorkManagerSyncManager.kt index 9131e4888..1d251588e 100644 --- a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/status/WorkManagerSyncManager.kt +++ b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/status/WorkManagerSyncManager.kt @@ -22,7 +22,7 @@ import androidx.work.WorkInfo import androidx.work.WorkInfo.State import androidx.work.WorkManager import com.google.samples.apps.nowinandroid.core.data.util.SyncManager -import com.google.samples.apps.nowinandroid.sync.initializers.SyncWorkName +import com.google.samples.apps.nowinandroid.sync.initializers.SYNC_WORK_NAME import com.google.samples.apps.nowinandroid.sync.workers.SyncWorker import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.flow.Flow @@ -37,7 +37,7 @@ class WorkManagerSyncManager @Inject constructor( @ApplicationContext private val context: Context, ) : SyncManager { override val isSyncing: Flow = - WorkManager.getInstance(context).getWorkInfosForUniqueWorkFlow(SyncWorkName) + WorkManager.getInstance(context).getWorkInfosForUniqueWorkFlow(SYNC_WORK_NAME) .map(List::anyRunning) .conflate() @@ -45,7 +45,7 @@ class WorkManagerSyncManager @Inject constructor( val workManager = WorkManager.getInstance(context) // Run sync on app startup and ensure only one sync worker runs at any time workManager.enqueueUniqueWork( - SyncWorkName, + SYNC_WORK_NAME, ExistingWorkPolicy.KEEP, SyncWorker.startUpSyncWork(), ) From 2a2d8ed88df563e22e82b0b53efa351850f3c629 Mon Sep 17 00:00:00 2001 From: lihenggui Date: Tue, 19 Dec 2023 10:17:42 -0800 Subject: [PATCH 6/9] Change the name of FOR_YOU_NAVIGATION_ROUTE to FOR_YOU_ROUTE --- .../samples/apps/nowinandroid/navigation/NiaNavHost.kt | 4 ++-- .../com/google/samples/apps/nowinandroid/ui/NiaAppState.kt | 4 ++-- .../feature/foryou/navigation/ForYouNavigation.kt | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt index 70651ed12..6167b0b59 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/navigation/NiaNavHost.kt @@ -20,7 +20,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.navigation.compose.NavHost import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.bookmarksScreen -import com.google.samples.apps.nowinandroid.feature.foryou.navigation.FOR_YOU_NAVIGATION_ROUTE +import com.google.samples.apps.nowinandroid.feature.foryou.navigation.FOR_YOU_ROUTE import com.google.samples.apps.nowinandroid.feature.foryou.navigation.forYouScreen import com.google.samples.apps.nowinandroid.feature.interests.navigation.interestsGraph import com.google.samples.apps.nowinandroid.feature.search.navigation.searchScreen @@ -41,7 +41,7 @@ fun NiaNavHost( appState: NiaAppState, onShowSnackbar: suspend (String, String?) -> Boolean, modifier: Modifier = Modifier, - startDestination: String = FOR_YOU_NAVIGATION_ROUTE, + startDestination: String = FOR_YOU_ROUTE, ) { val navController = appState.navController NavHost( diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt index 9c587cc5c..b99eab245 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt @@ -35,7 +35,7 @@ import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor import com.google.samples.apps.nowinandroid.core.ui.TrackDisposableJank import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.BOOKMARKS_ROUTE import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.navigateToBookmarks -import com.google.samples.apps.nowinandroid.feature.foryou.navigation.FOR_YOU_NAVIGATION_ROUTE +import com.google.samples.apps.nowinandroid.feature.foryou.navigation.FOR_YOU_ROUTE import com.google.samples.apps.nowinandroid.feature.foryou.navigation.navigateToForYou import com.google.samples.apps.nowinandroid.feature.interests.navigation.INTERESTS_ROUTE import com.google.samples.apps.nowinandroid.feature.interests.navigation.navigateToInterestsGraph @@ -91,7 +91,7 @@ class NiaAppState( val currentTopLevelDestination: TopLevelDestination? @Composable get() = when (currentDestination?.route) { - FOR_YOU_NAVIGATION_ROUTE -> FOR_YOU + FOR_YOU_ROUTE -> FOR_YOU BOOKMARKS_ROUTE -> BOOKMARKS INTERESTS_ROUTE -> INTERESTS else -> null diff --git a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/navigation/ForYouNavigation.kt b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/navigation/ForYouNavigation.kt index 264345be4..154b0f83b 100644 --- a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/navigation/ForYouNavigation.kt +++ b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/navigation/ForYouNavigation.kt @@ -26,17 +26,17 @@ import androidx.navigation.navDeepLink import com.google.samples.apps.nowinandroid.feature.foryou.ForYouRoute const val LINKED_NEWS_RESOURCE_ID = "linkedNewsResourceId" -const val FOR_YOU_NAVIGATION_ROUTE = "for_you_route/{$LINKED_NEWS_RESOURCE_ID}" +const val FOR_YOU_ROUTE = "for_you_route/{$LINKED_NEWS_RESOURCE_ID}" private const val DEEP_LINK_URI_PATTERN = "https://www.nowinandroid.apps.samples.google.com/foryou/{$LINKED_NEWS_RESOURCE_ID}" fun NavController.navigateToForYou(navOptions: NavOptions? = null) { - this.navigate(FOR_YOU_NAVIGATION_ROUTE, navOptions) + this.navigate(FOR_YOU_ROUTE, navOptions) } fun NavGraphBuilder.forYouScreen(onTopicClick: (String) -> Unit) { composable( - route = FOR_YOU_NAVIGATION_ROUTE, + route = FOR_YOU_ROUTE, deepLinks = listOf( navDeepLink { uriPattern = DEEP_LINK_URI_PATTERN }, ), From d671126f9eb5532206db2c7260e3cc06a978dd77 Mon Sep 17 00:00:00 2001 From: lihenggui Date: Tue, 19 Dec 2023 11:15:18 -0800 Subject: [PATCH 7/9] Move @Suppress("ktlint:standard:max-line-length") to function scope --- .../fake/FakeNiaNetworkDataSourceTest.kt | 78 +++++++++---------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/core/network/src/test/kotlin/com/google/samples/apps/nowinandroid/core/network/fake/FakeNiaNetworkDataSourceTest.kt b/core/network/src/test/kotlin/com/google/samples/apps/nowinandroid/core/network/fake/FakeNiaNetworkDataSourceTest.kt index 147252cf1..a0c60fdcb 100644 --- a/core/network/src/test/kotlin/com/google/samples/apps/nowinandroid/core/network/fake/FakeNiaNetworkDataSourceTest.kt +++ b/core/network/src/test/kotlin/com/google/samples/apps/nowinandroid/core/network/fake/FakeNiaNetworkDataSourceTest.kt @@ -44,47 +44,45 @@ class FakeNiaNetworkDataSourceTest { ) } + @Suppress("ktlint:standard:max-line-length") @Test - fun testDeserializationOfTopics() = - @Suppress("ktlint:standard:max-line-length") - runTest(testDispatcher) { - assertEquals( - NetworkTopic( - id = "1", - name = "Headlines", - shortDescription = "News you'll definitely be interested in", - longDescription = "The latest events and announcements from the world of Android development.", - url = "", - imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f", - ), - subject.getTopics().first(), - ) - } + fun testDeserializationOfTopics() = runTest(testDispatcher) { + assertEquals( + NetworkTopic( + id = "1", + name = "Headlines", + shortDescription = "News you'll definitely be interested in", + longDescription = "The latest events and announcements from the world of Android development.", + url = "", + imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f", + ), + subject.getTopics().first(), + ) + } + @Suppress("ktlint:standard:max-line-length") @Test - fun testDeserializationOfNewsResources() = - @Suppress("ktlint:standard:max-line-length") - runTest(testDispatcher) { - assertEquals( - NetworkNewsResource( - id = "125", - title = "Android Basics with Compose", - content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. ", - url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html", - headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg", - publishDate = LocalDateTime( - year = 2022, - monthNumber = 5, - dayOfMonth = 4, - hour = 23, - minute = 0, - second = 0, - nanosecond = 0, - ).toInstant(TimeZone.UTC), - type = "Codelab", - topics = listOf("2", "3", "10"), - ), - subject.getNewsResources().find { it.id == "125" }, - ) - } + fun testDeserializationOfNewsResources() = runTest(testDispatcher) { + assertEquals( + NetworkNewsResource( + id = "125", + title = "Android Basics with Compose", + content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. ", + url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html", + headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg", + publishDate = LocalDateTime( + year = 2022, + monthNumber = 5, + dayOfMonth = 4, + hour = 23, + minute = 0, + second = 0, + nanosecond = 0, + ).toInstant(TimeZone.UTC), + type = "Codelab", + topics = listOf("2", "3", "10"), + ), + subject.getNewsResources().find { it.id == "125" }, + ) + } } From 485440b550c0a241e96fbe78e52632ed0ec94619 Mon Sep 17 00:00:00 2001 From: lihenggui Date: Tue, 19 Dec 2023 12:42:49 -0800 Subject: [PATCH 8/9] Suppress ktlint:standard:function-naming in ResultKtTest --- .../samples/apps/nowinandroid/core/result/ResultKtTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt b/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt index 512a1a2f2..08fed508c 100644 --- a/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt +++ b/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt @@ -24,8 +24,9 @@ import kotlin.test.assertEquals class ResultKtTest { + @Suppress("ktlint:standard:function-naming") @Test - fun result_catches_errors() = runTest { + fun Result_catches_errors() = runTest { flow { emit(1) throw Exception("Test Done") From 56fbe13b5abe497df8b32a262001a922f3f9921c Mon Sep 17 00:00:00 2001 From: lihenggui Date: Tue, 19 Dec 2023 14:16:13 -0800 Subject: [PATCH 9/9] Ignore function naming check when annotated with @Test --- .editorconfig | 2 +- .../samples/apps/nowinandroid/core/result/ResultKtTest.kt | 1 - .../core/datastore/IntToStringIdsMigrationTest.kt | 4 ++-- .../nowinandroid/core/datastore/ListToMapMigrationTest.kt | 6 +++--- .../nowinandroid/core/designsystem/TagScreenshotTests.kt | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2d5a46b3c..7be3f8784 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,4 +4,4 @@ [*.{kt,kts}] ij_kotlin_allow_trailing_comma=true ij_kotlin_allow_trailing_comma_on_call_site=true -ktlint_function_naming_ignore_when_annotated_with=Composable +ktlint_function_naming_ignore_when_annotated_with=Composable, Test diff --git a/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt b/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt index 08fed508c..4f1229e9d 100644 --- a/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt +++ b/core/common/src/test/kotlin/com/google/samples/apps/nowinandroid/core/result/ResultKtTest.kt @@ -24,7 +24,6 @@ import kotlin.test.assertEquals class ResultKtTest { - @Suppress("ktlint:standard:function-naming") @Test fun Result_catches_errors() = runTest { flow { diff --git a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/IntToStringIdsMigrationTest.kt b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/IntToStringIdsMigrationTest.kt index 392ca2550..8b97cff34 100644 --- a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/IntToStringIdsMigrationTest.kt +++ b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/IntToStringIdsMigrationTest.kt @@ -27,7 +27,7 @@ import kotlin.test.assertTrue class IntToStringIdsMigrationTest { @Test - fun intToStringIdsMigration_should_migrate_topic_ids() = runTest { + fun IntToStringIdsMigration_should_migrate_topic_ids() = runTest { // Set up existing preferences with topic int ids val preMigrationUserPreferences = userPreferences { deprecatedIntFollowedTopicIds.addAll(listOf(1, 2, 3)) @@ -56,7 +56,7 @@ class IntToStringIdsMigrationTest { } @Test - fun intToStringIdsMigration_should_migrate_author_ids() = runTest { + fun IntToStringIdsMigration_should_migrate_author_ids() = runTest { // Set up existing preferences with author int ids val preMigrationUserPreferences = userPreferences { deprecatedIntFollowedAuthorIds.addAll(listOf(4, 5, 6)) diff --git a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ListToMapMigrationTest.kt b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ListToMapMigrationTest.kt index 41404d6a9..f7e083b45 100644 --- a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ListToMapMigrationTest.kt +++ b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ListToMapMigrationTest.kt @@ -24,7 +24,7 @@ import kotlin.test.assertTrue class ListToMapMigrationTest { @Test - fun listToMapMigration_should_migrate_topic_ids() = runTest { + fun ListToMapMigration_should_migrate_topic_ids() = runTest { // Set up existing preferences with topic ids val preMigrationUserPreferences = userPreferences { deprecatedFollowedTopicIds.addAll(listOf("1", "2", "3")) @@ -50,7 +50,7 @@ class ListToMapMigrationTest { } @Test - fun listToMapMigration_should_migrate_author_ids() = runTest { + fun ListToMapMigration_should_migrate_author_ids() = runTest { // Set up existing preferences with author ids val preMigrationUserPreferences = userPreferences { deprecatedFollowedAuthorIds.addAll(listOf("4", "5", "6")) @@ -76,7 +76,7 @@ class ListToMapMigrationTest { } @Test - fun listToMapMigration_should_migrate_bookmarks() = runTest { + fun ListToMapMigration_should_migrate_bookmarks() = runTest { // Set up existing preferences with bookmarks val preMigrationUserPreferences = userPreferences { deprecatedBookmarkedNewsResourceIds.addAll(listOf("7", "8", "9")) diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt index 16ed71aeb..d9edfd6c6 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt @@ -47,7 +47,7 @@ class TagScreenshotTests() { val composeTestRule = createAndroidComposeRule() @Test - fun tag_multipleThemes() { + fun Tag_multipleThemes() { composeTestRule.captureMultiTheme("Tag") { NiaTopicTag(followed = true, onClick = {}) { Text("TOPIC")