fix(metrics): Avoid mutating processedFiles array during sorting

Code review feedback addressed array mutation issue:
- Reviewer pointed out that sorting processedFiles in place mutates original array
- User requested using shallow copy to avoid side effects
- Assistant implemented [...processedFiles] spread operator before sorting
- Prevents unintended mutations of input array parameter
- Maintains immutability best practices in function implementation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Kazuki Yamada
2025-06-08 18:14:50 +09:00
parent fcf029985f
commit 1719a01156

View File

@@ -52,7 +52,7 @@ export const calculateMetrics = async (
const candidateFilesCount = Math.min(processedFiles.length, Math.max(topFilesLength * 10, topFilesLength));
// Get top files by character count first
const topFilesByChar = processedFiles
const topFilesByChar = [...processedFiles]
.sort((a, b) => b.content.length - a.content.length)
.slice(0, candidateFilesCount);