Skip to content

Commit

Permalink
Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0 (#3564)
Browse files Browse the repository at this point in the history
* Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0

* ktlint fixes

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Frett <[email protected]>
  • Loading branch information
renovate[bot] and frett authored Jun 10, 2024
1 parent f0d6259 commit 4f581a2
Show file tree
Hide file tree
Showing 57 changed files with 158 additions and 185 deletions.
2 changes: 0 additions & 2 deletions app/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<baseline version="1.0">
<file name="src/main/kotlin/org/cru/godtools/ui/account/AccountLayout.kt">
<error line="61" column="9" source="compose:vm-injection-check" />
<error line="103" column="12" source="compose:unstable-collections" />
</file>
<file name="src/main/kotlin/org/cru/godtools/ui/account/globalactivity/GlobalActivityLayout.kt">
<error line="33" column="5" source="compose:modifier-missing-check" />
Expand All @@ -18,7 +17,6 @@
</file>
<file name="src/main/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsLayout.kt">
<error line="40" column="9" source="compose:vm-injection-check" />
<error line="111" column="34" source="compose:unstable-collections" />
</file>
<file name="src/main/kotlin/org/cru/godtools/ui/languages/downloadable/DownloadableLanguagesLayout.kt">
<error line="59" column="5" source="compose:modifier-missing-check" />
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/kotlin/org/cru/godtools/GodToolsApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import org.ccci.gto.android.common.util.LocaleUtils
import timber.log.Timber

@HiltAndroidApp
open class GodToolsApplication : Application(), Configuration.Provider {
open class GodToolsApplication :
Application(),
Configuration.Provider {
@Inject
internal lateinit var eagerInitializer: EagerSingletonInitializer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import android.os.Bundle
private const val PARAM_SOURCE = "cru_source"
private const val PARAM_TOOL = "cru_tool"

internal class OpenAnalyticsActionEvent(
action: String,
private val tool: String?,
private val source: String
) : AnalyticsActionEvent(action = action, system = AnalyticsSystem.FIREBASE) {
internal class OpenAnalyticsActionEvent(action: String, private val tool: String?, private val source: String) :
AnalyticsActionEvent(action = action, system = AnalyticsSystem.FIREBASE) {
companion object {
const val ACTION_OPEN_LESSON = "open_lesson"
const val ACTION_OPEN_TOOL = "open_tool"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import org.cru.godtools.shared.user.activity.model.UserActivity
import org.cru.godtools.user.activity.UserActivityManager

@HiltViewModel
class AccountActivityViewModel @Inject constructor(
userActivityManager: UserActivityManager,
) : ViewModel() {
class AccountActivityViewModel @Inject constructor(userActivityManager: UserActivityManager) : ViewModel() {
val userActivity = userActivityManager.userActivityFlow
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), UserActivity(emptyMap()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import org.cru.godtools.db.repository.GlobalActivityRepository
import org.cru.godtools.model.GlobalActivityAnalytics

@HiltViewModel
class GlobalActivityViewModel @Inject constructor(
globalActivityRepository: GlobalActivityRepository
) : ViewModel() {
class GlobalActivityViewModel @Inject constructor(globalActivityRepository: GlobalActivityRepository) : ViewModel() {
val activity = globalActivityRepository.getGlobalActivityFlow()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), GlobalActivityAnalytics())
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import org.cru.godtools.base.ui.dashboard.Page
internal fun Uri.isDashboardLessonsDeepLink() =
(scheme == "http" || scheme == "https") && host.equals(HOST_GODTOOLSAPP_COM, true) && path == "/lessons"

internal fun Uri.isDashboardGodToolsDeepLink() =
(scheme == "http" || scheme == "https") && host.equals(HOST_GODTOOLSAPP_COM, true) &&
pathSegments[0] == "deeplink" && pathSegments[1] == "dashboard"
internal fun Uri.isDashboardGodToolsDeepLink() = (scheme == "http" || scheme == "https") &&
host.equals(HOST_GODTOOLSAPP_COM, true) &&
pathSegments[0] == "deeplink" &&
pathSegments[1] == "dashboard"

internal fun Uri.isDashboardCustomUriSchemeDeepLink() = SCHEME_GODTOOLS.equals(scheme, true) &&
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,8 @@ import org.cru.godtools.ui.tooldetails.ToolDetailsScreen
import org.cru.godtools.ui.tools.ToolCardEvent

internal sealed interface DashboardEvent {
open class OpenTool(
val tool: String?,
val type: Tool.Type?,
val lang1: Locale?,
val lang2: Locale? = null,
) : DashboardEvent
open class OpenTool(val tool: String?, val type: Tool.Type?, val lang1: Locale?, val lang2: Locale? = null) :
DashboardEvent
class OpenLesson(lesson: String?, lang: Locale?) : OpenTool(lesson, Tool.Type.LESSON, lang)
class OpenToolDetails(val tool: String?, val lang: Locale? = null) : DashboardEvent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ import org.cru.godtools.ui.tools.ToolCardEvent
private val PADDING_HORIZONTAL = 16.dp

internal sealed interface DashboardHomeEvent {
open class OpenTool(
val tool: String?,
val type: Tool.Type?,
val lang1: Locale?,
val lang2: Locale? = null,
) : DashboardHomeEvent {
open class OpenTool(val tool: String?, val type: Tool.Type?, val lang1: Locale?, val lang2: Locale? = null) :
DashboardHomeEvent {
constructor(event: ToolCardEvent) : this(event.tool, event.toolType, event.lang1, event.lang2)
}
open class OpenToolDetails(val tool: String?) : DashboardHomeEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import org.cru.godtools.db.repository.ToolsRepository
import org.greenrobot.eventbus.EventBus

@HiltViewModel
class LessonsViewModel @Inject constructor(
private val eventBus: EventBus,
toolsRepository: ToolsRepository,
) : ViewModel() {
class LessonsViewModel @Inject constructor(private val eventBus: EventBus, toolsRepository: ToolsRepository) :
ViewModel() {
val lessons = toolsRepository.getLessonsFlow()
.map { it.filterNot { it.isHidden }.sortedBy { it.defaultOrder }.mapNotNull { it.code } }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), emptyList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import org.cru.godtools.ui.drawer.DrawerMenuScreen.Event
import org.cru.godtools.ui.drawer.DrawerMenuScreen.State

@Singleton
class DrawerMenuPresenter @Inject constructor(
private val accountManager: GodToolsAccountManager,
) : Presenter<State> {
class DrawerMenuPresenter @Inject constructor(private val accountManager: GodToolsAccountManager) : Presenter<State> {
@Composable
override fun present(): State {
val scope = rememberCoroutineScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import kotlinx.coroutines.withContext
import org.cru.godtools.account.GodToolsAccountManager

@HiltViewModel
class DrawerViewModel @Inject constructor(
private val accountManager: GodToolsAccountManager,
) : ViewModel() {
class DrawerViewModel @Inject constructor(private val accountManager: GodToolsAccountManager) : ViewModel() {
val isAuthenticatedFlow = accountManager.isAuthenticatedFlow
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import org.cru.godtools.ui.BasePaparazziTest
import org.junit.runner.RunWith

@RunWith(TestParameterInjector::class)
class AccountActivityBadgesPaparazziTest(
@TestParameter nightMode: NightMode,
) : BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
class AccountActivityBadgesPaparazziTest(@TestParameter nightMode: NightMode) :
BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
@Test
fun `AccountActivityBadges() - All Incomplete`() {
val activity = UserActivity(emptyMap())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import org.cru.godtools.ui.BasePaparazziTest
import org.junit.runner.RunWith

@RunWith(TestParameterInjector::class)
class LanguageDownloadStatusIndicatorPaparazziTest(
@TestParameter nightMode: NightMode
) : BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
class LanguageDownloadStatusIndicatorPaparazziTest(@TestParameter nightMode: NightMode) :
BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
@Test
fun `LanguageDownloadStatusIndicator()`() = centerInSnapshot {
Row {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ kotlin = "1.9.24"
kotlinCoroutines = "1.8.1"
kotlinKover = "0.7.6"
ksp = "1.9.24-1.0.20"
ktlint = "1.2.1"
ktlint = "1.3.0"
ktlintGradle = "12.1.1"
lottie = "6.4.1"
okhttp3 = "4.12.0"
Expand Down
2 changes: 1 addition & 1 deletion library/account/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="src/main/kotlin/org/cru/godtools/account/compose/LocalGodToolsAccountManager.kt">
<error line="14" column="17" source="compose:compositionlocal-allowlist" />
<error line="13" column="17" source="compose:compositionlocal-allowlist" />
</file>
</baseline>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.cru.godtools.account.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.ProvidedValue
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.platform.LocalContext
import dagger.hilt.EntryPoint
Expand All @@ -24,9 +23,7 @@ internal object LocalGodToolsAccountManager {
/**
* Associates a [GodToolsAccountManager] key to a value in a call to [CompositionLocalProvider].
*/
infix fun provides(accountManager: GodToolsAccountManager): ProvidedValue<GodToolsAccountManager?> {
return LocalComposition.provides(accountManager)
}
infix fun provides(accountManager: GodToolsAccountManager) = LocalComposition.provides(accountManager)
}

@EntryPoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.cru.godtools.account.provider.google

class GoogleBuildConfig(
val serverClientId: String
)
class GoogleBuildConfig(val serverClientId: String)
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import java.util.Locale
private const val ACTION_EXIT_LINK = "exit_link_engaged"
private const val FIREBASE_PARAM_EXIT_LINK = "cru_mobileexitlink"

class ExitLinkActionEvent(
private val tool: String?,
private val link: String,
locale: Locale? = null
) : AnalyticsActionEvent(ACTION_EXIT_LINK, locale = locale) {
class ExitLinkActionEvent(private val tool: String?, private val link: String, locale: Locale? = null) :
AnalyticsActionEvent(ACTION_EXIT_LINK, locale = locale) {
constructor(tool: String?, link: Uri, locale: Locale? = null) : this(tool, link.toString(), locale)

override fun isForSystem(system: AnalyticsSystem) = system == AnalyticsSystem.FIREBASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ package org.cru.godtools.api.model
import org.ccci.gto.android.common.jsonapi.annotation.JsonApiType

@JsonApiType("publisher-info")
class PublisherInfo(
var subscriberChannelId: String? = null
)
class PublisherInfo(var subscriberChannelId: String? = null)
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import timber.log.Timber

fun Locale.getPrimaryCollator(): Collator = Collator.getInstance(this).also { it.strength = Collator.PRIMARY }

fun Locale.getDisplayName(context: Context? = null, defaultName: String? = null, inLocale: Locale? = null): String {
return getLanguageNameStringRes(context, inLocale)
fun Locale.getDisplayName(context: Context? = null, defaultName: String? = null, inLocale: Locale? = null) =
getLanguageNameStringRes(context, inLocale)
// use Locale.getDisplayName()
?: getOptionalDisplayName(inLocale)
// use the default name if specified
Expand All @@ -24,7 +24,6 @@ fun Locale.getDisplayName(context: Context? = null, defaultName: String? = null,
.e(e, "Locale(%s).getDisplayName(defaultName = %s, inLocale = %s)", this, defaultName, inLocale)
if (inLocale != null) getDisplayName(inLocale) else displayName
}
}

private fun Locale.getLanguageNameStringRes(context: Context?, inLocale: Locale?) = when (toLanguageTag()) {
"fa" -> context?.getLocalizedString(inLocale, R.string.language_name_fa)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
package org.cru.godtools.db.room.entity.partial

internal class MigrationUserCounter(
val name: String,
val count: Int,
val decayedCount: Double
)
internal class MigrationUserCounter(val name: String, val count: Int, val decayedCount: Double)
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ package org.cru.godtools.db.room.entity.partial

import org.cru.godtools.model.UserCounter

internal class SyncUserCounter(
val name: String,
val count: Int,
val decayedCount: Double
) {
internal class SyncUserCounter(val name: String, val count: Int, val decayedCount: Double) {
constructor(counter: UserCounter) : this(counter.id, counter.apiCount, counter.apiDecayedCount)
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ private const val DATABASE_VERSION = 63
* 63: 2024-01-17
*/

internal class GodToolsDatabase(
private val context: Context,
private val roomDb: GodToolsRoomDatabase,
) : WalSQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
internal class GodToolsDatabase(private val context: Context, private val roomDb: GodToolsRoomDatabase) :
WalSQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
override fun onCreate(db: SQLiteDatabase) = Unit

override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
Expand Down
6 changes: 4 additions & 2 deletions library/model/src/main/kotlin/org/cru/godtools/model/Tool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ class Tool(
@Suppress("SENSELESS_COMPARISON")
val isValid
get() = !code.isNullOrEmpty() &&
type != null && type != Type.UNKNOWN &&
apiId != null && apiId != INVALID_ID
type != null &&
type != Type.UNKNOWN &&
apiId != null &&
apiId != INVALID_ID
val totalShares get() = pendingShares + shares

override fun equals(other: Any?) = when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@ package org.cru.godtools.model

import java.util.Locale

data class TrainingTip(
val tool: String,
val locale: Locale,
val tipId: String,
val isCompleted: Boolean
)
data class TrainingTip(val tool: String, val locale: Locale, val tipId: String, val isCompleted: Boolean)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.cru.godtools.db.repository.GlobalActivityRepository
import org.cru.godtools.db.repository.LastSyncTimeRepository

private const val SYNC_TIME_GLOBAL_ACTIVITY = "last_synced.global_activity"
private const val STALE_DURATION_GLOBAL_ACTIVITY = DAY_IN_MS
private const val STALE_GLOBAL_ACTIVITY = DAY_IN_MS

@Singleton
internal class AnalyticsSyncTasks @Inject internal constructor(
Expand All @@ -22,8 +22,8 @@ internal class AnalyticsSyncTasks @Inject internal constructor(

suspend fun syncGlobalActivity(force: Boolean): Boolean = globalActivityMutex.withLock {
// short-circuit if we aren't forcing a sync and the data isn't stale
if (!force && !lastSyncTimeRepository
.isLastSyncStale(SYNC_TIME_GLOBAL_ACTIVITY, staleAfter = STALE_DURATION_GLOBAL_ACTIVITY)
if (!force &&
!lastSyncTimeRepository.isLastSyncStale(SYNC_TIME_GLOBAL_ACTIVITY, staleAfter = STALE_GLOBAL_ACTIVITY)
) {
return@withLock true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class Resource(@field:PrimaryKey val uri: Uri) {
/**
* @return true if this resource needs to be downloaded
*/
fun needsDownload(): Boolean {
return localFileName == null || dateDownloaded == null
}
fun needsDownload() = localFileName == null || dateDownloaded == null

suspend fun getLocalFile(fs: FileSystem) = localFileName?.let { fs.file(it) }
suspend fun getInputStream(fs: FileSystem) = getLocalFile(fs)?.inputStream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ class ArticlesActivity :
}

private fun Uri.isGodToolsDeepLink() = (scheme == "http" || scheme == "https") &&
HOST_GODTOOLSAPP_COM.equals(host, true) && pathSegments.orEmpty().size >= 5 &&
HOST_GODTOOLSAPP_COM.equals(host, true) &&
pathSegments.orEmpty().size >= 5 &&
pathSegments?.getOrNull(0) == "deeplink" &&
pathSegments?.getOrNull(1) == "tool" && pathSegments?.getOrNull(2) == "article"
pathSegments?.getOrNull(1) == "tool" &&
pathSegments?.getOrNull(2) == "article"

private fun Uri.isCustomUriDeepLink() = scheme == SCHEME_GODTOOLS &&
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) && pathSegments.orEmpty().size >= 4 &&
pathSegments?.getOrNull(0) == "tool" && pathSegments?.getOrNull(1) == "article"
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) &&
pathSegments.orEmpty().size >= 4 &&
pathSegments?.getOrNull(0) == "tool" &&
pathSegments?.getOrNull(1) == "article"
// endregion Intent Processing

private fun updateToolbarTitle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import org.cru.godtools.article.aem.model.Article
import org.cru.godtools.shared.tool.parser.model.Manifest
import org.cru.godtools.tool.article.databinding.ListItemArticleBinding

class ArticlesAdapter(
lifecycleOwner: LifecycleOwner?,
private val manifest: LiveData<Manifest?>
) : SimpleDataBindingAdapter<ListItemArticleBinding>(lifecycleOwner), Observer<List<Article>?> {
class ArticlesAdapter(lifecycleOwner: LifecycleOwner?, private val manifest: LiveData<Manifest?>) :
SimpleDataBindingAdapter<ListItemArticleBinding>(lifecycleOwner),
Observer<List<Article>?> {
interface Callbacks {
fun onArticleSelected(article: Article?)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import org.greenrobot.eventbus.EventBus
import splitties.fragmentargs.argOrNull

@AndroidEntryPoint
class ArticlesFragment : BaseToolFragment<FragmentArticlesBinding>, ArticlesAdapter.Callbacks {
class ArticlesFragment :
BaseToolFragment<FragmentArticlesBinding>,
ArticlesAdapter.Callbacks {
constructor() : super(R.layout.fragment_articles)
constructor(
code: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import org.cru.godtools.shared.tool.parser.model.Category
import org.cru.godtools.tool.article.databinding.ListItemCategoryBinding

internal class CategoriesAdapter(lifecycleOwner: LifecycleOwner? = null) :
SimpleDataBindingAdapter<ListItemCategoryBinding>(lifecycleOwner), Observer<List<Category>?> {
SimpleDataBindingAdapter<ListItemCategoryBinding>(lifecycleOwner),
Observer<List<Category>?> {
init {
setHasStableIds(true)
}
Expand Down
Loading

0 comments on commit 4f581a2

Please sign in to comment.