Skip to content

Commit

Permalink
feat: TOP-62 data module lint 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
taewooyo committed Sep 15, 2023
1 parent acbf445 commit 5c0d499
Show file tree
Hide file tree
Showing 70 changed files with 311 additions and 276 deletions.
1 change: 1 addition & 0 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("org.jlleitschuh.gradle.ktlint")
id("com.google.gms.google-services")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import android.content.Context
import android.content.SharedPreferences
import androidx.test.core.app.ApplicationProvider.getApplicationContext
import com.google.gson.Gson
import com.tht.tht.data.local.dao.SignupUserDaoImpl
import com.tht.tht.data.local.datasource.SignupUserDataSource
import com.tht.tht.data.local.datasource.SignupUserDataSourceImpl
import com.tht.tht.data.local.mapper.toEntity
import com.tht.tht.domain.signup.model.SignupUserModel
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand All @@ -18,15 +15,15 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test


@ExperimentalCoroutinesApi
internal class SignupUserDaoImplTest {
private lateinit var dao: SignupUserDaoImpl
private lateinit var sp: SharedPreferences
private val testDispatcher = StandardTestDispatcher(TestCoroutineScheduler())
private lateinit var context: Context

private val savedUser = SignupUserModel.getFromDefaultArgument().copy(phone = "savedUser").toEntity()
private val savedUser =
SignupUserModel.getFromDefaultArgument().copy(phone = "savedUser").toEntity()

@Before
fun setup() {
Expand Down Expand Up @@ -87,7 +84,4 @@ internal class SignupUserDaoImplTest {
assertThat(actual)
.isFalse
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ internal class ImageRepositoryImplTest {
repository.uploadImageWithIndex(uriString, "", 0)
coVerify { dataSource.uploadImage(any(), any()) }
}

}

1 change: 0 additions & 1 deletion data/src/main/java/com/tht/tht/data/di/DispatcherModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ object DispatcherModule {
@IODispatcher
@Provides
fun provideIODispatcher() = Dispatchers.IO

}

@Qualifier
Expand Down
39 changes: 27 additions & 12 deletions data/src/main/java/com/tht/tht/data/di/UseCaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,63 +41,71 @@ object UseCaseModule {
repository: SignupRepository,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): CreateSignupUserUseCase = CreateSignupUserUseCase(
repository, dispatcher
repository,
dispatcher
)

@Provides
fun provideFetchIdealTypeUseCase(
repository: SignupRepository,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): FetchIdealTypeUseCase = FetchIdealTypeUseCase(
repository, dispatcher
repository,
dispatcher
)

@Provides
fun provideFetchInterestUseCase(
repository: SignupRepository,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): FetchInterestUseCase = FetchInterestUseCase(
repository, dispatcher
repository,
dispatcher
)

@Provides
fun provideFetchSignupUserUseCase(
repository: SignupRepository,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): FetchSignupUserUseCase = FetchSignupUserUseCase(
repository, dispatcher
repository,
dispatcher
)

@Provides
fun provideFetchTermsUseCase(
repository: SignupRepository,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): FetchTermsUseCase = FetchTermsUseCase(
repository, dispatcher
repository,
dispatcher
)

@Provides
fun providePatchSignupDataUseCase(
repository: SignupRepository,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): PatchSignupDataUseCase = PatchSignupDataUseCase(
repository, dispatcher
repository,
dispatcher
)

@Provides
fun provideRemoveSignupUserUseCase(
repository: SignupRepository,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): RemoveSignupUserUseCase = RemoveSignupUserUseCase(
repository, dispatcher
repository,
dispatcher
)

@Provides
fun provideRequestAuthenticationUseCase(
repository: SignupRepository,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): RequestAuthenticationUseCase = RequestAuthenticationUseCase(
repository, dispatcher
repository,
dispatcher
)

@Provides
Expand All @@ -107,7 +115,10 @@ object UseCaseModule {
removeSignupUserUseCase: RemoveSignupUserUseCase,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): RequestSignupUseCase = RequestSignupUseCase(
repository, tokenRepository, removeSignupUserUseCase, dispatcher
repository,
tokenRepository,
removeSignupUserUseCase,
dispatcher
)

@Provides
Expand All @@ -116,7 +127,9 @@ object UseCaseModule {
tokenRepository: TokenRepository,
loginRepository: LoginRepository
): CheckLoginEnableUseCase = CheckLoginEnableUseCase(
repository, tokenRepository, loginRepository
repository,
tokenRepository,
loginRepository
)

@Provides
Expand All @@ -125,7 +138,9 @@ object UseCaseModule {
createSignupUserUseCase: CreateSignupUserUseCase,
@DefaultDispatcher dispatcher: CoroutineDispatcher
): RequestPhoneVerifyUseCase = RequestPhoneVerifyUseCase(
repository, createSignupUserUseCase, dispatcher
repository,
createSignupUserUseCase,
dispatcher
)

@Provides
Expand Down Expand Up @@ -189,7 +204,7 @@ object UseCaseModule {

@Provides
fun provideGetChatListUseCase(
repository: ChatRepository,
repository: ChatRepository
): GetChatListUseCase =
GetChatListUseCase(repository)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object OkHttpInterceptorModule {

@Provides
fun provideHeaderInterceptor(
fetchThtTokenUseCase: FetchThtTokenUseCase,
fetchThtTokenUseCase: FetchThtTokenUseCase
): Interceptor = Interceptor { chain ->
val requestBuilder = chain.request().newBuilder()
.header(HttpHeaderKey.CONTENT_TYPE_HEADER_KEY, HttpHeaderKey.CONTENT_TYPE_HEADER_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import javax.inject.Singleton
@Singleton
class SignupUserDaoImpl @Inject constructor(
private val sp: SharedPreferences,
private val gson: Gson,
private val gson: Gson
) : SignupUserDao {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TermsDaoImpl @Inject constructor(
val inputStream = context.resources.assets.open("signup_terms.json")
val reader = inputStream.bufferedReader()
Gson().fromJson(reader, TermsEntity::class.java)
}catch (e: Exception) {
} catch (e: Exception) {
e.printStackTrace()
throw e
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ interface SignupUserDataSource {
suspend fun fetchSignupUser(phone: String): SignupUserEntity?

suspend fun removeSignupUser(phone: String): Boolean

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.tht.tht.data.local.datasource

import android.content.SharedPreferences
import androidx.core.content.edit
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.tht.tht.data.di.IODispatcher
import com.tht.tht.data.local.dao.SignupUserDao
import com.tht.tht.data.local.entity.SignupUserEntity
Expand All @@ -16,7 +12,7 @@ class SignupUserDataSourceImpl @Inject constructor(
@IODispatcher private val dispatcher: CoroutineDispatcher
) : SignupUserDataSource {
override suspend fun saveSignupUser(phone: String, user: SignupUserEntity): SignupUserEntity {
return withContext(dispatcher){
return withContext(dispatcher) {
signupUserDao.saveSignupUser(phone, user)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ interface TokenDataSource {
suspend fun fetchThtToken(): String?

suspend fun fetchPhone(): String?

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tht.tht.data.local.entity


import com.google.gson.annotations.SerializedName

data class TermsEntity(
Expand Down
6 changes: 3 additions & 3 deletions data/src/main/java/com/tht/tht/data/local/mapper/Mapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ fun LocationResponse.toModel(): LocationModel {
val simpleAddress = StringBuilder()
var isDetail = false
address.split(" ").forEach { name ->
if(name.isEmpty()) return@forEach
if(name.first() == '(') isDetail = true
if (name.isEmpty()) return@forEach
if (name.first() == '(') isDetail = true
if (isDetail) return@forEach

val newName = when(name) {
val newName = when (name) {
"대한민국" -> return@forEach
"경기" -> "경기도"
"충북" -> "충청북도"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.tht.tht.data.remote.datasource.chat

import com.tht.tht.data.di.IODispatcher
import com.tht.tht.data.remote.mapper.toUnwrap
import com.tht.tht.data.remote.response.chat.ChatListResponse
import com.tht.tht.data.remote.service.chat.ChatService
import kotlinx.coroutines.CoroutineDispatcher
import javax.inject.Inject

class ChatDataSourceImpl @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext
import javax.inject.Inject


class LocationDataSourceImpl @Inject constructor(
@IODispatcher private val dispatcher: CoroutineDispatcher,
private val locationService: LocationService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@ fun DailyTopicModel.toEntity(): DailyTopicResponse.FallingTopic {
talkIssue = content
)
}


Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.tht.tht.domain.dailyusercard.DailyUserCardModel
import com.tht.tht.domain.signup.model.IdealTypeModel
import com.tht.tht.domain.signup.model.InterestModel


fun DailyUserCardResponse.UserInfo.IdealTypeResponse.toModel(): IdealTypeModel {
return IdealTypeModel(
title = name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ inline fun <reified T : Any> ThtResponse<out T>.toUnwrap(): T {
is BaseResponse.UnknownError -> throw Exception(throwable.message)
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ fun ChatListResponse.toModel() = ChatListModel(
partnerName = partnerName,
partnerProfileUrl = partnerProfileUrl,
currentMessage = currentMessage,
messageTime = messageTime,
messageTime = messageTime
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tht.tht.data.remote.request.dailyusercard


import com.google.gson.annotations.SerializedName

data class DailyUserCardRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tht.tht.data.remote.request.login


import com.google.gson.annotations.SerializedName

data class FcmTokenLoginRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tht.tht.data.remote.request.signup


import com.google.gson.annotations.SerializedName

data class SignupRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tht.tht.data.remote.response.authenticationnumber


import com.google.gson.annotations.SerializedName

data class AuthenticationNumberResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sealed class BaseResponse<out T : Any, out E : Any> {

data class ApiError<E : Any>(
val statusCode: Int,
val errorResponse: E,
val errorResponse: E
) : BaseResponse<Nothing, E>()

data class NetworkError(val exception: IOException) : BaseResponse<Nothing, Nothing>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ data class ErrorResponse(
val error: String,
val message: String,
val timestamp: String,
val path: String,
val path: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ data class ChatListResponse(
@SerializedName("partnerName") val partnerName: String,
@SerializedName("partnerProfileUrl") val partnerProfileUrl: String,
@SerializedName("currentMessage") val currentMessage: String,
@SerializedName("messageTime") val messageTime: String,
)
@SerializedName("messageTime") val messageTime: String
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tht.tht.data.remote.response.dailyusercard


import com.google.gson.annotations.SerializedName

data class DailyUserCardResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ data class IdealTypeResponse(
@SerializedName("name") override val name: String,
@SerializedName("emojiCode") override val emojiCode: String,
@SerializedName("idx") override val idx: Long
): TypeResponse
) : TypeResponse
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ data class InterestTypeResponse(
@SerializedName("name") override val name: String,
@SerializedName("emojiCode") override val emojiCode: String,
@SerializedName("idx") override val idx: Long
): TypeResponse
) : TypeResponse
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.tht.tht.data.remote.response.location

data class LocationResponse (
data class LocationResponse(
val lat: Double,
val lng: Double,
val address: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tht.tht.data.remote.response.login


import com.google.gson.annotations.SerializedName

data class FcmTokenLoginResponse(
Expand Down
Loading

0 comments on commit 5c0d499

Please sign in to comment.