Problem
computeInsights() finds the most-starred repository with repos.sort(...). Array.prototype.sort() mutates the array supplied by the caller, so computing metrics unexpectedly changes repository order. The GitHub client deliberately returns repositories by recent update; callers that reuse the array receive a different order after analysis.
Reproduction
Pass repositories ordered by update time to computeInsights() and inspect the array afterward; it has been reordered by star count.
Expected behavior
- Insight calculation is side-effect free.
- The most-starred repository is still selected correctly.
- A regression test verifies that input order is preserved.
Problem
computeInsights()finds the most-starred repository withrepos.sort(...).Array.prototype.sort()mutates the array supplied by the caller, so computing metrics unexpectedly changes repository order. The GitHub client deliberately returns repositories by recent update; callers that reuse the array receive a different order after analysis.Reproduction
Pass repositories ordered by update time to
computeInsights()and inspect the array afterward; it has been reordered by star count.Expected behavior