Skip to content

Commit

Permalink
Merge pull request #149 from hoc081098/deps
Browse files Browse the repository at this point in the history
deps: kotlin 1.7, ktlint 0.45.2, spotless 6.7.2
  • Loading branch information
hoc081098 authored Jun 20, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 6f16e8e + 7b76a1c commit 3a8bbd8
Showing 26 changed files with 103 additions and 96 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/hoc/flowmvi/App.kt
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@ import com.hoc.flowmvi.domain.domainModule
import com.hoc.flowmvi.ui.add.addModule
import com.hoc.flowmvi.ui.main.mainModule
import com.hoc.flowmvi.ui.search.searchModule
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import org.koin.core.logger.Level
import timber.log.Timber
import kotlin.time.ExperimentalTime

@FlowPreview
@ExperimentalCoroutinesApi
6 changes: 3 additions & 3 deletions app/src/test/java/com/hoc/flowmvi/CheckModulesTest.kt
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ import androidx.lifecycle.SavedStateHandle
import com.hoc.flowmvi.test_utils.TestCoroutineDispatcherRule
import io.mockk.every
import io.mockk.mockk
import kotlin.test.Test
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import org.junit.Rule
@@ -12,8 +14,6 @@ import org.koin.dsl.koinApplication
import org.koin.test.AutoCloseKoinTest
import org.koin.test.check.checkModules
import org.koin.test.mock.MockProviderRule
import kotlin.test.Test
import kotlin.time.ExperimentalTime

@ExperimentalStdlibApi
@FlowPreview
@@ -24,7 +24,7 @@ class CheckModulesTest : AutoCloseKoinTest() {
val mockProvider = MockProviderRule.create { clazz ->
when (clazz) {
SavedStateHandle::class -> {
mockk<SavedStateHandle>() {
mockk<SavedStateHandle> {
every { get<Any?>(any()) } returns null
}
}
51 changes: 33 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ buildscript {
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.7.1")
classpath("com.diffplug.spotless:spotless-plugin-gradle:6.7.2")
classpath("dev.ahmedmourad.nocopy:nocopy-gradle-plugin:1.4.0")
classpath("org.jacoco:org.jacoco.core:0.8.8")
classpath("com.vanniktech:gradle-android-junit-jacoco-plugin:0.17.0-SNAPSHOT")
@@ -29,19 +29,34 @@ subprojects {
apply(plugin = "com.github.ben-manes.versions")

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
val EDITOR_CONFIG_KEYS: Set<String> = hashSetOf(
"ij_kotlin_imports_layout",
"indent_size",
"end_of_line",
"charset"
)

kotlin {
target("**/*.kt")

ktlint(ktlintVersion).userData(
// TODO this should all come from editorconfig https://github.com/diffplug/spotless/issues/142
mapOf(
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8"
)
// TODO this should all come from editorconfig https://github.com/diffplug/spotless/issues/142
val data = mapOf(
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8",
"disabled_rules" to arrayOf(
"experimental:package-name",
"experimental:trailing-comma",
"experimental:type-parameter-list-spacing",
).joinToString(separator = ","),
)

ktlint(ktlintVersion)
.setUseExperimental(true)
.userData(data.filterKeys { it !in EDITOR_CONFIG_KEYS })
.editorConfigOverride(data.filterKeys { it in EDITOR_CONFIG_KEYS })

trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
@@ -58,14 +73,16 @@ subprojects {
kotlinGradle {
target("**/*.gradle.kts", "*.gradle.kts")

ktlint(ktlintVersion).userData(
mapOf(
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8"
)
val data = mapOf(
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8"
)
ktlint(ktlintVersion)
.setUseExperimental(true)
.userData(data.filterKeys { it !in EDITOR_CONFIG_KEYS })
.editorConfigOverride(data.filterKeys { it in EDITOR_CONFIG_KEYS })

trimTrailingWhitespace()
indentWithSpaces()
@@ -114,8 +131,6 @@ allprojects {
kotlinOptions {
val version = JavaVersion.VERSION_11.toString()
jvmTarget = version
sourceCompatibility = version
targetCompatibility = version
}
}

4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/deps.kt
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ import org.gradle.kotlin.dsl.project
import org.gradle.plugin.use.PluginDependenciesSpec
import org.gradle.plugin.use.PluginDependencySpec

const val ktlintVersion = "0.44.0"
const val kotlinVersion = "1.6.21"
const val ktlintVersion = "0.45.2"
const val kotlinVersion = "1.7.0"

object appConfig {
const val applicationId = "com.hoc.flowmvi"
Original file line number Diff line number Diff line change
@@ -8,13 +8,13 @@ import androidx.appcompat.widget.SearchView
import androidx.core.widget.doOnTextChanged
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.hoc081098.flowext.startWith
import kotlin.coroutines.EmptyCoroutineContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.take
import timber.log.Timber
import kotlin.coroutines.EmptyCoroutineContext

internal fun checkMainThread() {
check(Looper.myLooper() == Looper.getMainLooper()) {
4 changes: 2 additions & 2 deletions data/src/main/java/com/hoc/flowmvi/data/DataModule.kt
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ import com.hoc.flowmvi.domain.repository.UserRepository
import com.squareup.moshi.Moshi
import com.squareup.moshi.adapter
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import java.util.concurrent.TimeUnit
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import okhttp3.OkHttpClient
@@ -19,8 +21,6 @@ import org.koin.core.qualifier.named
import org.koin.dsl.module
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import java.util.concurrent.TimeUnit
import kotlin.time.ExperimentalTime

internal val BASE_URL_QUALIFIER = named("BASE_URL")
internal val ERROR_RESPONSE_JSON_ADAPTER = named("ERROR_RESPONSE_JSON_ADAPTER")
8 changes: 4 additions & 4 deletions data/src/main/java/com/hoc/flowmvi/data/UserRepositoryImpl.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hoc.flowmvi.data

import arrow.core.Either.Companion.catch as catchEither
import arrow.core.ValidatedNel
import arrow.core.continuations.either
import arrow.core.left
@@ -16,6 +17,9 @@ import com.hoc.flowmvi.domain.model.UserError
import com.hoc.flowmvi.domain.model.UserValidationError
import com.hoc.flowmvi.domain.repository.UserRepository
import com.hoc081098.flowext.retryWithExponentialBackoff
import java.io.IOException
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.Flow
@@ -29,10 +33,6 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.scan
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.io.IOException
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.ExperimentalTime
import arrow.core.Either.Companion.catch as catchEither

@FlowPreview
@ExperimentalTime
Original file line number Diff line number Diff line change
@@ -5,12 +5,12 @@ import com.hoc.flowmvi.core.Mapper
import com.hoc.flowmvi.data.remote.ErrorResponse
import com.hoc.flowmvi.domain.model.UserError
import com.squareup.moshi.JsonAdapter
import okhttp3.ResponseBody
import retrofit2.HttpException
import java.io.IOException
import java.net.SocketException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import okhttp3.ResponseBody
import retrofit2.HttpException

internal class UserErrorMapper(private val errorResponseJsonAdapter: JsonAdapter<ErrorResponse>) :
Mapper<Throwable, UserError> {
Original file line number Diff line number Diff line change
@@ -4,6 +4,11 @@ import android.util.Log
import com.hoc.flowmvi.core.dispatchers.AppCoroutineDispatchers
import com.hoc.flowmvi.domain.repository.UserRepository
import com.hoc.flowmvi.test_utils.getOrThrow
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlin.test.Test
import kotlin.test.assertTrue
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
@@ -20,11 +25,6 @@ import org.koin.test.KoinTest
import org.koin.test.KoinTestRule
import org.koin.test.inject
import timber.log.Timber
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlin.test.Test
import kotlin.test.assertTrue
import kotlin.time.ExperimentalTime

@FlowPreview
@ExperimentalCoroutinesApi
Original file line number Diff line number Diff line change
@@ -24,14 +24,6 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import io.mockk.verifySequence
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import java.io.IOException
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
@@ -42,6 +34,14 @@ import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import org.junit.Rule

private val USER_BODY = UserBody(
email = "[email protected]",
Original file line number Diff line number Diff line change
@@ -5,19 +5,19 @@ import com.hoc.flowmvi.domain.model.UserError
import com.squareup.moshi.Moshi
import com.squareup.moshi.adapter
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.ResponseBody.Companion.toResponseBody
import retrofit2.HttpException
import retrofit2.Response
import java.io.IOException
import java.net.SocketException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import kotlin.coroutines.cancellation.CancellationException as KotlinCancellationException
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.coroutines.cancellation.CancellationException as KotlinCancellationException
import kotlinx.coroutines.CancellationException as KotlinXCancellationException
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.ResponseBody.Companion.toResponseBody
import retrofit2.HttpException
import retrofit2.Response

@ExperimentalStdlibApi
class UserErrorMapperTest {
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@ import com.hoc.flowmvi.domain.model.Email
import com.hoc.flowmvi.domain.model.FirstName
import com.hoc.flowmvi.domain.model.LastName
import com.hoc.flowmvi.domain.model.UserValidationError
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import kotlinx.coroutines.ExperimentalCoroutinesApi

@ExperimentalCoroutinesApi
@Suppress("ClassName")
8 changes: 4 additions & 4 deletions domain/src/test/java/com/hoc/flowmvi/domain/UseCaseTest.kt
Original file line number Diff line number Diff line change
@@ -19,15 +19,15 @@ import io.mockk.confirmVerified
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals

private val USERS = listOf(
User.create(
4 changes: 2 additions & 2 deletions feature-add/src/test/java/com/hoc/flowmvi/ui/add/AddVMTest.kt
Original file line number Diff line number Diff line change
@@ -18,10 +18,10 @@ import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.confirmVerified
import io.mockk.mockk
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.flowOf
import kotlin.test.Test
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.flowOf

private val ALL_ERRORS = UserValidationError.values().toSet()
private const val EMAIL = "[email protected]"
14 changes: 6 additions & 8 deletions feature-main/src/test/java/com/hoc/flowmvi/ui/main/MainVMTest.kt
Original file line number Diff line number Diff line change
@@ -19,26 +19,24 @@ import io.mockk.confirmVerified
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.update
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.time.ExperimentalTime

@ExperimentalTime
@ExperimentalCoroutinesApi
@FlowPreview
class MainVMTest : BaseMviViewModelTest<
ViewIntent,
class MainVMTest : BaseMviViewModelTest<ViewIntent,
ViewState,
SingleEvent,
MainVM
>() {
MainVM>() {
private lateinit var vm: MainVM
private lateinit var getUserUseCase: GetUsersUseCase
private lateinit var refreshGetUsersUseCase: RefreshGetUsersUseCase
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ import com.hoc.flowmvi.domain.model.UserError
import com.hoc.flowmvi.mvi_base.AbstractMviActivity
import com.hoc.flowmvi.ui.search.databinding.ActivitySearchBinding
import com.hoc081098.viewbindingdelegate.viewBinding
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.channels.Channel
@@ -32,7 +33,6 @@ import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onEach
import org.koin.androidx.viewmodel.ext.android.stateViewModel
import timber.log.Timber
import kotlin.time.ExperimentalTime

@ExperimentalCoroutinesApi
@FlowPreview
Loading

0 comments on commit 3a8bbd8

Please sign in to comment.