-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 출결번호가 네 자리 수가 되도록 String 타입으로 수정 #858
Conversation
개요Walkthrough이 풀 리퀘스트는 출석 번호 생성 및 관리 로직을 정수(int)에서 문자열(String) 타입으로 변경하는 작업을 포함합니다. 주요 변경 사항은 Changes
연결된 이슈에 대한 평가
가능성 있는 관련 PR
제안된 라벨
제안된 리뷰어
토끼의 시
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Job Summary for GradleCheck Style and Test to Develop :: build-test
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudySessionV2.java (1)
출석번호 유효성 검증 및 메서드 반환 타입 수정이 필요합니다.
- createEmpty 메서드에 제안된 유효성 검증 로직 추가가 필요합니다.
- 메서드가 void 대신 생성된 객체를 반환하도록 수정이 필요합니다.
수정 제안:
- public static void createEmpty(Integer position, String lessonAttendanceNumber, StudyV2 studyV2) { + public static StudySessionV2 createEmpty(Integer position, String lessonAttendanceNumber, StudyV2 studyV2) { + if (lessonAttendanceNumber == null || !lessonAttendanceNumber.matches("^\\d{4}$")) { + throw new IllegalArgumentException("출석번호는 네 자리 숫자여야 합니다"); + } - StudySessionV2.builder() + return StudySessionV2.builder() .position(position) .lessonAttendanceNumber(lessonAttendanceNumber) .studyV2(studyV2) .build(); }🔗 Analysis chain
Line range hint
95-100
: createEmpty 메서드에 유효성 검증이 필요합니다.출석번호가 null이거나 잘못된 형식일 경우를 처리하는 검증 로직이 필요합니다.
다음과 같은 검증 로직 추가를 제안합니다:
public static void createEmpty(Integer position, String lessonAttendanceNumber, StudyV2 studyV2) { + if (lessonAttendanceNumber == null || !lessonAttendanceNumber.matches("^\\d{4}$")) { + throw new IllegalArgumentException("출석번호는 네 자리 숫자여야 합니다"); + } StudySessionV2.builder() .position(position) .lessonAttendanceNumber(lessonAttendanceNumber) .studyV2(studyV2) .build(); }🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
#!/bin/bash # Search for lessonAttendanceNumber usage and validation echo "=== Searching for lessonAttendanceNumber usage ===" rg "lessonAttendanceNumber" -t java -A 2 -B 2 echo -e "\n=== Searching for validation patterns in StudySessionV2 ===" ast-grep --pattern 'if ($_ == null || !$_.matches($_)) { throw new IllegalArgumentException($_); }' echo -e "\n=== Searching for createEmpty usage ===" rg "createEmpty" -t java -A 2 -B 2Length of output: 4203
Script:
#!/bin/bash # Search for attendanceNumberGenerator implementation echo "=== Searching for AttendanceNumberGenerator ===" rg "AttendanceNumberGenerator" -t java -A 5 -B 5 echo -e "\n=== Searching for generate() method implementations ===" ast-grep --pattern 'generate() { $$$ }'Length of output: 8144
🧹 Nitpick comments (2)
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/RandomAttendanceNumberGenerator.java (1)
16-20
: 출석번호 형식을 일관되게 유지하도록 개선이 필요합니다.현재 구현은 네 자리 수를 보장하지만, 형식의 일관성을 위해 String.format을 사용하는 것이 좋습니다.
다음과 같이 수정을 제안합니다:
public String generate() { - return String.valueOf(SecureRandom.getInstanceStrong() + return String.format("%04d", SecureRandom.getInstanceStrong() .ints(MIN_ORIGIN, MAX_BOUND) .findFirst() .orElseThrow()); }src/test/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyFactoryTest.java (1)
18-21
: 테스트 케이스 보완이 필요합니다.현재는 고정된 "0000" 값만 테스트하고 있습니다. 다양한 케이스에 대한 테스트가 필요합니다.
다음과 같은 테스트 케이스 추가를 제안합니다:
@Test void 출석번호_형식이_올바른지_검증한다() { // given StudySessionV2 session = StudySessionV2.builder() .position(1) .lessonAttendanceNumber("1234") .studyV2(study) .build(); // then assertThat(session.getLessonAttendanceNumber()).matches("^\\d{4}$"); } @Test void 잘못된_출석번호_형식은_예외를_발생시킨다() { assertThatThrownBy(() -> { StudySessionV2.builder() .position(1) .lessonAttendanceNumber("123") // 3자리 숫자 .studyV2(study) .build(); }).isInstanceOf(IllegalArgumentException.class); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/AttendanceNumberGenerator.java
(1 hunks)src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/RandomAttendanceNumberGenerator.java
(1 hunks)src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/StudySessionV2.java
(3 hunks)src/test/java/com/gdschongik/gdsc/domain/studyv2/domain/StudyFactoryTest.java
(2 hunks)
🔇 Additional comments (1)
src/main/java/com/gdschongik/gdsc/domain/studyv2/domain/AttendanceNumberGenerator.java (1)
4-4
: 반환 타입 변경이 적절합니다.출석번호를 네 자리 수로 표현하기 위한 String 타입으로의 변경이 적절합니다.
@@ -42,7 +42,7 @@ public class StudySessionV2 extends BaseEntity { | |||
// 수업 관련 필드 | |||
|
|||
@Comment("수업 출석 번호") | |||
private Integer lessonAttendanceNumber; | |||
private String lessonAttendanceNumber; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
출석번호 유효성 검증이 필요합니다.
출석번호가 항상 네 자리 문자열 형식을 유지하도록 유효성 검증이 필요합니다.
다음과 같은 검증 로직 추가를 제안합니다:
@Pattern(regexp = "^\\d{4}$", message = "출석번호는 네 자리 숫자여야 합니다")
private String lessonAttendanceNumber;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
🌱 관련 이슈
📌 작업 내용 및 특이사항
📝 참고사항
📚 기타
Summary by CodeRabbit