cutenode / cutenode/good-first-issue
Random pick never returns the last issue
- Dominant language
- JavaScript
- Stars
- 832
- Forks
- 236
- PR merge metrics
- No merged PRs in 30d
Description
## 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.
Contributor guide
Research direction
Open bin/good-first-issue.js and inspect the issue-selection expression described in the report. Verify the random selection behavior with a result list that includes a final issue; done means every issue, including the last one, can be selected with equal probability.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100