Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Apr 27, 2022
1 parent 3d27411 commit a1be69a
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 29 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root=true
[*]
indent_size=2
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
insert_final_newline=true
[*.{kt,kts}]
ij_kotlin_imports_layout=*
[*.xml]
indent_size=4
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import com.hoc.comicapp.domain.models.FavoriteComic
@Suppress("ClassName")
@IgnoreExtraProperties
data class _FavoriteComic(
@get:PropertyName("url") @set:PropertyName("url") var url: String,
@get:PropertyName("title") @set:PropertyName("title") var title: String,
@get:PropertyName("thumbnail") @set:PropertyName("thumbnail") var thumbnail: String,
@get:PropertyName("view") @set:PropertyName("view") var view: String,
@get:ServerTimestamp @get:PropertyName("created_at") @set:PropertyName("created_at") var createdAt: Timestamp?,
@get:PropertyName("url") @set:PropertyName("url")
var url: String,
@get:PropertyName("title") @set:PropertyName("title")
var title: String,
@get:PropertyName("thumbnail") @set:PropertyName("thumbnail")
var thumbnail: String,
@get:PropertyName("view") @set:PropertyName("view")
var view: String,
@get:ServerTimestamp @get:PropertyName("created_at") @set:PropertyName("created_at")
var createdAt: Timestamp?,
) {
fun toDomain(): FavoriteComic {
return FavoriteComic(
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/com/hoc/comicapp/data/firebase/entity/_User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import com.hoc.comicapp.domain.models.User
@Suppress("ClassName")
@IgnoreExtraProperties
data class _User(
@get:PropertyName("uid") @set:PropertyName("uid") var uid: String,
@get:PropertyName("display_name") @set:PropertyName("display_name") var displayName: String,
@get:PropertyName("email") @set:PropertyName("email") var email: String,
@get:PropertyName("photo_url") @set:PropertyName("photo_url") var photoURL: String,
@get:PropertyName("uid") @set:PropertyName("uid")
var uid: String,
@get:PropertyName("display_name") @set:PropertyName("display_name")
var displayName: String,
@get:PropertyName("email") @set:PropertyName("email")
var email: String,
@get:PropertyName("photo_url") @set:PropertyName("photo_url")
var photoURL: String,
) {
@Suppress("unused")
constructor() : this("", "", "", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class FirebaseAuthUserDataSourceImpl(

override suspend fun register(email: String, password: String, fullName: String, avatar: Uri?) = Either.catch {
withContext(dispatchersProvider.io) {

val authResult = firebaseAuth.createUserWithEmailAndPassword(email, password).await()
val user = authResult.user ?: throw IllegalStateException("User is null")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class ComicDetailFragment : BaseFragment<
}
}

private fun onClickButtonRead(readFirst: @ParameterName(name = "readFirst") Boolean) {
private fun onClickButtonRead(readFirst: Boolean) {
val comicDetail = viewModel.state.value.comicDetail as? ComicDetail.Detail ?: return
val chapter =
comicDetail.chapters.let { if (readFirst) it.lastOrNull() else it.firstOrNull() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class ComicDetailInteractorImpl(
link: String,
): Observable<ComicDetailPartialChange> {
return rxObservable(dispatchersProvider.main) {

if (thumbnail != null && name != null && view != null && remoteThumbnail != null) {
send(
InitialRetryPartialChange.InitialData(
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/hoc/comicapp/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class HomeFragment :
// Swipe refresh layout and recycler view
viewBinding.swipeRefreshLayout.setColorSchemeColors(*resources.getIntArray(R.array.swipe_refresh_colors))
viewBinding.recyclerHome.run {

setHasFixedSize(true)
layoutManager = GridLayoutManager(this@HomeFragment.context, getMaxSpanCount()).apply {
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[{*.kt, *.kts}]
# Allow longer max_line_length within buildSrc/
max_line_length = 200
max_line_length = 300
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object PluginVersions {
const val navigationSafeArgs = "2.5.0-alpha04"
const val googleServices = "4.3.10"
const val crashlytics = "2.7.1"
const val spotless = "5.17.0"
const val spotless = "6.5.0"
const val gradleVersions = "0.39.0"
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Configurations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object appConfig {
}

object versions {
const val ktLint = "0.41.0"
const val ktLint = "0.44.0"

object sdk {
const val buildTools = "31.0.0"
Expand Down
2 changes: 2 additions & 0 deletions domain/src/main/java/com/hoc/comicapp/domain/Result.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ktlint-disable filename

package com.hoc.comicapp.domain

import arrow.core.Either
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ktlint-disable filename

package com.hoc.comicapp.navigation

import android.os.Parcelable
Expand Down
36 changes: 23 additions & 13 deletions spotless.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ apply(plugin = "com.diffplug.spotless")
configure<SpotlessExtension> {
kotlin {
target("**/*.kt")
ktlint(versions.ktLint).userData(
mapOf(
"indent_size" to "2",
"continuation_indent_size" to "4",
"kotlin_imports_layout" to "ascii"
ktlint(versions.ktLint)
.setUseExperimental(true)
.userData(
mapOf(
"continuation_indent_size" to "4",
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8",
"disabled_rules" to "experimental:package-name,experimental:trailing-comma",
)
)
)

trimTrailingWhitespace()
indentWithSpaces()
Expand All @@ -29,16 +34,21 @@ configure<SpotlessExtension> {
kotlinGradle {
target("**/*.gradle.kts", "*.gradle.kts")

ktlint(versions.ktLint).userData(
mapOf(
"indent_size" to "2",
"continuation_indent_size" to "4",
"kotlin_imports_layout" to "ascii"
ktlint(versions.ktLint)
.setUseExperimental(true)
.userData(
mapOf(
"continuation_indent_size" to "4",
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8",
"disabled_rules" to "no-wildcard-imports",
)
)
)

trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
}

0 comments on commit a1be69a

Please sign in to comment.