mirror of
https://github.com/yamadashy/repomix.git
synced 2025-06-11 00:25:54 +03:00
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user