diff --git a/detekt.yml b/detekt.yml index a74f1251..cb59ca02 100644 --- a/detekt.yml +++ b/detekt.yml @@ -154,6 +154,9 @@ performance: UnnecessaryTemporaryInstantiation: active: true + SpreadOperator: + active: false + potential-bugs: CastToNullableType: active: true diff --git a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Person.kt b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Person.kt index d57bfac8..f08b161e 100644 --- a/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Person.kt +++ b/src/main/kotlin/dev/usbharu/hideout/activitypub/domain/model/Person.kt @@ -21,6 +21,7 @@ constructor( val manuallyApprovesFollowers: Boolean? = false ) : Object(add(type, "Person")), HasId, HasName { + @Suppress("CyclomaticComplexMethod", "CognitiveComplexMethod") override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false @@ -45,6 +46,7 @@ constructor( return true } + @Suppress("CyclomaticComplexMethod") override fun hashCode(): Int { var result = super.hashCode() result = 31 * result + name.hashCode() diff --git a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsServiceImpl.kt index ddb289cb..2e979cea 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/springframework/oauth2/UserDetailsServiceImpl.kt @@ -27,7 +27,7 @@ class UserDetailsServiceImpl( val findById = try { actorQueryService.findByNameAndDomain(username, applicationConfig.url.host) } catch (e: FailedToGetResourcesException) { - throw UsernameNotFoundException("$username not found") + throw UsernameNotFoundException("$username not found", e) } val userDetails = userDetailRepository.findByActorId(findById.id) ?: throw UsernameNotFoundException("${findById.id} not found.") diff --git a/src/main/kotlin/dev/usbharu/hideout/core/query/RelationshipQueryService.kt b/src/main/kotlin/dev/usbharu/hideout/core/query/RelationshipQueryService.kt index 6278ae30..c4219711 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/query/RelationshipQueryService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/query/RelationshipQueryService.kt @@ -5,6 +5,8 @@ import dev.usbharu.hideout.core.domain.model.relationship.Relationship interface RelationshipQueryService { suspend fun findByTargetIdAndFollowing(targetId: Long, following: Boolean): List + + @Suppress("LongParameterList") suspend fun findByTargetIdAndFollowRequestAndIgnoreFollowRequest( maxId: Long?, sinceId: Long?, diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImpl.kt index 966163e8..8b508af0 100644 --- a/src/main/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/relationship/RelationshipServiceImpl.kt @@ -73,7 +73,6 @@ class RelationshipServiceImpl( relationshipRepository.save(relationship) - val remoteUser = isRemoteUser(targetId) if (remoteUser != null) { diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/AccountQueryServiceImpl.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/AccountQueryServiceImpl.kt index 13daaf89..916c1333 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/AccountQueryServiceImpl.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/infrastructure/exposedquery/AccountQueryServiceImpl.kt @@ -32,7 +32,11 @@ class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) lastCreated, postsCount ) - .select { Actors.id eq accountId and (Relationships.following eq true or (Relationships.following.isNull())) } + .select { + (Actors.id.eq(accountId)).and( + Relationships.following.eq(true).or(Relationships.following.isNull()) + ) + } .groupBy(Actors.id) return query @@ -57,7 +61,10 @@ class AccountQueryServiceImpl(private val applicationConfig: ApplicationConfig) lastCreated, postsCount ) - .select { Actors.id inList accountIds and (Relationships.following eq true or (Relationships.following.isNull())) } + .select { + Actors.id.inList(accountIds) + .and(Relationships.following.eq(true).or(Relationships.following.isNull())) + } .groupBy(Actors.id) return query diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/account/MastodonAccountApiController.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/account/MastodonAccountApiController.kt index 124f1e75..e8e65008 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/account/MastodonAccountApiController.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/interfaces/api/account/MastodonAccountApiController.kt @@ -144,7 +144,8 @@ class MastodonAccountApiController( return ResponseEntity.ok(removeFromFollowers) } - override suspend fun apiV1AccountsUpdateCredentialsPatch(updateCredentials: UpdateCredentials?): ResponseEntity { + override suspend fun apiV1AccountsUpdateCredentialsPatch(updateCredentials: UpdateCredentials?): + ResponseEntity { val principal = SecurityContextHolder.getContext().getAuthentication().principal as Jwt val userid = principal.getClaim("uid").toLong() diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt index 0ff62971..98cfdb3e 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountApiService.kt @@ -16,6 +16,7 @@ import org.springframework.stereotype.Service import kotlin.math.min @Service +@Suppress("TooManyFunctions") interface AccountApiService { @Suppress("LongParameterList") suspend fun accountsStatuses( diff --git a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountService.kt b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountService.kt index 88cb1f88..b3f57aaf 100644 --- a/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/mastodon/service/account/AccountService.kt @@ -14,11 +14,7 @@ interface AccountService { class AccountServiceImpl( private val accountQueryService: AccountQueryService ) : AccountService { - override suspend fun findById(id: Long): Account { - return accountQueryService.findById(id) - } + override suspend fun findById(id: Long): Account = accountQueryService.findById(id) - override suspend fun findByIds(ids: List): List { - return accountQueryService.findByIds(ids) - } + override suspend fun findByIds(ids: List): List = accountQueryService.findByIds(ids) }