Conversation
설명여러 파일에서 임포트 순서 정렬 및 코드 형식을 개선하고, 세션 참석 정책 처리 방식을 리팩토링하여 변경 사항
예상 코드 리뷰 시간🎯 2 (Simple) | ⏱️ ~12분 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can approve the review once all CodeRabbit's comments are resolved.Enable the |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
application/src/main/kotlin/core/application/session/application/service/SessionQueryService.kt (1)
55-59: 정책 조회 로직 중복을 합치면 유지보수성이 좋아집니다.
getAttendancePolicy가getCurrentPolicy와 동일한 조회/예외 처리를 반복하고 있어, 한쪽만 수정되는 드리프트 위험이 있습니다.♻️ 제안 수정안
fun getAttendancePolicy(sessionId: SessionId): AttendancePolicy = - sessionPersistencePort - .findSessionById(sessionId.value) - ?.attendancePolicy - ?: throw SessionNotFoundException() + getCurrentPolicy(sessionId.value)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@application/src/main/kotlin/core/application/session/application/service/SessionQueryService.kt` around lines 55 - 59, getAttendancePolicy duplicates the session lookup and exception handling already implemented by getCurrentPolicy; refactor by delegating to the existing getCurrentPolicy (or extract a shared private helper like findSessionOrThrow that calls sessionPersistencePort.findSessionById and throws SessionNotFoundException) and return its attendancePolicy, ensuring you reference getAttendancePolicy, getCurrentPolicy, sessionPersistencePort.findSessionById, SessionNotFoundException and attendancePolicy so the lookup/exception logic is centralized and not duplicated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@domain/src/main/kotlin/core/domain/session/aggregate/Session.kt`:
- Around line 67-69: The attendance-time ordering (attendanceStart < lateStart <
absentStart) is not being validated, so malformed AttendancePolicy values can
invert status decisions; update the code that consumes or constructs
attendancePolicy (e.g., the Session aggregate constructor/factory or the method
using attendancePolicy in Session.kt where
now.isBefore(attendancePolicy.lateStart) is evaluated) to validate the invariant
and fail fast: verify attendancePolicy.attendanceStart <
attendancePolicy.lateStart && attendancePolicy.lateStart <
attendancePolicy.absentStart and either throw a clear domain error / return a
failure result before performing the
AttendanceResult.Success(AttendanceStatus...) logic, or normalize/reject
incoming policy updates to ensure the invariant always holds.
---
Nitpick comments:
In
`@application/src/main/kotlin/core/application/session/application/service/SessionQueryService.kt`:
- Around line 55-59: getAttendancePolicy duplicates the session lookup and
exception handling already implemented by getCurrentPolicy; refactor by
delegating to the existing getCurrentPolicy (or extract a shared private helper
like findSessionOrThrow that calls sessionPersistencePort.findSessionById and
throws SessionNotFoundException) and return its attendancePolicy, ensuring you
reference getAttendancePolicy, getCurrentPolicy,
sessionPersistencePort.findSessionById, SessionNotFoundException and
attendancePolicy so the lookup/exception logic is centralized and not
duplicated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 14b173fd-eca8-4270-9085-229d82603370
📒 Files selected for processing (11)
application/src/main/kotlin/core/application/afterParty/application/service/AfterPartyCommandService.ktapplication/src/main/kotlin/core/application/member/application/service/MemberQueryService.ktapplication/src/main/kotlin/core/application/member/presentation/controller/MemberApi.ktapplication/src/main/kotlin/core/application/session/application/service/SessionQueryService.ktapplication/src/main/kotlin/core/application/session/presentation/controller/SessionQueryController.ktapplication/src/main/kotlin/core/application/session/presentation/mapper/SessionMapper.ktapplication/src/main/kotlin/core/application/session/presentation/response/AttendanceTimeResponse.ktdomain/src/main/kotlin/core/domain/member/port/outbound/MemberPersistencePort.ktdomain/src/main/kotlin/core/domain/session/aggregate/Session.ktdomain/src/main/kotlin/core/domain/session/event/SessionCreateEvent.ktpersistence/src/main/kotlin/core/persistence/member/repository/MemberRepository.kt
| now.isBefore(attendancePolicy.lateStart) -> AttendanceResult.Success(AttendanceStatus.PRESENT) | ||
| now.isBefore(attendancePolicy.absentStart) -> AttendanceResult.Success(AttendanceStatus.LATE) | ||
| else -> AttendanceResult.Success(AttendanceStatus.ABSENT) |
There was a problem hiding this comment.
출석 정책 시간 순서 불변식 검증이 없어 상태 판정이 깨질 수 있습니다.
Line 67-69는 lateStart, absentStart를 직접 신뢰합니다.
그런데 현재 생성/수정 경로에서 attendanceStart < lateStart < absentStart 보장이 없어서, 잘못된 정책값이 들어오면 출석 상태가 역전되거나 즉시 결석 처리될 수 있습니다.
💡 제안 수정안
class Session(
@@
deletedAt: Instant? = null,
) {
+ init {
+ validateAttendancePolicy(attendancePolicy)
+ }
+
+ private fun validateAttendancePolicy(policy: AttendancePolicy) {
+ require(policy.attendanceStart.isBefore(policy.lateStart)) {
+ "attendanceStart must be before lateStart"
+ }
+ require(policy.lateStart.isBefore(policy.absentStart)) {
+ "lateStart must be before absentStart"
+ }
+ }
@@
fun updateAttendanceStartTime(newStartTime: Instant) {
- this.attendancePolicy =
- attendancePolicy.copy(
- attendanceStart = newStartTime,
- )
+ val newPolicy = attendancePolicy.copy(attendanceStart = newStartTime)
+ validateAttendancePolicy(newPolicy)
+ this.attendancePolicy = newPolicy
}
@@
fun updateSession(command: SessionUpdateCommand) {
@@
- this.attendancePolicy =
- AttendancePolicy(
- attendanceStart = command.attendanceStart,
- lateStart = command.lateStart,
- absentStart = command.absentStart,
- attendanceCode = this.attendancePolicy.attendanceCode,
- )
+ val newPolicy =
+ AttendancePolicy(
+ attendanceStart = command.attendanceStart,
+ lateStart = command.lateStart,
+ absentStart = command.absentStart,
+ attendanceCode = this.attendancePolicy.attendanceCode,
+ )
+ validateAttendancePolicy(newPolicy)
+ this.attendancePolicy = newPolicy
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@domain/src/main/kotlin/core/domain/session/aggregate/Session.kt` around lines
67 - 69, The attendance-time ordering (attendanceStart < lateStart <
absentStart) is not being validated, so malformed AttendancePolicy values can
invert status decisions; update the code that consumes or constructs
attendancePolicy (e.g., the Session aggregate constructor/factory or the method
using attendancePolicy in Session.kt where
now.isBefore(attendancePolicy.lateStart) is evaluated) to validate the invariant
and fail fast: verify attendancePolicy.attendanceStart <
attendancePolicy.lateStart && attendancePolicy.lateStart <
attendancePolicy.absentStart and either throw a clear domain error / return a
failure result before performing the
AttendanceResult.Success(AttendanceStatus...) logic, or normalize/reject
incoming policy updates to ensure the invariant always holds.
Summary
Tasks
ETC
Screenshot
Summary by CodeRabbit
릴리스 노트
개선 사항
기타