From 5a4ababe026623ea5c7f827d7e75854a801d197f Mon Sep 17 00:00:00 2001 From: idealflower-k Date: Sat, 20 Jul 2024 15:07:11 +0900 Subject: [PATCH 1/2] KL-99/build: apply checkstyle when test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - test 실행시 checkstyle을 적용합니다. --- build.gradle | 13 +- tool/naver-checkstyle-rules.xml | 439 +++++++++++++++++++++++++ tool/naver-checkstyle-suppressions.xml | 7 + 3 files changed, 458 insertions(+), 1 deletion(-) create mode 100644 tool/naver-checkstyle-rules.xml create mode 100644 tool/naver-checkstyle-suppressions.xml diff --git a/build.gradle b/build.gradle index 24111873..fc268de2 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.3.1' id 'io.spring.dependency-management' version '1.1.5' + id 'checkstyle' } group = 'taco' @@ -38,6 +39,16 @@ dependencies { testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } -tasks.named('test') { +checkstyle { + maxWarnings = 0 + toolVersion = '9.3' + configFile = file("${rootDir}/tool/naver-checkstyle-rules.xml") + configProperties = ["suppressionFile": "${rootDir}/tool/naver-checkstyle-suppressions.xml"] + +} + +test { useJUnitPlatform() + dependsOn 'checkstyleMain' + dependsOn 'checkstyleTest' } diff --git a/tool/naver-checkstyle-rules.xml b/tool/naver-checkstyle-rules.xml new file mode 100644 index 00000000..0b410a21 --- /dev/null +++ b/tool/naver-checkstyle-rules.xml @@ -0,0 +1,439 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tool/naver-checkstyle-suppressions.xml b/tool/naver-checkstyle-suppressions.xml new file mode 100644 index 00000000..3f11e0cd --- /dev/null +++ b/tool/naver-checkstyle-suppressions.xml @@ -0,0 +1,7 @@ + + + + + From 5ddd8812060e2d27f944a1afa87048b13d2fe8f7 Mon Sep 17 00:00:00 2001 From: idealflower-k Date: Sat, 20 Jul 2024 15:08:59 +0900 Subject: [PATCH 2/2] KL-99/style: modify checkstyle error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - checkstyle에서 발생한 오류를 수정했습니다. --- .../java/taco/klkl/global/config/swagger/SwaggerConfig.java | 4 ++-- src/main/java/taco/klkl/global/error/ErrorResponse.java | 2 +- .../taco/klkl/global/error/exception/CustomException.java | 2 +- .../java/taco/klkl/global/response/GlobalResponseAdvice.java | 2 +- .../taco/klkl/global/error/GlobalExceptionHandlerTest.java | 4 ++-- .../taco/klkl/global/response/GlobalResponseAdviceTest.java | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/taco/klkl/global/config/swagger/SwaggerConfig.java b/src/main/java/taco/klkl/global/config/swagger/SwaggerConfig.java index 4674ef3c..c709d9d6 100644 --- a/src/main/java/taco/klkl/global/config/swagger/SwaggerConfig.java +++ b/src/main/java/taco/klkl/global/config/swagger/SwaggerConfig.java @@ -16,7 +16,7 @@ @Configuration public class SwaggerConfig { @Bean - public GroupedOpenApi KlklOpenApi() { + public GroupedOpenApi klklOpenApi() { // "/v1/**" 경로에 매칭되는 API를 그룹화하여 문서화한다. String[] paths = {"/v1/**"}; @@ -25,4 +25,4 @@ public GroupedOpenApi KlklOpenApi() { .pathsToMatch(paths) // 그룹에 속하는 경로 패턴을 지정한다. .build(); } -} \ No newline at end of file +} diff --git a/src/main/java/taco/klkl/global/error/ErrorResponse.java b/src/main/java/taco/klkl/global/error/ErrorResponse.java index 291e0b20..99114812 100644 --- a/src/main/java/taco/klkl/global/error/ErrorResponse.java +++ b/src/main/java/taco/klkl/global/error/ErrorResponse.java @@ -4,4 +4,4 @@ public record ErrorResponse(String code, String message) { public static ErrorResponse of(String code, String message) { return new ErrorResponse(code, message); } -} \ No newline at end of file +} diff --git a/src/main/java/taco/klkl/global/error/exception/CustomException.java b/src/main/java/taco/klkl/global/error/exception/CustomException.java index 05b74ca7..e0905659 100644 --- a/src/main/java/taco/klkl/global/error/exception/CustomException.java +++ b/src/main/java/taco/klkl/global/error/exception/CustomException.java @@ -10,4 +10,4 @@ public CustomException(ErrorCode errorCode) { super(errorCode.getMessage()); this.errorCode = errorCode; } -} \ No newline at end of file +} diff --git a/src/main/java/taco/klkl/global/response/GlobalResponseAdvice.java b/src/main/java/taco/klkl/global/response/GlobalResponseAdvice.java index e55ec6d0..546296a6 100644 --- a/src/main/java/taco/klkl/global/response/GlobalResponseAdvice.java +++ b/src/main/java/taco/klkl/global/response/GlobalResponseAdvice.java @@ -44,4 +44,4 @@ public Object beforeBodyWrite( } return body; } -} \ No newline at end of file +} diff --git a/src/test/java/taco/klkl/global/error/GlobalExceptionHandlerTest.java b/src/test/java/taco/klkl/global/error/GlobalExceptionHandlerTest.java index 71ef8249..de88c144 100644 --- a/src/test/java/taco/klkl/global/error/GlobalExceptionHandlerTest.java +++ b/src/test/java/taco/klkl/global/error/GlobalExceptionHandlerTest.java @@ -76,7 +76,7 @@ void httpRequestMethodNotSupportedOccurred() { @Test @DisplayName("ExceptionInternal이 발생한 경우") - void ExceptionInternalOccurred() { + void exceptionInternalOccurred() { // given Exception exception = new RuntimeException("Test exception"); HttpHeaders headers = new HttpHeaders(); @@ -136,4 +136,4 @@ void handleException() { assertEquals("C012", errorResponse.code()); assertEquals("서버에 문제가 발생했습니다. 관리자에게 문의해주세요.", errorResponse.message()); } -} \ No newline at end of file +} diff --git a/src/test/java/taco/klkl/global/response/GlobalResponseAdviceTest.java b/src/test/java/taco/klkl/global/response/GlobalResponseAdviceTest.java index 90f368c4..2f733a63 100644 --- a/src/test/java/taco/klkl/global/response/GlobalResponseAdviceTest.java +++ b/src/test/java/taco/klkl/global/response/GlobalResponseAdviceTest.java @@ -102,4 +102,4 @@ void testBeforeBodyWrite_WithNullHttpStatus() { // Then assertEquals(body, result); } -} \ No newline at end of file +}