260630_13_김진용#94
Conversation
|
Warning Review limit reached
Next review available in: 13 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughGradle 멀티프로젝트에 Changespost-oop 모듈 신규 추가
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
post-oop/src/test/java/com/survivalcoding/BookTest.java (1)
36-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win정렬 테스트에 동률/
null날짜 케이스를 추가해 주세요.지금 테스트는 날짜가 서로 다른 경우만 검증해서,
Book.compareTo()가 같은 날짜의 다른 책을0으로 처리하는 버그를 잡지 못합니다. 같은publishDate+ 다른title, 그리고publishDate == null케이스를 하나씩 추가해 두는 편이 안전합니다.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@post-oop/src/test/java/com/survivalcoding/BookTest.java` around lines 36 - 57, The Book.compareTo() test only covers different publishDate values, so it misses tie and null-handling behavior. Extend BookTest.compareTo() to add one case where two Book instances share the same publishDate but have different titles and verify the ordering/comparison is not collapsed to 0, and another case where publishDate is null to confirm the method handles null dates safely; use the existing compareTo() test and Book setup patterns to locate and expand the assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@post-oop/src/main/java/com/survivalcoding/Book.java`:
- Around line 66-70: `Book.compareTo()`가 `equals()`와 일치하지 않아 같은 `publishDate`이거나
`null`일 때 모두 0을 반환합니다. `compareTo(Book other)`에서 `publishDate`만으로 동등 처리하지 말고,
`publishDate`가 같거나 둘 다 null인 경우에는 `title`이나 식별자 같은 다른 필드로 2차 비교를 추가해 서로 다른
`Book`이 0으로 묶이지 않도록 수정하세요. `Book` 클래스의 `compareTo()`, `equals()`, `publishDate`
처리 로직이 일관되게 정렬되도록 맞추면 됩니다.
In `@TIL/sample/2026-06-30-인스턴스기본조작.md`:
- Around line 54-67: 복사 설명과 `clone()` 예제가 서로 다른 수준의 복사를 설명하고 있습니다. `clone()`이
`publishDate`를 새 `Date`로 복제하는 현재 동작에 맞게 문서의 “얕은 복사” 설명을 수정하거나, 반대로 예제를 완전한 얕은
복사로 바꿔서 `clone()`과 설명이 일치하도록 정리하세요. `clone()`과 “얕은 복사/깊은 복사” 섹션이 같은 의미를 가리키도록
맞추면 됩니다.
---
Nitpick comments:
In `@post-oop/src/test/java/com/survivalcoding/BookTest.java`:
- Around line 36-57: The Book.compareTo() test only covers different publishDate
values, so it misses tie and null-handling behavior. Extend BookTest.compareTo()
to add one case where two Book instances share the same publishDate but have
different titles and verify the ordering/comparison is not collapsed to 0, and
another case where publishDate is null to confirm the method handles null dates
safely; use the existing compareTo() test and Book setup patterns to locate and
expand the assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 287a7e81-2580-4ab5-bbdc-f144fd6fe6e7
📒 Files selected for processing (7)
TIL/sample/2026-06-30-인스턴스기본조작.mdpost-oop/06_30.pumlpost-oop/build.gradlepost-oop/src/main/java/com/survivalcoding/Book.javapost-oop/src/main/java/com/survivalcoding/Main.javapost-oop/src/test/java/com/survivalcoding/BookTest.javasettings.gradle
| public int compareTo(Book other) { | ||
| if (this.publishDate == null || other.publishDate == null) { | ||
| return 0; | ||
| } | ||
| return other.publishDate.compareTo(this.publishDate); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
compareTo()가 현재 equals()와 충돌합니다.
같은 publishDate를 가진 서로 다른 책이거나, 둘 중 하나의 날짜가 null인 경우에도 0을 반환해서 서로 다른 객체가 같은 정렬 키로 취급됩니다. 이 상태로 TreeSet/TreeMap에 넣으면 데이터가 누락될 수 있습니다.
수정 예시
`@Override`
public int compareTo(Book other) {
- if (this.publishDate == null || other.publishDate == null) {
- return 0;
- }
- return other.publishDate.compareTo(this.publishDate);
+ int byPublishDate = java.util.Comparator
+ .nullsLast(java.util.Comparator.<Date>reverseOrder())
+ .compare(this.publishDate, other.publishDate);
+ if (byPublishDate != 0) {
+ return byPublishDate;
+ }
+ return java.util.Comparator
+ .nullsFirst(String::compareTo)
+ .compare(this.title, other.title);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public int compareTo(Book other) { | |
| if (this.publishDate == null || other.publishDate == null) { | |
| return 0; | |
| } | |
| return other.publishDate.compareTo(this.publishDate); | |
| public int compareTo(Book other) { | |
| int byPublishDate = java.util.Comparator | |
| .nullsLast(java.util.Comparator.<Date>reverseOrder()) | |
| .compare(this.publishDate, other.publishDate); | |
| if (byPublishDate != 0) { | |
| return byPublishDate; | |
| } | |
| return java.util.Comparator | |
| .nullsFirst(String::compareTo) | |
| .compare(this.title, other.title); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@post-oop/src/main/java/com/survivalcoding/Book.java` around lines 66 - 70,
`Book.compareTo()`가 `equals()`와 일치하지 않아 같은 `publishDate`이거나 `null`일 때 모두 0을
반환합니다. `compareTo(Book other)`에서 `publishDate`만으로 동등 처리하지 말고, `publishDate`가 같거나
둘 다 null인 경우에는 `title`이나 식별자 같은 다른 필드로 2차 비교를 추가해 서로 다른 `Book`이 0으로 묶이지 않도록
수정하세요. `Book` 클래스의 `compareTo()`, `equals()`, `publishDate` 처리 로직이 일관되게 정렬되도록
맞추면 됩니다.
| ### 복사를 지원하기 위해 다음 메서드를 작성한다. | ||
|
|
||
| - Cloneable 인터페이스를 구현하여 얕은 복사를 구현하기로 한다 | ||
|
|
||
| ### 얕은 복사 | ||
|
|
||
| - 객체 자체는 새로 생성되지만, 객체 내의 참조 타입 필드(다른 객체에 대한 참조)는 원본과 동일한 객체를 참조합니다. | ||
| - 즉, 중첩된 객체는 복사되지 않고 주소만 복사됩니다. | ||
| - 원본 객체의 참조 타입 필드를 변경하면 복사본의 해당 필드도 함께 변경됩니다. | ||
|
|
||
| ### 깊은 복사 | ||
|
|
||
| - 객체 자체뿐만 아니라, 객체 내의 모든 참조 타입 필드(중첩된 객체들)까지도 재귀적으로 완전히 새로 생성하여 복사합니다. | ||
| - 원본 객체와 복사본 객체는 완전히 독립적입니다. 한쪽을 변경해도 다른 쪽에는 영향을 주지 않습니다. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
복사 설명이 현재 구현과 맞지 않습니다.
Line 56은 “얕은 복사”라고 적혀 있지만, 아래 코드의 clone()은 publishDate를 별도 Date로 복제해서 부분적인 깊은 복사를 하고 있습니다. TIL 내용과 예제 코드가 서로 다르게 읽히니 한쪽으로 맞춰 주세요.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@TIL/sample/2026-06-30-인스턴스기본조작.md` around lines 54 - 67, 복사 설명과 `clone()` 예제가
서로 다른 수준의 복사를 설명하고 있습니다. `clone()`이 `publishDate`를 새 `Date`로 복제하는 현재 동작에 맞게 문서의
“얕은 복사” 설명을 수정하거나, 반대로 예제를 완전한 얕은 복사로 바꿔서 `clone()`과 설명이 일치하도록 정리하세요. `clone()`과
“얕은 복사/깊은 복사” 섹션이 같은 의미를 가리키도록 맞추면 됩니다.
260630_13_김진용
📝 과제 정보
📋 체크리스트
📷 실행 결과 (또는 테스트 결과)
❓질문 및 어려웠던 점
복사랑 정렬이 어려웠다
🔄 자체 평가 & 회고