fix: lint

This commit is contained in:
usbharu 2023-11-16 20:59:22 +09:00
parent f0a84e7fa1
commit ac0e05ade8
13 changed files with 15 additions and 42 deletions

View File

@ -41,7 +41,5 @@ open class Delete : Object {
return result
}
override fun toString(): String {
return "Delete(`object`=$`object`, published=$published) ${super.toString()}"
}
override fun toString(): String = "Delete(`object`=$`object`, published=$published) ${super.toString()}"
}

View File

@ -62,13 +62,9 @@ class ContextDeserializer : JsonDeserializer<String>() {
class ContextSerializer : JsonSerializer<List<String>>() {
override fun isEmpty(value: List<String>?): Boolean {
return value.isNullOrEmpty()
}
override fun isEmpty(value: List<String>?): Boolean = value.isNullOrEmpty()
override fun isEmpty(provider: SerializerProvider?, value: List<String>?): Boolean {
return value.isNullOrEmpty()
}
override fun isEmpty(provider: SerializerProvider?, value: List<String>?): Boolean = value.isNullOrEmpty()
override fun serialize(value: List<String>?, gen: JsonGenerator?, serializers: SerializerProvider) {
if (value.isNullOrEmpty()) {

View File

@ -46,9 +46,7 @@ open class Object : JsonLd {
return result
}
override fun toString(): String {
return "Object(type=$type, name=$name, actor=$actor, id=$id) ${super.toString()}"
}
override fun toString(): String = "Object(type=$type, name=$name, actor=$actor, id=$id) ${super.toString()}"
companion object {
@JvmStatic

View File

@ -12,7 +12,7 @@ class UserAPControllerImpl(private val apUserService: APUserService) : UserAPCon
override suspend fun userAp(username: String): ResponseEntity<Person> {
val person = try {
apUserService.getPersonByName(username)
} catch (e: FailedToGetResourcesException) {
} catch (_: FailedToGetResourcesException) {
return ResponseEntity.notFound().build()
}
person.context += listOf("https://www.w3.org/ns/activitystreams")

View File

@ -22,7 +22,7 @@ class APReceiveDeleteServiceImpl(
val post = try {
postQueryService.findByApId(deleteId)
} catch (e: FailedToGetResourcesException) {
} catch (_: FailedToGetResourcesException) {
return@transaction ActivityPubStringResponse(HttpStatusCode.OK, "Resource not found or already deleted")
}
postRepository.delete(post.id)

View File

@ -1,6 +1,5 @@
package dev.usbharu.hideout.activitypub.service.objects.note
import com.fasterxml.jackson.databind.ObjectMapper
import dev.usbharu.hideout.activitypub.domain.exception.FailedToGetActivityPubResourceException
import dev.usbharu.hideout.activitypub.domain.exception.IllegalActivityPubObjectException
import dev.usbharu.hideout.activitypub.domain.model.Note
@ -24,7 +23,6 @@ import kotlinx.coroutines.async
import kotlinx.coroutines.slf4j.MDCContext
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Service
import java.time.Instant
@ -50,7 +48,6 @@ class APNoteServiceImpl(
private val postRepository: PostRepository,
private val apUserService: APUserService,
private val postQueryService: PostQueryService,
@Qualifier("activitypub") private val objectMapper: ObjectMapper,
private val postService: PostService,
private val apResourceResolveService: APResourceResolveService,
private val postBuilder: Post.PostBuilder,

View File

@ -73,7 +73,6 @@ class PostRepositoryImpl(
.let(postQueryMapper::map)
.singleOr { FailedToGetResourcesException("id: $id was not found.", it) }
override suspend fun delete(id: Long) {
Posts.deleteWhere { Posts.id eq id }
}

View File

@ -24,6 +24,7 @@ open class MediaServiceImpl(
private val remoteMediaDownloadService: RemoteMediaDownloadService,
private val renameService: MediaFileRenameService
) : MediaService {
@Suppress("LongMethod")
override suspend fun uploadLocalMedia(mediaRequest: MediaRequest): EntityMedia {
val fileName = mediaRequest.file.name
logger.info(
@ -33,8 +34,6 @@ open class MediaServiceImpl(
val tempFile = Files.createTempFile("hideout-tmp-file", ".tmp")
tempFile.withDelete().use {
Files.newOutputStream(tempFile).use { outputStream ->
mediaRequest.file.inputStream.use {
@ -93,8 +92,6 @@ open class MediaServiceImpl(
}
}
}
}
// TODO: 仮の処理として保存したように動かす
@ -156,11 +153,11 @@ open class MediaServiceImpl(
return mediaProcessServices.first {
try {
it.isSupport(mimeType)
} catch (e: Exception) {
} catch (_: Exception) {
false
}
}
} catch (e: NoSuchElementException) {
} catch (_: NoSuchElementException) {
throw UnsupportedMediaException("MediaType: $mimeType isn't supported.")
}
}

View File

@ -12,9 +12,7 @@ class MediaProcessServiceImpl(
private val mediaConverterRoot: MediaConverterRoot,
private val thumbnailGenerateService: ThumbnailGenerateService
) : MediaProcessService {
override fun isSupport(mimeType: MimeType): Boolean {
return false
}
override fun isSupport(mimeType: MimeType): Boolean = false
override suspend fun process(
fileType: FileType,

View File

@ -70,7 +70,9 @@ class ImageMediaProcessService(private val imageMediaProcessorConfiguration: Ima
Thumbnails.of(thumbnails.toFile()).size(width, height).asBufferedImage()
} else {
Thumbnails.of(bufferedImage).size(width, height).asBufferedImage()
}, convertType, it
},
convertType,
it
)
if (write) {
tempThumbnailFile

View File

@ -22,9 +22,7 @@ import kotlin.math.min
@Service
@Qualifier("video")
class MovieMediaProcessService : MediaProcessService {
override fun isSupport(mimeType: MimeType): Boolean {
return mimeType.type == "video"
}
override fun isSupport(mimeType: MimeType): Boolean = mimeType.type == "video"
override suspend fun process(
fileType: FileType,
@ -92,7 +90,6 @@ class MovieMediaProcessService : MediaProcessService {
while (true) {
val grab = grabber.grab() ?: break
if (bufferedImage == null) {
bufferedImage = frameConverter.convert(grab)
}
@ -106,14 +103,11 @@ class MovieMediaProcessService : MediaProcessService {
}
}
if (bufferedImage != null) {
ImageIO.write(bufferedImage, "jpeg", thumbnailFile.toFile())
}
}
}
}
logger.info("SUCCESS Convert Movie Media {}", fileName)

View File

@ -45,7 +45,7 @@ class ReactionServiceImpl(
reactionQueryService.findByPostIdAndUserIdAndEmojiId(postId, userId, 0)
reactionRepository.delete(findByPostIdAndUserIdAndEmojiId)
apReactionService.removeReaction(findByPostIdAndUserIdAndEmojiId)
} catch (e: FailedToGetResourcesException) {
} catch (_: FailedToGetResourcesException) {
}
}

View File

@ -37,7 +37,6 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.mockito.kotlin.*
import utils.JsonObjectMapper.objectMapper
import utils.PostBuilder
import utils.UserBuilder
import java.time.Instant
@ -74,7 +73,6 @@ class APNoteServiceImplTest {
postRepository = mock(),
apUserService = mock(),
postQueryService = mock(),
objectMapper = objectMapper,
postService = mock(),
apResourceResolveService = mock(),
postBuilder = Post.PostBuilder(CharacterLimit()),
@ -152,7 +150,6 @@ class APNoteServiceImplTest {
postRepository = postRepository,
apUserService = apUserService,
postQueryService = postQueryService,
objectMapper = objectMapper,
postService = mock(),
apResourceResolveService = apResourceResolveService,
postBuilder = Post.PostBuilder(CharacterLimit()),
@ -221,7 +218,6 @@ class APNoteServiceImplTest {
postRepository = mock(),
apUserService = mock(),
postQueryService = postQueryService,
objectMapper = objectMapper,
postService = mock(),
apResourceResolveService = apResourceResolveService,
postBuilder = Post.PostBuilder(CharacterLimit()),
@ -274,7 +270,6 @@ class APNoteServiceImplTest {
postRepository = postRepository,
apUserService = apUserService,
postQueryService = mock(),
objectMapper = objectMapper,
postService = postService,
apResourceResolveService = mock(),
postBuilder = postBuilder,
@ -333,7 +328,6 @@ class APNoteServiceImplTest {
postRepository = mock(),
apUserService = mock(),
postQueryService = mock(),
objectMapper = objectMapper,
postService = mock(),
apResourceResolveService = mock(),
postBuilder = postBuilder,