オートモードの終着前巻き戻りを防ぐ#5558
Conversation
📝 Walkthroughウォークスルー駅オブジェクトの次の非通過駅選択ロジックを、フィルタリング方式から直接インデックス検索方式に変更しました。さらに、同一駅が駅リストで再び登場した場合のテストケースを追加し、速度プロファイル生成とシミュレーション進行の正確性を検証しました。 変更内容
推定コード審査工数🎯 3 (中程度) | ⏱️ ~20分 関連する可能性のあるPR
ウサギの詩
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/hooks/useSimulationMode.ts (1)
305-313: 到達不能なガード条件の簡略化を検討Line 264で
nextStopStationIndex === -1の場合は早期リターンしており、findIndexはidx > normalizedSegmentIndexで探索するため、見つかった場合は必ずnextStopStationIndex > currentSegmentStationIndexとなります。このため、Line 306のnextStopStationIndex < currentSegmentStationIndexチェックは到達不能です。防御的コーディングとして残すか、簡略化するかは任意ですが、削除すればコードがより明確になります。
♻️ 簡略化案
- if ( - nextStopStationIndex < 0 || - nextStopStationIndex < currentSegmentStationIndex - ) { - segmentIndexRef.current = 0; - childIndexRef.current = 0; - segmentProgressDistanceRef.current = 0; - return; - }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/useSimulationMode.ts` around lines 305 - 313, The if-block that checks "nextStopStationIndex < 0 || nextStopStationIndex < currentSegmentStationIndex" contains a redundant unreachable condition: earlier you already early-return when nextStopStationIndex === -1 and the findIndex uses "idx > normalizedSegmentIndex", so any found nextStopStationIndex will always be > currentSegmentStationIndex; remove the "nextStopStationIndex < currentSegmentStationIndex" clause and keep the simple guard "nextStopStationIndex < 0" while preserving the reset behavior that sets segmentIndexRef.current, childIndexRef.current, and segmentProgressDistanceRef.current to 0.
🤖 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/hooks/useSimulationMode.ts`:
- Around line 305-313: The if-block that checks "nextStopStationIndex < 0 ||
nextStopStationIndex < currentSegmentStationIndex" contains a redundant
unreachable condition: earlier you already early-return when
nextStopStationIndex === -1 and the findIndex uses "idx >
normalizedSegmentIndex", so any found nextStopStationIndex will always be >
currentSegmentStationIndex; remove the "nextStopStationIndex <
currentSegmentStationIndex" clause and keep the simple guard
"nextStopStationIndex < 0" while preserving the reset behavior that sets
segmentIndexRef.current, childIndexRef.current, and
segmentProgressDistanceRef.current to 0.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d4d8abc1-ede4-4d13-9a21-6d9b4c2d15ac
📒 Files selected for processing (2)
src/hooks/useSimulationMode.test.tsxsrc/hooks/useSimulationMode.ts
概要
リスク
実行コマンド
チケット
Summary by CodeRabbit
リリースノート
バグ修正
パフォーマンス改善