Skip to content

computeInsights mutates the caller's repository array #3

Description

@adity982

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions