260616_22_진미#57
Conversation
|
Warning Review limit reached
More reviews will be available in 31 minutes and 28 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
Changes게임 클래스 계층 및 테스트 구현
TIL 학습 문서 업데이트
🎯 2 (Simple) | ⏱️ ~10 minutes🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 5
🤖 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 `@game/game.puml`:
- Line 4: The PlantUML class inheritance syntax has a typo in the SuperHero
class definition where `exdends` should be `extends`. Correct the spelling of
the keyword from `exdends` to `extends` in the class SuperHero declaration to
ensure the inheritance relationship between SuperHero and Hero is properly
parsed by PlantUML.
In `@game/src/main/java/com/survivalcoding/Hero.java`:
- Around line 14-16: The setHp method in the Hero class lacks lower bound
validation, allowing negative HP values that can cause incorrect battle logic
(negative damage becomes healing). Modify the setHp method to validate and clamp
the HP parameter to a minimum value of 0 before assigning it to the instance
variable, or throw an exception if negative values are provided. This ensures HP
state integrity and prevents reversed damage calculations.
In `@game/src/test/java/com/survivalcoding/PoisonSlimeTest.java`:
- Around line 8-15: The attack() test method currently only contains print
statements with no assertions, which means the test will pass regardless of
whether the attack logic works correctly. Add an explicit assertion using
assertEquals to verify the Hero's HP value after the PoisonSlime attacks it.
Based on the comment context, verify that the Hero's HP becomes 72 after being
attacked by the PoisonSlime (starting from 100 HP). Place this assertion after
calling ps.attack(h) and before or instead of the print statements to ensure the
test actually validates the expected behavior.
In `@TIL/sample/2026-06-15-정리.md`:
- Around line 43-46: The constructor overload examples in both TIL documents do
not match the actual Hero.java implementation. In TIL/sample/2026-06-15-정리.md
(lines 43-46), update the Hero constructor examples to reflect the actual
implementation which only includes Hero(int hp), rather than the fictional
Hero(), Hero(String name), and Hero(String name, int hp) constructors. In
TIL/sample/2026-06-16-정리.md (lines 14-17), make the same correction to align
with the actual Hero.java code, or alternatively replace both examples with a
generic constructor overload pattern that is not tied to the actual codebase
implementation to avoid confusion about what exists in the repository.
In `@TIL/sample/2026-06-16-정리.md`:
- Around line 36-44: The instance creation statement Hero hero = new Hero("홍길동",
100); is written at the top level of the class body, which is invalid Java
syntax. Move this instantiation code inside a method (such as a main method)
where executable statements are allowed, or separate it into a different code
example that shows usage outside the class definition. This will ensure the code
sample is syntactically valid and properly demonstrates both the class
definition and its instantiation.
🪄 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: cad2ab24-1d15-42c3-a475-c76647028d76
📒 Files selected for processing (9)
TIL/sample/2026-06-15-정리.mdTIL/sample/2026-06-16-정리.mdgame/game.pumlgame/src/main/java/com/survivalcoding/Hero.javagame/src/main/java/com/survivalcoding/PersonPerson.javagame/src/main/java/com/survivalcoding/PoisonSlime.javagame/src/main/java/com/survivalcoding/Slime.javagame/src/main/java/com/survivalcoding/all.javagame/src/test/java/com/survivalcoding/PoisonSlimeTest.java
💤 Files with no reviewable changes (1)
- game/src/main/java/com/survivalcoding/all.java
| @startuml | ||
| scale 3 | ||
|
|
||
| class SuperHero exdends Hero{ |
There was a problem hiding this comment.
extends 키워드 오타로 다이어그램이 깨집니다.
Line 4의 exdends는 extends로 수정해야 PlantUML 상속 관계가 정상 파싱됩니다.
🤖 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 `@game/game.puml` at line 4, The PlantUML class inheritance syntax has a typo
in the SuperHero class definition where `exdends` should be `extends`. Correct
the spelling of the keyword from `exdends` to `extends` in the class SuperHero
declaration to ensure the inheritance relationship between SuperHero and Hero is
properly parsed by PlantUML.
| public void setHp(int hp) { | ||
| this.hp = hp; | ||
| } |
There was a problem hiding this comment.
HP 하한 검증이 없어 전투 로직이 역전될 수 있습니다.
Line 14-16에서 음수 HP를 허용하면, 이후 독 데미지 계산에서 음수 데미지가 발생해 실제로 HP가 증가할 수 있습니다. setHp에서 최소 0으로 clamp(또는 예외 처리)해 상태 무결성을 고정해 주세요.
🤖 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 `@game/src/main/java/com/survivalcoding/Hero.java` around lines 14 - 16, The
setHp method in the Hero class lacks lower bound validation, allowing negative
HP values that can cause incorrect battle logic (negative damage becomes
healing). Modify the setHp method to validate and clamp the HP parameter to a
minimum value of 0 before assigning it to the instance variable, or throw an
exception if negative values are provided. This ensures HP state integrity and
prevents reversed damage calculations.
| [생성자 오버로드] :: 하나의 생성자 + 타입이 다른 여러 방법의 정의 형태 | ||
| Hero() {} | ||
| Hero(String name) {} | ||
| Hero(String name, int hp) {} |
There was a problem hiding this comment.
생성자 오버로드 예시가 실제 저장소 코드와 불일치합니다.
두 TIL 문서(2026-06-15, 2026-06-16)의 생성자 오버로드 예시는 모두 동일한 근본 원인으로 인한 문제입니다. 제시된 Hero() / Hero(String name) / Hero(String name, int hp) 예시는 현재 저장소의 Hero.java에 존재하지 않으며, 실제 구현은 Hero(int hp) 생성자만 가지고 있습니다. 학습 자료로서 정확성이 중요하므로 두 문서를 모두 수정해 주세요.
TIL/sample/2026-06-15-정리.md#L43-L46: 생성자 오버로드 예시를 실제 Hero.java와 일치하도록 수정TIL/sample/2026-06-16-정리.md#L14-L17: 동일하게 예시를 실제 코드와 일치하도록 수정, 또는 더 일반적인 생성자 오버로드 설명으로 변경
📍 Affects 2 files
TIL/sample/2026-06-15-정리.md#L43-L46(this comment)TIL/sample/2026-06-16-정리.md#L14-L17
🤖 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-15-정리.md` around lines 43 - 46, The constructor overload
examples in both TIL documents do not match the actual Hero.java implementation.
In TIL/sample/2026-06-15-정리.md (lines 43-46), update the Hero constructor
examples to reflect the actual implementation which only includes Hero(int hp),
rather than the fictional Hero(), Hero(String name), and Hero(String name, int
hp) constructors. In TIL/sample/2026-06-16-정리.md (lines 14-17), make the same
correction to align with the actual Hero.java code, or alternatively replace
both examples with a generic constructor overload pattern that is not tied to
the actual codebase implementation to avoid confusion about what exists in the
repository.
| public class Hero { // ← ①클래스 | ||
| private String name; | ||
| private int hp; | ||
| public Hero(String name, int hp) { // ← ②생성자 | ||
| this.name = name; | ||
| this.hp = hp; | ||
| } | ||
| Hero hero = new Hero("홍길동", 100); // ← ③인스턴스 | ||
| } |
There was a problem hiding this comment.
코드 샘플이 문법적으로 유효하지 않습니다.
라인 43의 Hero hero = new Hero("홍길동", 100);는 클래스 본체의 최상위 수준에서 직접 statement를 작성한 것으로, Java 컴파일 오류가 발생합니다. 클래스 변수 선언이나 메소드 내부에서만 인스턴스화 코드가 유효합니다.
🔧 권장 수정안
옵션 1: main 메소드 내부로 이동 (추천)
public class Hero {
private String name;
private int hp;
public Hero(String name, int hp) {
this.name = name;
this.hp = hp;
}
- Hero hero = new Hero("홍길동", 100);
+ public static void main(String[] args) {
+ Hero hero = new Hero("홍길동", 100);
+ }
}옵션 2: 설명 텍스트로 변경
- Hero hero = new Hero("홍길동", 100);
+ // 인스턴스 생성 예시:
+ // Hero hero = new Hero("홍길동", 100);옵션 3: 인스턴스 생성을 별도 섹션으로 분리
코드 샘플을 클래스 정의 부분과 사용 부분으로 명확히 분리하면 혼동을 줄일 수 있습니다.
🤖 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-16-정리.md` around lines 36 - 44, The instance creation
statement Hero hero = new Hero("홍길동", 100); is written at the top level of the
class body, which is invalid Java syntax. Move this instantiation code inside a
method (such as a main method) where executable statements are allowed, or
separate it into a different code example that shows usage outside the class
definition. This will ensure the code sample is syntactically valid and properly
demonstrates both the class definition and its instantiation.
|
test 코드 작성할때 println 말고 assertXXX 함수를 사용해야 합니다 |
[수정내용] PoisonSlimeTest 의 println을 assertEquals72, h.getHp());로
260616_22_진미
📝 과제 정보
📋 체크리스트
📷 실행 결과 (또는 테스트 결과)
❓질문 및 어려웠던 점
🔄 자체 평가 & 회고