-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 닉네임 양 끝단 숫자 허용 #331
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
fix: 닉네임 양 끝단 숫자 허용 #331
Conversation
Summary of ChangesHello @yongjun0511, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 풀 리퀘스트는 닉네임 유효성 검사 로직을 개선하여 사용자가 숫자로 시작하거나 끝나는 닉네임을 설정할 수 있도록 합니다. 이는 기존의 제한을 완화하여 닉네임 생성의 유연성을 높이는 것을 목표로 합니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. 숫자도 이젠 닉네임 앞뒤에 허용 규칙이 바뀌네 Footnotes
|
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.
Code Review
닉네임의 시작과 끝에 숫자를 허용하도록 정규식을 수정한 점 좋습니다. 하지만 몇 가지 개선점이 보입니다.
가장 중요한 것은 변경 사항에 대한 테스트 코드가 누락되었다는 점입니다. PR 설명에도 테스트가 수행되지 않았다고 명시되어 있습니다. NicknameValidatorTest.java의 한글_또는_영어로_시작하지_않는_닉네임인_경우_예외가_발생한다와 한글_또는_영어로_끝나지_않는_닉네임인_경우_예외가_발생한다 테스트는 현재 로직 변경으로 인해 실패할 것입니다. 이 테스트들을 수정하고, "123test"나 "test123"과 같이 이제 유효해진 케이스에 대한 새로운 테스트를 추가하여 코드의 정확성을 보장해야 합니다.
또한, 리포지토리 스타일 가이드 13번 규칙에 따르면 테스트 메소드명은 영어로 작성해야 합니다. 현재 테스트 메소드명이 한글로 되어 있으니 이 부분도 수정하는 것을 고려해 주세요.
코드 자체에 대해서는 String.matches() 대신 미리 컴파일된 Pattern 객체를 사용하는 것이 성능과 일관성 측면에서 더 좋다는 의견을 리뷰 댓글로 남겼습니다.
| if (nickname.matches("^[^A-Za-z가-힣ㄱ-ㅎㅏ-ㅣ0-9].*")) { | ||
| throw new BaseException(BaseResponseStatus.INVALID_START_OF_NICKNAME); | ||
| } | ||
|
|
||
| // 한글 영어가 아닌 것으로 마무리 | ||
| if (nickname.matches(".*[^A-Za-z가-힣ㄱ-ㅎㅏ-ㅣ]$")) { | ||
| // 한글, 영어, 숫자가 아닌 것으로 끝남 | ||
| if (nickname.matches(".*[^A-Za-z가-힣ㄱ-ㅎㅏ-ㅣ0-9]$")) { | ||
| throw new BaseException(BaseResponseStatus.INVALID_END_OF_NICKNAME); |
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.
String.matches() 메소드는 호출될 때마다 정규 표현식을 새로 컴파일하여 성능에 부담을 줄 수 있습니다. 이 블록의 두 검증 로직 모두 PROFANITY_PATTERN처럼 private static final Pattern 상수로 미리 컴파일하여 사용하는 것을 권장합니다. 이렇게 하면 성능을 개선하고 코드의 일관성을 높일 수 있습니다.
예를 들어, 클래스 상단에 다음과 같이 패턴을 정의하고,
private static final Pattern INVALID_START_NICKNAME_PATTERN = Pattern.compile("^[^A-Za-z가-힣ㄱ-ㅎㅏ-ㅣ0-9].*");
private static final Pattern INVALID_END_NICKNAME_PATTERN = Pattern.compile(".*[^A-Za-z가-힣ㄱ-ㅎㅏ-ㅣ0-9]$");검증 로직에서는 INVALID_START_NICKNAME_PATTERN.matcher(nickname).matches() 와 같이 사용할 수 있습니다. 이 방식은 이 메소드 내의 다른 모든 String.matches() 호출에도 적용하면 더욱 좋습니다.
#️⃣ Issue Number
📝 요약(Summary)
💬 공유사항 to 리뷰어
✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.