Skip to content

[REFACTOR] 사용하지 않는 import문 제거#142

Merged
parkmineum merged 2 commits intodevfrom
refactor/#129_search-code-refactor
Aug 20, 2025
Merged

[REFACTOR] 사용하지 않는 import문 제거#142
parkmineum merged 2 commits intodevfrom
refactor/#129_search-code-refactor

Conversation

@jaemin0413
Copy link
Contributor

@jaemin0413 jaemin0413 commented Aug 20, 2025

🎋 이슈 및 작업중인 브랜치

🔑 주요 내용

  • 사용하지 않는 import문만 제거했습니다.

Check List

  • Reviewers 등록을 하였나요?
  • Assignees 등록을 하였나요?
  • 라벨(Label) 등록을 하였나요?
  • PR 머지하기 전 반드시 CI가 정상적으로 작동하는지 확인해주세요!

Summary by CodeRabbit

  • Refactor
    • 미사용 의존성과 임포트를 전반적으로 정리하여 코드 경량화 및 유지보수성 개선.
    • 일부 구성의 생성자 의존성을 단순화하여 결합도 감소.
  • Style
    • 사소한 포맷팅 정리로 코드 일관성과 가독성 향상.
  • Chores
    • 빌드/분석 경고 감소를 위한 코드 청소 전반 수행.

사용자 영향: 기능 변화 없음. 앱 동작은 동일하며, 내부 품질과 안정성이 향상되었습니다.

@jaemin0413 jaemin0413 self-assigned this Aug 20, 2025
@jaemin0413 jaemin0413 added the ♻️ REFACTOR 리팩토링 관련 라벨 label Aug 20, 2025
@jaemin0413 jaemin0413 linked an issue Aug 20, 2025 that may be closed by this pull request
3 tasks
@coderabbitai
Copy link

coderabbitai bot commented Aug 20, 2025

Walkthrough

다수의 클래스에서 사용되지 않는 import를 제거하고, 사소한 포매팅을 정리했습니다. 영향 파일은 DTO(request/response), 엔티티, 리포지토리, 서비스 구현 및 컨트롤러 등입니다. 기능 로직과 공개 API 시그니처는 대부분 변경 없음입니다. 예외적으로 RecentSearchServiceImpl의 생성자에서 JwtTokenProvider 의존성이 제거되어 생성자 파라미터가 축소되었습니다. 그 외 서비스 구현, 유효성 검증 애노테이션, 메서드 시그니처, 제어 흐름에는 변화가 없습니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • 범위: 여러 파일에 걸친 import 정리 중심, 한 곳(RecentSearchServiceImpl)에서 생성자 시그니처 변경
  • 복잡도: 낮음. 대부분 반복적이고 동질적인 변경
  • 이질성: 낮음. DI 구성 영향 점검 필요 파일은 1개
  • 논리 밀도: 거의 없음 (로직 무변경)

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/#129_search-code-refactor

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/mumuk/domain/search/service/RecentSearchServiceImpl.java (1)

45-51: NPE 위험: size(key)가 null일 때 'logSize==10' 비교에서 언박싱 NPE 발생

opsForList().size(key)는 키가 없으면 null을 반환합니다. 현재 비교는 언박싱을 유발하여 NullPointerException 가능성이 있습니다. 또한 경계값 비교는 == 10 보다는 >= 10이 안전합니다.

다음 수정으로 NPE를 방지하고 경계값 비교를 보완해 주세요:

-        Long logSize = redisTemplate.opsForList().size(key);
-        // 해당 key가 존재하지 않는 경우 발생하는 nullPointerException 방지
-
-        if (logSize==10) {
-            redisTemplate.opsForList().rightPop(key);
-        } // 최근 검색어는 10개까지! 그 이상은 내보냄
+        Long logSize = redisTemplate.opsForList().size(key);
+        // 키가 없으면 size가 null이므로 NPE 방지
+        if (logSize == null) {
+            logSize = 0L;
+        }
+        // 최근 검색어는 10개까지 유지
+        if (logSize >= 10) {
+            redisTemplate.opsForList().rightPop(key);
+        }
🧹 Nitpick comments (1)
src/main/java/com/mumuk/domain/search/service/RecentSearchServiceImpl.java (1)

52-54: 간결화 제안: LPUSH 후 LTRIM으로 리스트 길이(10개) 보장

선행 size 체크 대신 push 후 trim으로 일관되게 10개를 유지하면 코드가 단순해지고 경합 상황에서도 안전합니다. 위의 NPE 수정과 배타적으로 하나만 선택 적용해도 됩니다.

다음과 같이 변경을 고려해 주세요:

-        // 검색어 저장
-        redisTemplate.opsForList().leftPush(key,value);
+        // 검색어 저장 후 길이 10개로 트림
+        redisTemplate.opsForList().leftPush(key, value);
+        redisTemplate.opsForList().trim(key, 0, 9);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1a783e2 and 7f60eaa.

📒 Files selected for processing (15)
  • src/main/java/com/mumuk/domain/healthManagement/dto/request/HealthGoalRequest.java (0 hunks)
  • src/main/java/com/mumuk/domain/healthManagement/dto/request/UserInfoRequest.java (0 hunks)
  • src/main/java/com/mumuk/domain/healthManagement/dto/response/HealthGoalResponse.java (0 hunks)
  • src/main/java/com/mumuk/domain/healthManagement/entity/HealthGoal.java (0 hunks)
  • src/main/java/com/mumuk/domain/healthManagement/entity/UserInfo.java (1 hunks)
  • src/main/java/com/mumuk/domain/healthManagement/repository/AllergyRepository.java (0 hunks)
  • src/main/java/com/mumuk/domain/healthManagement/service/AllergyService.java (0 hunks)
  • src/main/java/com/mumuk/domain/healthManagement/service/HealthGoalServiceImpl.java (0 hunks)
  • src/main/java/com/mumuk/domain/healthManagement/service/UserInfoService.java (0 hunks)
  • src/main/java/com/mumuk/domain/search/controller/SearchController.java (0 hunks)
  • src/main/java/com/mumuk/domain/search/dto/request/SearchRequest.java (0 hunks)
  • src/main/java/com/mumuk/domain/search/dto/response/SearchResponse.java (0 hunks)
  • src/main/java/com/mumuk/domain/search/service/AutocompleteServiceImpl.java (0 hunks)
  • src/main/java/com/mumuk/domain/search/service/RecentSearchServiceImpl.java (2 hunks)
  • src/main/java/com/mumuk/domain/search/service/SearchServiceImpl.java (0 hunks)
💤 Files with no reviewable changes (13)
  • src/main/java/com/mumuk/domain/healthManagement/service/UserInfoService.java
  • src/main/java/com/mumuk/domain/healthManagement/dto/response/HealthGoalResponse.java
  • src/main/java/com/mumuk/domain/search/controller/SearchController.java
  • src/main/java/com/mumuk/domain/healthManagement/entity/HealthGoal.java
  • src/main/java/com/mumuk/domain/healthManagement/service/AllergyService.java
  • src/main/java/com/mumuk/domain/healthManagement/dto/request/UserInfoRequest.java
  • src/main/java/com/mumuk/domain/healthManagement/service/HealthGoalServiceImpl.java
  • src/main/java/com/mumuk/domain/healthManagement/dto/request/HealthGoalRequest.java
  • src/main/java/com/mumuk/domain/search/dto/response/SearchResponse.java
  • src/main/java/com/mumuk/domain/healthManagement/repository/AllergyRepository.java
  • src/main/java/com/mumuk/domain/search/dto/request/SearchRequest.java
  • src/main/java/com/mumuk/domain/search/service/SearchServiceImpl.java
  • src/main/java/com/mumuk/domain/search/service/AutocompleteServiceImpl.java
🔇 Additional comments (4)
src/main/java/com/mumuk/domain/healthManagement/entity/UserInfo.java (1)

35-35: 기본 생성자 포맷 정리(LGTM)

불필요한 세미콜론 제거 및 공백 정리로 가독성 향상. 동작 영향 없습니다.

src/main/java/com/mumuk/domain/search/service/RecentSearchServiceImpl.java (3)

116-116: 변경 없음으로 간주

파일 말미 중괄호 변경 표시는 실질 로직 영향이 없어 코멘트 생략합니다.


76-92: SavedRecentSearchReq에 equals()/hashCode() 구현 확인됨
SearchRequest.java의 SavedRecentSearchReq 클래스에 Lombok의 @AllArgsConstructor@EqualsAndHashCode 어노테이션이 적용되어 있어, opsForList().remove()가 내부적으로 equals()를 이용한 값 비교를 수행합니다. 삭제 로직이 의도한 대로 동작하므로 추가 대응이 필요 없습니다.


21-24: 검토 결과: RecentSearchServiceImpl 생성자 변경 영향 없음 확인

  • 코드베이스 전체 검색 결과 new RecentSearchServiceImpl(...) 직접 호출이나 테스트(@InjectMocks, @Mock, @Autowired)에서의 사용처가 없습니다.
  • Spring 컨테이너 자동 주입에도 문제가 없으며, 컴파일/런타임 오류 발생 가능성은 없습니다.

따라서 이번 생성자 시그니처 변경은 안전하며 추가 조치가 필요 없습니다.

@parkmineum parkmineum merged commit 5ff64a7 into dev Aug 20, 2025
3 checks passed
@jaemin0413 jaemin0413 deleted the refactor/#129_search-code-refactor branch August 27, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️ REFACTOR 리팩토링 관련 라벨

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 전반적인 코드 개선

2 participants