Skip to content

Commit cbaf40a

Browse files
Apply new spotless rules
1 parent 4fc43bd commit cbaf40a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+496
-406
lines changed

build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ allprojects {
2929
mavenLocal()
3030
}
3131

32-
apply(plugin = rootProject.libs.plugins.spotless.get().pluginId)
32+
apply(
33+
plugin =
34+
rootProject.libs.plugins.spotless
35+
.get()
36+
.pluginId,
37+
)
38+
3339
configure<SpotlessExtension> {
3440
kotlin {
3541
target("**/*.kt")

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[versions]
22
kotlin = "2.0.21"
3-
spotless = "6.23.3"
3+
spotless = "7.0.0.BETA4"
44
ben-manes-versions = "0.51.0"
55
dokka = "1.9.20"
66
kotlinx-datetime = "0.6.1"
77
kotlinx-serialization = "1.7.3"
88
coroutines = "1.9.0"
99
ktor = "3.0.1"
10-
ktlint = "1.1.1"
10+
ktlint = "1.4.1"
1111
junit-jupiter = "5.11.3"
1212
truth = "1.4.4"
1313
junit = "4.13.2"

lib/src/commonMain/kotlin/app/moviebase/trakt/Trakt.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ fun Trakt(block: TraktClientConfig.() -> Unit): Trakt {
2323
return Trakt(config)
2424
}
2525

26-
class Trakt internal constructor(private val config: TraktClientConfig) {
27-
26+
class Trakt internal constructor(
27+
private val config: TraktClientConfig,
28+
) {
2829
constructor(traktApiKey: String) : this(TraktClientConfig.withKey(traktApiKey))
2930

3031
val client: HttpClient by lazy {
@@ -54,7 +55,8 @@ class Trakt internal constructor(private val config: TraktClientConfig) {
5455
val recommendations by buildApi(::TraktRecommendationsApi)
5556
val comments by buildApi(::TraktCommentsApi)
5657

57-
private inline fun <T> buildApi(crossinline builder: (HttpClient) -> T) = lazy {
58-
builder(client)
59-
}
58+
private inline fun <T> buildApi(crossinline builder: (HttpClient) -> T) =
59+
lazy {
60+
builder(client)
61+
}
6062
}

lib/src/commonMain/kotlin/app/moviebase/trakt/TraktClientConfig.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import io.ktor.client.plugins.logging.LoggingConfig
1010

1111
@TraktDsl
1212
class TraktClientConfig {
13-
1413
var traktApiKey: String? = null
1514
var clientSecret: String? = null
1615

@@ -54,16 +53,15 @@ class TraktClientConfig {
5453
}
5554

5655
companion object {
57-
58-
internal fun withKey(tmdbApiKey: String) = TraktClientConfig().apply {
59-
this.traktApiKey = tmdbApiKey
60-
}
56+
internal fun withKey(tmdbApiKey: String) =
57+
TraktClientConfig().apply {
58+
this.traktApiKey = tmdbApiKey
59+
}
6160
}
6261
}
6362

6463
@TraktDsl
6564
class TraktAuthCredentials {
66-
6765
internal var refreshTokensProvider: suspend () -> BearerTokens? = { null }
6866
internal var loadTokensProvider: suspend () -> BearerTokens? = { null }
6967

lib/src/commonMain/kotlin/app/moviebase/trakt/TraktWebConfig.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ internal object TraktUrlParameter {
3636
const val EPISODES = "episodes"
3737
}
3838

39-
enum class TraktExtended(val value: String) {
39+
enum class TraktExtended(
40+
val value: String,
41+
) {
4042
FULL("full"),
4143
NO_SEASONS("noseasons"),
4244
EPISODES("episodes"),

lib/src/commonMain/kotlin/app/moviebase/trakt/api/TraktAuthApi.kt

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@ class TraktAuthApi(
1414
private val client: HttpClient,
1515
private val config: TraktClientConfig,
1616
) {
17-
18-
suspend fun postToken(request: TraktTokenRefreshRequest): TraktAccessToken = client.postByPaths("oauth", "token") {
19-
contentType(ContentType.Application.Json)
20-
setBody(request)
21-
}
17+
suspend fun postToken(request: TraktTokenRefreshRequest): TraktAccessToken =
18+
client.postByPaths("oauth", "token") {
19+
contentType(ContentType.Application.Json)
20+
setBody(request)
21+
}
2222

2323
suspend fun requestAccessToken(
2424
redirectUri: String,
2525
code: String,
2626
): TraktAccessToken {
27-
val requestToken = TraktTokenRefreshRequest(
28-
clientId = config.traktApiKey,
29-
clientSecret = config.clientSecret,
30-
redirectUri = redirectUri,
31-
grantType = TraktGrantType.AUTHORIZATION_CODE,
32-
code = code,
33-
)
27+
val requestToken =
28+
TraktTokenRefreshRequest(
29+
clientId = config.traktApiKey,
30+
clientSecret = config.clientSecret,
31+
redirectUri = redirectUri,
32+
grantType = TraktGrantType.AUTHORIZATION_CODE,
33+
code = code,
34+
)
3435
return postToken(requestToken)
3536
}
3637

@@ -40,13 +41,14 @@ class TraktAuthApi(
4041
): TraktAccessToken {
4142
require(refreshToken.isNotBlank()) { "refresh token is empty" }
4243

43-
val requestToken = TraktTokenRefreshRequest(
44-
clientId = config.traktApiKey,
45-
clientSecret = config.clientSecret,
46-
redirectUri = redirectUri,
47-
grantType = TraktGrantType.REFRESH_TOKEN,
48-
refreshToken = refreshToken,
49-
)
44+
val requestToken =
45+
TraktTokenRefreshRequest(
46+
clientId = config.traktApiKey,
47+
clientSecret = config.clientSecret,
48+
redirectUri = redirectUri,
49+
grantType = TraktGrantType.REFRESH_TOKEN,
50+
refreshToken = refreshToken,
51+
)
5052
return postToken(requestToken)
5153
}
5254
}

lib/src/commonMain/kotlin/app/moviebase/trakt/api/TraktCheckinApi.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import io.ktor.client.request.setBody
1111
import io.ktor.http.ContentType
1212
import io.ktor.http.contentType
1313

14-
class TraktCheckinApi(private val client: HttpClient) {
15-
16-
suspend fun postCheckin(item: TraktCheckinItem): TraktCheckin.Active = client.postByPaths("checkin") {
17-
contentType(ContentType.Application.Json)
18-
setBody(item)
19-
}
14+
class TraktCheckinApi(
15+
private val client: HttpClient,
16+
) {
17+
suspend fun postCheckin(item: TraktCheckinItem): TraktCheckin.Active =
18+
client.postByPaths("checkin") {
19+
contentType(ContentType.Application.Json)
20+
setBody(item)
21+
}
2022

2123
suspend fun deleteCheckin(): TraktCheckin.Active = client.delete(urlString = buildPaths("checkin")).body()
2224
}

lib/src/commonMain/kotlin/app/moviebase/trakt/api/TraktCommentsApi.kt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import io.ktor.client.request.setBody
1414
import io.ktor.http.ContentType
1515
import io.ktor.http.contentType
1616

17-
class TraktCommentsApi(private val client: HttpClient) {
18-
17+
class TraktCommentsApi(
18+
private val client: HttpClient,
19+
) {
1920
suspend fun postComment(comment: TraktPostComment): TraktCheckin.Active =
2021
client.postByPaths("comments") {
2122
contentType(ContentType.Application.Json)
@@ -25,24 +26,25 @@ class TraktCommentsApi(private val client: HttpClient) {
2526
suspend fun updateComment(
2627
id: Int,
2728
comment: TraktPostComment,
28-
): TraktComment = client.put(urlString = buildPaths("comments", id.toString())) {
29-
contentType(ContentType.Application.Json)
30-
setBody(comment)
31-
}.body()
29+
): TraktComment =
30+
client
31+
.put(urlString = buildPaths("comments", id.toString())) {
32+
contentType(ContentType.Application.Json)
33+
setBody(comment)
34+
}.body()
3235

3336
suspend fun getComment(id: Int): TraktComment = client.getByPaths("comments", id.toString())
3437

35-
suspend fun deleteComment(id: Int): TraktComment =
36-
client.delete(urlString = buildPaths("comments", id.toString())).body()
38+
suspend fun deleteComment(id: Int): TraktComment = client.delete(urlString = buildPaths("comments", id.toString())).body()
3739

38-
suspend fun getCommentReplies(id: Int): List<TraktComment> =
39-
client.getByPaths("comments", id.toString(), "replies")
40+
suspend fun getCommentReplies(id: Int): List<TraktComment> = client.getByPaths("comments", id.toString(), "replies")
4041

4142
suspend fun postCommentReplies(
4243
id: Int,
4344
comment: TraktPostComment,
44-
): List<TraktComment> = client.postByPaths("comments", id.toString(), "replies") {
45-
contentType(ContentType.Application.Json)
46-
setBody(comment)
47-
}
45+
): List<TraktComment> =
46+
client.postByPaths("comments", id.toString(), "replies") {
47+
contentType(ContentType.Application.Json)
48+
setBody(comment)
49+
}
4850
}

lib/src/commonMain/kotlin/app/moviebase/trakt/api/TraktEpisodesApi.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ import app.moviebase.trakt.model.TraktEpisode
77
import app.moviebase.trakt.model.TraktRating
88
import io.ktor.client.HttpClient
99

10-
class TraktEpisodesApi(private val client: HttpClient) {
11-
10+
class TraktEpisodesApi(
11+
private val client: HttpClient,
12+
) {
1213
suspend fun getSummary(
1314
traktSlug: String,
1415
seasonNumber: Int,
1516
episodeNumber: Int,
1617
extended: TraktExtended = TraktExtended.FULL,
17-
): TraktEpisode = client.getByPaths(*pathEpisodes(traktSlug, seasonNumber, episodeNumber)) {
18-
parameterExtended(extended)
19-
}
18+
): TraktEpisode =
19+
client.getByPaths(*pathEpisodes(traktSlug, seasonNumber, episodeNumber)) {
20+
parameterExtended(extended)
21+
}
2022

2123
suspend fun getRating(
2224
traktSlug: String,

lib/src/commonMain/kotlin/app/moviebase/trakt/api/TraktMoviesApi.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ import app.moviebase.trakt.model.TraktMovie
66
import app.moviebase.trakt.model.TraktRating
77
import io.ktor.client.HttpClient
88

9-
class TraktMoviesApi(private val client: HttpClient) {
10-
11-
suspend fun getSummary(traktSlug: String): TraktMovie = client.getByPaths(*pathMovies(traktSlug)) {
12-
parameterExtended()
13-
}
9+
class TraktMoviesApi(
10+
private val client: HttpClient,
11+
) {
12+
suspend fun getSummary(traktSlug: String): TraktMovie =
13+
client.getByPaths(*pathMovies(traktSlug)) {
14+
parameterExtended()
15+
}
1416

1517
suspend fun getRating(traktSlug: String): TraktRating = client.getByPaths(*pathMovies(traktSlug, "ratings"))
1618

17-
private fun pathMovies(traktSlug: String, vararg paths: String) = arrayOf("movies", traktSlug, *paths)
19+
private fun pathMovies(
20+
traktSlug: String,
21+
vararg paths: String,
22+
) = arrayOf("movies", traktSlug, *paths)
1823
}

0 commit comments

Comments
 (0)