Skip to content

Random pick never returns the last issue #1100

Description

@yugaaank

Bug

In bin/good-first-issue.js the issue selection uses:

const key = cmd.first ? 0 : Math.floor(Math.random() * Math.floor(issues.length - 1))

Because the multiplier is bounded by `issues.length - 1`, `Math.random()` can never produce `issues.length - 1`, so the final issue in the result list is never selectable.

Expected

Every returned issue should have an equal chance of being picked, including the last one.

Fix (one line)

const key = cmd.first ? 0 : Math.floor(Math.random() * issues.length)

The inner `Math.floor(issues.length - 1)` is also redundant since `issues.length` is already an integer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions