From da106a6922fff92b2d1374c5a1472f5d7ebbd3e3 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:47:11 +0900 Subject: [PATCH] style: fix lint --- .../usbharu/hideout/core/config/MessageSourceConfig.kt | 4 +--- .../dev/usbharu/hideout/core/config/SecurityConfig.kt | 1 + .../model/userdetails/UserDetailHashedPassword.kt | 4 +--- .../core/domain/model/userdetails/UserDetailId.kt | 4 +--- .../exposedquery/ExposedUserTimelineQueryService.kt | 10 +++++----- .../hideout/core/interfaces/web/auth/AuthController.kt | 5 ++--- .../hideout/core/interfaces/web/posts/PublishPost.kt | 1 + .../main/kotlin/dev/usbharu/hideout/util/RsaUtil.kt | 8 ++------ 8 files changed, 14 insertions(+), 23 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt index ecbc2553..dcfecd4b 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/MessageSourceConfig.kt @@ -22,7 +22,5 @@ class MessageSourceConfig { @Bean @Profile("dev") @ConfigurationProperties(prefix = "spring.messages") - fun messageSourceProperties(): MessageSourceProperties { - return MessageSourceProperties() - } + fun messageSourceProperties(): MessageSourceProperties = MessageSourceProperties() } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/SecurityConfig.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/SecurityConfig.kt index a9730eda..d0b071ca 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/SecurityConfig.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/config/SecurityConfig.kt @@ -140,6 +140,7 @@ class SecurityConfig { } @Bean + @Suppress("UnsafeCallOnNullableType") fun loadJwkSource(jwkConfig: JwkConfig, applicationConfig: ApplicationConfig): JWKSource { if (jwkConfig.keyId == null) { logger.error("hideout.security.jwt.keyId is null.") diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetailHashedPassword.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetailHashedPassword.kt index 8e5edf56..2e73d911 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetailHashedPassword.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetailHashedPassword.kt @@ -18,7 +18,5 @@ package dev.usbharu.hideout.core.domain.model.userdetails @JvmInline value class UserDetailHashedPassword(val password: String) { - override fun toString(): String { - return "[MASKED]" - } + override fun toString(): String = "[MASKED]" } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetailId.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetailId.kt index 0641cd6e..23faa150 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetailId.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/userdetails/UserDetailId.kt @@ -18,7 +18,5 @@ package dev.usbharu.hideout.core.domain.model.userdetails @JvmInline value class UserDetailId(val id: Long) { - override fun toString(): String { - return "UserDetailId(id=$id)" - } + override fun toString(): String = "UserDetailId(id=$id)" } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedUserTimelineQueryService.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedUserTimelineQueryService.kt index 72e48686..82be6f96 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedUserTimelineQueryService.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedquery/ExposedUserTimelineQueryService.kt @@ -17,6 +17,9 @@ import java.net.URI @Repository class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractRepository() { + override val logger: Logger + get() = Companion.logger + protected fun authorizedQuery(principal: Principal? = null): QueryAlias { if (principal == null) { return Posts @@ -73,8 +76,8 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi private fun toPostDetail(it: ResultRow, authorizedQuery: QueryAlias, iconMedia: Alias): PostDetail { return PostDetail( - it[authorizedQuery[Posts.id]], - ActorDetail( + id = it[authorizedQuery[Posts.id]], + actor = ActorDetail( actorId = it[authorizedQuery[Posts.actorId]], instanceId = it[Actors.instance], name = it[Actors.name], @@ -101,9 +104,6 @@ class ExposedUserTimelineQueryService : UserTimelineQueryService, AbstractReposi ) } - override val logger: Logger - get() = Companion.logger - companion object { private val logger = LoggerFactory.getLogger(ExposedUserTimelineQueryService::class.java) } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/AuthController.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/AuthController.kt index 7e985359..ccda2fab 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/AuthController.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/auth/AuthController.kt @@ -60,7 +60,6 @@ class AuthController( } @GetMapping("/auth/sign_out") - fun signOut(): String { - return "sign_out" - } + @Suppress("FunctionOnlyReturningConstant") + fun signOut(): String = "sign_out" } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PublishPost.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PublishPost.kt index 334f1b1b..5da5aa30 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PublishPost.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/interfaces/web/posts/PublishPost.kt @@ -1,5 +1,6 @@ package dev.usbharu.hideout.core.interfaces.web.posts +@Suppress("ConstructorParameterNaming") data class PublishPost( var status: String? = null, var overview: String? = null, diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/util/RsaUtil.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/util/RsaUtil.kt index 4af71576..8f9d0bfd 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/util/RsaUtil.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/util/RsaUtil.kt @@ -45,11 +45,7 @@ object RsaUtil { fun decodeRsaPrivateKey(encoded: String): RSAPrivateKey = decodeRsaPrivateKey(Base64Util.decode(encoded)) - fun encodeRsaPublicKey(publicKey: RSAPublicKey): String { - return Base64Util.encode(publicKey.encoded) - } + fun encodeRsaPublicKey(publicKey: RSAPublicKey): String = Base64Util.encode(publicKey.encoded) - fun encodeRsaPrivateKey(privateKey: RSAPrivateKey): String { - return Base64Util.encode(privateKey.encoded) - } + fun encodeRsaPrivateKey(privateKey: RSAPrivateKey): String = Base64Util.encode(privateKey.encoded) }