Skip to content

Commit

Permalink
Suppress konsist TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-mullvad committed Oct 2, 2023
1 parent cc230f6 commit 8af8d3c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class AccountViewModel(
}
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), AccountUiState.default())

@Suppress("konsist.ensurePublicPropertiesUsePermittedNames")
val enterTransitionEndAction = _enterTransitionEndAction.asSharedFlow()

fun onManageAccountClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class DeviceListViewModel(
private val _loadingDevices = MutableStateFlow<List<DeviceId>>(emptyList())

private val _toastMessages = MutableSharedFlow<String>(extraBufferCapacity = 1)
@Suppress("konsist.ensurePublicPropertiesUsePermittedNames")
val toastMessages = _toastMessages.asSharedFlow()

var accountToken: String? = null
@Suppress("konsist.ensurePublicPropertiesUsePermittedNames") var accountToken: String? = null
private var cachedDeviceList: List<Device>? = null

val uiState =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class SelectLocationViewModel(private val serviceConnectionManager: ServiceConne
SelectLocationUiState.Loading
)

@Suppress("konsist.ensurePublicPropertiesUsePermittedNames")
val uiCloseAction = _closeAction.asSharedFlow()
@Suppress("konsist.ensurePublicPropertiesUsePermittedNames")
val enterTransitionEndAction = _enterTransitionEndAction.asSharedFlow()

fun selectRelay(relayItem: RelayItem?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SettingsViewModel(
SettingsUiState(appVersion = "", isLoggedIn = false, isUpdateAvailable = false)
)

@Suppress("konsist.ensurePublicPropertiesUsePermittedNames")
val enterTransitionEndAction = _enterTransitionEndAction.asSharedFlow()

fun onTransitionAnimationEnd() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class VpnSettingsViewModel(
) : ViewModel() {

private val _toastMessages = MutableSharedFlow<String>(extraBufferCapacity = 1)
@Suppress("konsist.ensurePublicPropertiesUsePermittedNames")
val toastMessages = _toastMessages.asSharedFlow()

private val dialogState =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class ViewModelTests {
// properties that shouldn't be exposed.
@Test
fun ensurePublicPropertiesUsePermittedNames() {
allViewModels().properties().withPublicOrDefaultModifier().assert { property ->
permittedPublicPropertyNames.contains(property.name)
allViewModels().properties(includeNested = false).withPublicOrDefaultModifier().assert {
property ->
property.name == "uiState" || property.name == "uiSideEffect"
}
}

Expand All @@ -34,17 +35,4 @@ class ViewModelTests {

private fun allViewModels() =
Konsist.scopeFromProject().classes().withAllParentsOf(ViewModel::class)

companion object {
// TODO: The goal is to reduce this list to only "uiState" and "uiSideEffect".
private val permittedPublicPropertyNames =
listOf(
"uiState",
"uiSideEffect",
"toastMessages",
"uiCloseAction",
"enterTransitionEndAction",
"accountToken"
)
}
}

0 comments on commit 8af8d3c

Please sign in to comment.