feat: 스캔 내역 클릭 시 상세 보고서 페이지 연결#37
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
Walkthrough스캔 분류 로직을 통합하는 리팩토링으로, 새로운 Changes스캔 분류 통합
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 👉 Get your free trial and get 200 agent minutes per Slack user (a $50 value). 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. Review rate limit: 0/1 reviews remaining, refill in 43 minutes and 52 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/pages/ScanList/ScanListPage.tsx (1)
88-94: 💤 Low value
isWebScanListItem래퍼 함수가 불필요합니다.단 한 줄로
isWebScanTarget을 그대로 위임하므로, 추가적인 가독성이나 추상화 효과가 없습니다.♻️ 인라인 직접 호출로 간소화
-function isWebScanListItem(item: { - isUrl: boolean | null; - schemeType: string | null; - url: string; -}): boolean { - return isWebScanTarget(item); -} // ... -const nextRoute = isWebScanListItem(item) ? reportRoute : nonUrlResultRoute; +const nextRoute = isWebScanTarget(item) ? reportRoute : nonUrlResultRoute;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/ScanList/ScanListPage.tsx` around lines 88 - 94, The function isWebScanListItem simply delegates to isWebScanTarget and is unused for added abstraction; remove the isWebScanListItem wrapper function and replace its call sites to call isWebScanTarget directly, making sure any necessary import or scope for isWebScanTarget is present where the wrapper was used and that the parameter shape expected by isWebScanTarget matches the previous usage.src/shared/store/scanSessionStore.ts (1)
137-158: 💤 Low value
resolveIsUrl내 이중 정규화는 무해하지만 중복입니다.
resolveSchemeType이 이미normalizeScanSchemeTypeAlias를 적용하여 정규화된 값을 반환하므로,resolveIsUrl에서 동일 함수를 다시 호출하는 것은 불필요합니다. 동작에는 영향이 없습니다.♻️ 간소화 제안
function resolveIsUrl( source: unknown, decodedUrl: string | null, schemeType: string | null, ): boolean | null { const explicitIsUrl = pickBoolean(source, ['isUrl', 'is_url']); - const normalizedSchemeType = normalizeScanSchemeTypeAlias(schemeType); - if (normalizedSchemeType) { - return normalizedSchemeType === 'WEB'; + if (schemeType) { + return schemeType === 'WEB'; } ... }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/shared/store/scanSessionStore.ts` around lines 137 - 158, The function resolveIsUrl redundantly calls normalizeScanSchemeTypeAlias on schemeType even though callers already pass a normalized value (from resolveSchemeType); remove the duplicate normalization and instead use the incoming schemeType directly (e.g., compare schemeType === 'WEB'), leaving the explicitIsUrl (pickBoolean) and isHttpUrl checks unchanged so behavior remains the same; update resolveIsUrl to accept and use the normalized schemeType without calling normalizeScanSchemeTypeAlias.src/pages/QRScan/hooks/useQRScanPage.ts (1)
140-165: 💤 Low value
isNonWebScanResponse내 불필요한 사전 정규화 및 빈 문자열 폴백Line 157에서
rawSchemeType.trim().toUpperCase()로 사전 정규화한 후isWebScanTarget에 넘기지만,isWebScanTarget내부의normalizeScanSchemeTypeAlias가 동일한 정규화를 한 번 더 수행합니다. 또한 스킴 타입 부재 시null대신''을 폴백으로 사용하는 것은ScanTargetLike.schemeType: string | null | undefined관례와 일치하지 않습니다 (''은normalizeScanSchemeTypeAlias내!schemeType체크로 우연히 동작함).♻️ 정리 제안
function isNonWebScanResponse(scanResponse: Record<string, unknown>): boolean { const rawSchemeType = typeof scanResponse.schemeType === 'string' ? scanResponse.schemeType : scanResponse.scheme_type; const targetValue = /* ... unchanged ... */; - const schemeType = typeof rawSchemeType === 'string' ? rawSchemeType.trim().toUpperCase() : ''; + const schemeType = typeof rawSchemeType === 'string' ? rawSchemeType : null; const rawIsUrl = scanResponse.isUrl !== undefined ? scanResponse.isUrl : scanResponse.is_url; return !isWebScanTarget({ isUrl: typeof rawIsUrl === 'boolean' ? rawIsUrl : null, schemeType, url: targetValue, }); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/QRScan/hooks/useQRScanPage.ts` around lines 140 - 165, The function isNonWebScanResponse is pre-normalizing schemeType (rawSchemeType.trim().toUpperCase()) and falling back to an empty string, which duplicates work done by isWebScanTarget/normalizeScanSchemeTypeAlias and breaks the expected ScanTargetLike.schemeType contract; change isNonWebScanResponse to stop trimming/uppercasing and instead pass the raw scheme value as string | null | undefined (i.e. use rawSchemeType directly or null when absent), and keep the isUrl handling as boolean | null, so isWebScanTarget can perform its own normalizeScanSchemeTypeAlias logic.src/shared/lib/scan-session/scanClassification.test.ts (1)
5-26: ⚡ Quick win핵심 헬퍼 함수의 엣지 케이스 테스트가 누락되어 있습니다.
이 유틸리티는 4개 이상의 소비처에서 사용되는 공유 분류 로직의 핵심입니다. 아래 케이스들을 추가하면 회귀 방지 효과가 높습니다.
✅ 추가 권장 테스트 케이스
describe('scanClassification', () => { it('normalizes URL scheme aliases to WEB', () => { expect(normalizeScanSchemeTypeAlias('URL')).toBe('WEB'); expect(normalizeScanSchemeTypeAlias(' web ')).toBe('WEB'); + expect(normalizeScanSchemeTypeAlias('SMS')).toBe('SMS'); + expect(normalizeScanSchemeTypeAlias(null)).toBe(null); + expect(normalizeScanSchemeTypeAlias(' ')).toBe(null); }); it('detects http and https targets as web URLs', () => { expect(isHttpUrl('https://example.com')).toBe(true); expect(isHttpUrl('http://example.com')).toBe(true); expect(isHttpUrl('sms:01012345678')).toBe(false); + expect(isHttpUrl(null)).toBe(false); + expect(isHttpUrl(undefined)).toBe(false); + expect(isHttpUrl(' https://example.com')).toBe(true); // trim 동작 확인 }); it('treats history items with URL scheme aliases as web scans', () => { expect(isWebScanTarget({ isUrl: false, schemeType: 'URL', url: 'https://example.com/path' })).toBe(true); + }); + + it('falls back to HTTP URL when no schemeType', () => { + expect(isWebScanTarget({ schemeType: null, url: 'https://example.com' })).toBe(true); + }); + + it('returns false for explicit non-web schemeType', () => { + expect(isWebScanTarget({ schemeType: 'SMS', isUrl: true, url: 'https://example.com' })).toBe(false); + }); + + it('falls back to isUrl flag when schemeType and url are absent', () => { + expect(isWebScanTarget({ isUrl: true })).toBe(true); + expect(isWebScanTarget({ isUrl: false })).toBe(false); + expect(isWebScanTarget({})).toBe(false); }); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/shared/lib/scan-session/scanClassification.test.ts` around lines 5 - 26, Add comprehensive edge-case tests for the three helpers: normalizeScanSchemeTypeAlias, isHttpUrl, and isWebScanTarget. Specifically, add tests that verify normalizeScanSchemeTypeAlias handles null/undefined, empty string, mixed-case and surrounding whitespace (e.g., ' Url ' -> 'WEB'), and unknown scheme strings; add tests for isHttpUrl with non-string inputs (null/undefined/number), uppercase/lowercase scheme variants, and other schemes like 'ftp:' and 'mailto:' to ensure false; and add isWebScanTarget tests for history items where isUrl is true (should prefer isUrl), schemeType is unknown or null, url is empty/invalid, and when schemeType contains whitespace/casing differences to ensure consistent classification. Use the existing function names normalizeScanSchemeTypeAlias, isHttpUrl, and isWebScanTarget to locate and add these new test cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/pages/QRScan/hooks/useQRScanPage.ts`:
- Around line 140-165: The function isNonWebScanResponse is pre-normalizing
schemeType (rawSchemeType.trim().toUpperCase()) and falling back to an empty
string, which duplicates work done by
isWebScanTarget/normalizeScanSchemeTypeAlias and breaks the expected
ScanTargetLike.schemeType contract; change isNonWebScanResponse to stop
trimming/uppercasing and instead pass the raw scheme value as string | null |
undefined (i.e. use rawSchemeType directly or null when absent), and keep the
isUrl handling as boolean | null, so isWebScanTarget can perform its own
normalizeScanSchemeTypeAlias logic.
In `@src/pages/ScanList/ScanListPage.tsx`:
- Around line 88-94: The function isWebScanListItem simply delegates to
isWebScanTarget and is unused for added abstraction; remove the
isWebScanListItem wrapper function and replace its call sites to call
isWebScanTarget directly, making sure any necessary import or scope for
isWebScanTarget is present where the wrapper was used and that the parameter
shape expected by isWebScanTarget matches the previous usage.
In `@src/shared/lib/scan-session/scanClassification.test.ts`:
- Around line 5-26: Add comprehensive edge-case tests for the three helpers:
normalizeScanSchemeTypeAlias, isHttpUrl, and isWebScanTarget. Specifically, add
tests that verify normalizeScanSchemeTypeAlias handles null/undefined, empty
string, mixed-case and surrounding whitespace (e.g., ' Url ' -> 'WEB'), and
unknown scheme strings; add tests for isHttpUrl with non-string inputs
(null/undefined/number), uppercase/lowercase scheme variants, and other schemes
like 'ftp:' and 'mailto:' to ensure false; and add isWebScanTarget tests for
history items where isUrl is true (should prefer isUrl), schemeType is unknown
or null, url is empty/invalid, and when schemeType contains whitespace/casing
differences to ensure consistent classification. Use the existing function names
normalizeScanSchemeTypeAlias, isHttpUrl, and isWebScanTarget to locate and add
these new test cases.
In `@src/shared/store/scanSessionStore.ts`:
- Around line 137-158: The function resolveIsUrl redundantly calls
normalizeScanSchemeTypeAlias on schemeType even though callers already pass a
normalized value (from resolveSchemeType); remove the duplicate normalization
and instead use the incoming schemeType directly (e.g., compare schemeType ===
'WEB'), leaving the explicitIsUrl (pickBoolean) and isHttpUrl checks unchanged
so behavior remains the same; update resolveIsUrl to accept and use the
normalized schemeType without calling normalizeScanSchemeTypeAlias.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9e5ea637-f7a6-46de-8f39-6099630fa184
📒 Files selected for processing (7)
src/pages/Loading/hooks/useLoadingPage.tssrc/pages/QRScan/hooks/useQRScanPage.tssrc/pages/ScanList/ScanListPage.tsxsrc/shared/lib/scan-session/scanClassification.test.tssrc/shared/lib/scan-session/scanClassification.tssrc/shared/store/scanSessionStore.test.tssrc/shared/store/scanSessionStore.ts
Tasks
Summary by CodeRabbit
버그 수정 및 개선
버그 수정
테스트