diff --git a/casper-convention/src/main/kotlin/io/casper/convention/model/CodeElement.kt b/casper-convention/src/main/kotlin/io/casper/convention/model/CodeElement.kt index 230726c1..737cf1e6 100644 --- a/casper-convention/src/main/kotlin/io/casper/convention/model/CodeElement.kt +++ b/casper-convention/src/main/kotlin/io/casper/convention/model/CodeElement.kt @@ -1,10 +1,10 @@ package io.casper.convention.model /** - * 코드 요소 종류를 정의하는 열거형 클래스입니다. + * 코드 요소 종류를 정의하는 sealed class입니다. * 각 코드 요소는 KDoc 검사 대상이 됩니다. */ -enum class CodeElement( +sealed class CodeElement( val friendlyName: String, val difficulty: Int, val helpMessage: String @@ -12,45 +12,45 @@ enum class CodeElement( /** * Kotlin 클래스 정의 */ - CLASS( + object CLASS : CodeElement( "클래스", 3, "클래스 '%s'에 KDoc 주석이 없습니다." - ), + ) /** * Kotlin 객체 정의 */ - OBJECT( + object OBJECT : CodeElement( "객체", 3, "객체 '%s'에 KDoc 주석이 없습니다." - ), + ) /** * Kotlin 인터페이스 정의 */ - INTERFACE( + object INTERFACE : CodeElement( "인터페이스", 3, "인터페이스 '%s'에 KDoc 주석이 없습니다." - ), + ) /** * Kotlin 함수 정의 */ - FUNCTION( + object FUNCTION : CodeElement( "함수", 4, "함수 '%s'에 KDoc 주석이 없습니다." - ), + ) /** * Kotlin 속성 정의 */ - PROPERTY( + object PROPERTY : CodeElement( "속성", 5, "속성 '%s'에 KDoc 주석이 없습니다." - ); + ) } \ No newline at end of file diff --git a/casper-convention/src/main/kotlin/io/casper/convention/model/DocumentationProblem.kt b/casper-convention/src/main/kotlin/io/casper/convention/model/DocumentationProblem.kt index 3418fe41..f8469105 100644 --- a/casper-convention/src/main/kotlin/io/casper/convention/model/DocumentationProblem.kt +++ b/casper-convention/src/main/kotlin/io/casper/convention/model/DocumentationProblem.kt @@ -1,5 +1,7 @@ package io.casper.convention.model +import io.casper.convention.util.DocMessageTemplates + /** * 문서화 문제를 나타내는 데이터 클래스입니다. * 코드 베이스에서 KDoc 주석이 누락된 요소에 대한 정보를 저장합니다. @@ -35,26 +37,22 @@ data class DocumentationProblem( * * @return 파일명과 줄 번호가 포함된 형식화된 오류 메시지 */ - fun toUserFriendlyMessage(): String { - val message = element.helpMessage.format(elementName) - return "[$fileName:$lineNumber] $message" - } + fun toUserFriendlyMessage(): String = + DocMessageTemplates.USER_FRIENDLY_MESSAGE.format(fileName, lineNumber, element.helpMessage.format(elementName)) /** * 개발자를 위한 상세 오류 메시지를 생성합니다. * * @return 파일 경로와 줄 번호가 포함된 상세 오류 메시지 */ - fun toDetailedMessage(): String { - return "${element.friendlyName} '$elementName'에 KDoc 주석이 없습니다. (파일: $filePath, 라인: $lineNumber)" - } + fun toDetailedMessage(): String = + DocMessageTemplates.DETAILED_MESSAGE.format(element.friendlyName, elementName, filePath, lineNumber) /** * 로그 출력용 짧은 메시지를 생성합니다. * * @return 간결한 형식의 로그 메시지 */ - fun toLogMessage(): String { - return "문서화 필요: ${element.friendlyName} '$elementName' ($fileName:$lineNumber)" - } + fun toLogMessage(): String = + DocMessageTemplates.LOG_MESSAGE.format(element.friendlyName, elementName, fileName, lineNumber) } \ No newline at end of file diff --git a/casper-convention/src/main/kotlin/io/casper/convention/service/DocCheckService.kt b/casper-convention/src/main/kotlin/io/casper/convention/service/DocCheckService.kt index 8c073a53..07d203d6 100644 --- a/casper-convention/src/main/kotlin/io/casper/convention/service/DocCheckService.kt +++ b/casper-convention/src/main/kotlin/io/casper/convention/service/DocCheckService.kt @@ -40,7 +40,7 @@ class DocCheckService( /** * 프로젝트 내 소스 파일들을 분석하여 문서화 문제를 찾습니다. * - * @param sourceFiles 분석할 소스 파일 목록 + * @param sourceFile 분석할 소스 파일 목록 * @param element 검사할 코드 요소 타입 * @return 발견된 문서화 문제 목록 */ diff --git a/casper-convention/src/main/kotlin/io/casper/convention/tasks/DocCheckTask.kt b/casper-convention/src/main/kotlin/io/casper/convention/tasks/DocCheckTask.kt index 1601fced..dfd3a973 100644 --- a/casper-convention/src/main/kotlin/io/casper/convention/tasks/DocCheckTask.kt +++ b/casper-convention/src/main/kotlin/io/casper/convention/tasks/DocCheckTask.kt @@ -1,5 +1,6 @@ package io.casper.convention.tasks +import io.casper.convention.exception.DocumentationException import io.casper.convention.model.CodeElement import io.casper.convention.service.DocCheckService import org.gradle.api.DefaultTask @@ -35,10 +36,7 @@ abstract class DocCheckTask : DefaultTask() { val success = checkService.checkDocumentation(element) if (!success) { - throw GradleException( - "일부 ${element.friendlyName}에 KDoc 주석이 없습니다. " + - "자세한 내용은 로그를 확인하세요." - ) + throw DocumentationException.missingDocumentation(element) } } } \ No newline at end of file