-
Notifications
You must be signed in to change notification settings - Fork 3
Style/code review #152
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
Style/code review #152
Conversation
|
""" WalkthroughRedis 스트림 컨슈머의 이름이 호스트명 기반으로 변경되고, 관련 메서드가 UnknownHostException을 던지도록 수정되었습니다. Redis 메시지 소비자에서 6초 대기 코드가 제거되었습니다. OpenAI 프롬프트 및 응답 검증 로직이 포맷과 키워드에 따라 세분화되었습니다. 코드 제출 HTML에 AI 리뷰 요청 기능이 추가되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant Server
participant OpenAI
User->>Browser: 코드 제출
Browser->>Server: 코드 제출 요청
Server-->>Browser: 채점 결과 반환
Browser->>User: 결과 표시, 리뷰 버튼 활성화
User->>Browser: "리뷰 요청 (AI)" 클릭
Browser->>Server: 리뷰 요청 (문제ID, 언어, 코드, 정오답 여부)
Server->>OpenAI: 프롬프트 생성 및 요청
OpenAI-->>Server: AI 리뷰 응답
Server-->>Browser: AI 리뷰 반환
Browser->>User: 리뷰 박스에 결과 표시
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
""" 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
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: 2
🧹 Nitpick comments (1)
src/main/resources/templates/test-submit.html (1)
549-549: 불필요한 빈 줄 제거파일 끝에 불필요한 빈 줄이 있습니다.
-
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/main/java/org/ezcode/codetest/infrastructure/event/config/RedisStreamConfig.java(3 hunks)src/main/java/org/ezcode/codetest/infrastructure/event/listener/RedisJudgeQueueConsumer.java(0 hunks)src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIMessageBuilder.java(2 hunks)src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIResponseValidator.java(1 hunks)src/main/resources/templates/test-submit.html(5 hunks)
💤 Files with no reviewable changes (1)
- src/main/java/org/ezcode/codetest/infrastructure/event/listener/RedisJudgeQueueConsumer.java
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/aop/CodeReviewLockAspect.java:25-41
Timestamp: 2025-06-19T06:37:57.845Z
Learning: User thezz9 tends to skip validation for scenarios they consider unlikely to occur, but is willing to implement defensive programming practices when suggested for code robustness.
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:93-96
Timestamp: 2025-06-28T02:04:24.957Z
Learning: User thezz9 sometimes temporarily uses less secure or inconsistent exception handling (like RuntimeException with raw error bodies) for debugging purposes when error messages are being hidden in the normal application flow, but acknowledges this as technical debt and fixes it once debugging is complete.
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:159-165
Timestamp: 2025-06-28T02:03:38.693Z
Learning: User thezz9's service (ezcode) targets Korean users exclusively ("찐 한국인밖에 안 옴"), so Korean language hardcoding in commit messages and UI elements is intentional and appropriate for their use case.
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:142-147
Timestamp: 2025-06-19T07:00:53.895Z
Learning: SubmissionService.getCodeReview() 메서드에서 토큰 차감을 리뷰 요청 전에 수행하는 이유: OpenAI 서버 장애보다 유저 토큰 부족 상황이 더 빈번하므로, 확률이 높은 실패 케이스를 먼저 체크하여 불필요한 처리를 방지함. OpenAI 서버 장애 시에는 OpenAIClient에서 트랜잭션 롤백으로 토큰 복원이 처리됨.
Learnt from: thezz9
PR: ezcode-my/backend#132
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubContentBuilder.java:72-72
Timestamp: 2025-07-02T09:39:31.475Z
Learning: User thezz9 prefers to proceed with breaking changes to path structures when it improves the organization, rather than maintaining backward compatibility or implementing migration strategies.
src/main/resources/templates/test-submit.html (1)
Learnt from: thezz9
PR: ezcode-my/backend#73
File: src/main/resources/templates/submit-test.html:135-135
Timestamp: 2025-06-18T11:41:58.457Z
Learning: src/main/resources/templates/submit-test.html 파일은 테스트용 파일로, isCorrect 값의 하드코딩은 의도적이며 사용자가 UI 요소를 통해 정답/오답 상태를 선택할 수 있도록 개선 예정입니다.
src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIMessageBuilder.java (1)
Learnt from: thezz9
PR: ezcode-my/backend#73
File: src/main/resources/templates/submit-test.html:135-135
Timestamp: 2025-06-18T11:41:58.457Z
Learning: src/main/resources/templates/submit-test.html 파일은 테스트용 파일로, isCorrect 값의 하드코딩은 의도적이며 사용자가 UI 요소를 통해 정답/오답 상태를 선택할 수 있도록 개선 예정입니다.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (11)
src/main/java/org/ezcode/codetest/infrastructure/event/config/RedisStreamConfig.java (2)
3-4: 필요한 import 추가 완료호스트명 기반 컨슈머 이름 생성을 위한 import가 적절히 추가되었습니다.
81-81: 예외 처리 선언 적절함
InetAddress.getLocalHost()가UnknownHostException을 던질 수 있으므로 메서드 시그니처에 예외 선언을 추가한 것이 올바릅니다.src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIResponseValidator.java (2)
11-21: 오답 검증 로직 구현 잘 되었습니다isCorrect가 false일 때 필수 섹션 존재 확인과 금지 섹션 배제 로직이 명확하게 구현되어 있습니다. 비즈니스 로직에 맞게 올바르게 작성되었습니다.
23-25: 정답 검증 로직 구현 적절합니다정답일 때 필요한 세 가지 섹션(시간 복잡도, 코드 총평, 개선 방안)을 모두 확인하는 로직이 간결하고 명확합니다.
src/main/resources/templates/test-submit.html (3)
124-141: CSS 스타일링 구현 적절합니다비활성화된 버튼과 리뷰 박스의 스타일링이 기존 다크 테마와 일관성 있게 구현되었습니다. 특히 리뷰 박스의 강조 텍스트에 브랜드 컬러(#00d084)를 사용한 것이 좋습니다.
309-309: AI 리뷰 버튼 통합 잘 되었습니다기존 제출 버튼과 나란히 배치되어 있고, 초기 비활성화 상태가 적절합니다. 사용자 경험이 직관적입니다.
521-547: 리뷰 요청 함수 구현 훌륭합니다에러 핸들링, 마크다운 파싱, 그리고 응답 표시 로직이 잘 구현되어 있습니다. 특히 마크다운 전처리 부분(줄바꿈 처리, 리스트 형식 정리)이 세심하게 작성되었습니다.
src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIMessageBuilder.java (4)
12-12: 모델명 수정 적절합니다"o4-mini"에서 "gpt-4o"로 변경된 것은 올바른 OpenAI 모델명으로의 수정으로 보입니다. 이전 모델명은 유효하지 않은 것 같습니다.
17-19: 프롬프트 제약 조건 명확하게 추가됨형식 준수 경고와 오답 시 시간 복잡도 항목 금지 규칙이 명확하게 명시되어 있습니다. 이는 OpenAIResponseValidator의 검증 로직과 일치합니다.
68-81: 정답 프롬프트 형식 개선되었습니다시간 복잡도 설명이 더 구체적이고 명확해졌으며, 각 섹션의 형식 규칙이 상세하게 정의되어 있습니다. 특히 "N과 M을 같다고 가정하고 n으로 표기" 부분이 유용합니다.
84-100: 오답 프롬프트 형식 잘 구성됨오답 시 시간 복잡도 관련 내용을 명시적으로 금지하는 지시사항이 효과적으로 추가되었습니다. 새로운 섹션 구조도 적절합니다.
src/main/java/org/ezcode/codetest/infrastructure/event/config/RedisStreamConfig.java
Outdated
Show resolved
Hide resolved
| boolean containsForbidden = content.contains("**시간 복잡도**:") || | ||
| content.toLowerCase().contains("**시간복잡도:**"); |
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
금지 콘텐츠 검증 로직 개선 필요
toLowerCase() 처리 후 볼드 마크다운 패턴 **시간복잡도:**을 검사하는 것은 실제 응답에서 나타날 수 있는 다양한 형태를 놓칠 수 있습니다.
다음과 같이 개선하는 것을 권장합니다:
- boolean containsForbidden = content.contains("**시간 복잡도**:") ||
- content.toLowerCase().contains("**시간복잡도:**");
+ boolean containsForbidden = content.contains("**시간 복잡도**:") ||
+ content.toLowerCase().contains("시간복잡도") ||
+ content.toLowerCase().contains("시간 복잡도");🤖 Prompt for AI Agents
In
src/main/java/org/ezcode/codetest/infrastructure/openai/OpenAIResponseValidator.java
around lines 17 to 18, the current check for forbidden content uses
toLowerCase() combined with a fixed bold markdown pattern, which may miss
variations in the actual response. To fix this, replace the exact string match
with a case-insensitive regular expression that matches the phrase "시간 복잡도" or
"시간복잡도" with or without bold markdown, allowing for flexible spacing and
formatting variations.
Summary by CodeRabbit
신규 기능
버그 수정
개선 사항