Skip to content

πŸ—‘οΈ Deprecate Random::next(n) and Random::nextInt()#6687

Merged
dubzzz merged 8 commits into
mainfrom
claude/pr-6679-20260306-2203
Mar 6, 2026
Merged

πŸ—‘οΈ Deprecate Random::next(n) and Random::nextInt()#6687
dubzzz merged 8 commits into
mainfrom
claude/pr-6679-20260306-2203

Conversation

@dubzzz

@dubzzz dubzzz commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Mark Random::next(n) and Random::nextInt() (no-argument overload only) as @deprecated following the bump to pure-rand v8.

Related to #6679.

Generated with Claude Code

Co-authored-by: Nicolas DUBIEN <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@changeset-bot

changeset-bot Bot commented Mar 6, 2026

Copy link
Copy Markdown

πŸ¦‹ Changeset detected

Latest commit: 9231112

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
fast-check Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

πŸ‘‹ It looks like the PR template was not used for this pull request.

Please edit the PR description to use the template, or close this PR and open a new one that uses it.
Not using the template may result in your change not being reviewed.

The template includes:

  • A Description section
  • A Checklist section with items to verify before submitting

Thank you for your contribution! πŸ™

/**
* Generate an integer having `bits` random bits
* @param bits - Number of bits to generate
* @deprecated

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude add details on the alternative, suggest calling nextInt instead with the right parameters

@claude claude Bot Mar 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude finished @dubzzz's task in 49s β€”β€” View job


Tasks

  • Read Random.ts to understand current deprecation messages
  • Update @deprecated tag for next(bits) at line 39 with alternative suggestion
  • Update @deprecated tag for nextInt() (no-arg) at line 55 with alternative suggestion
  • Commit and push changes

Updated the @deprecated messages in packages/fast-check/src/random/generator/Random.ts:

  • next(bits): @deprecated Prefer \nextInt(0, (1 << bits) - 1)` instead`
  • nextInt() (no-arg): @deprecated Prefer \nextInt(0x80000000 | 0, 0x7fffffff | 0)` for a full 32-bit signed integer range, or `nextInt(min, max)` with explicit bounds`


/**
* Generate a random integer (32 bits)
* @deprecated

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude add details on the alternative, suggest calling nextInt with the right parameters

@claude claude Bot Mar 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude finished @dubzzz's task in 1m 24s β€”β€” View job


Tasks

  • Gather context
  • Read Random.ts to understand the deprecated methods
  • Update deprecation notices with alternative nextInt calls
  • Commit and push changes

Summary

Updated the @deprecated JSDoc tags in packages/fast-check/src/random/generator/Random.ts to include explicit alternatives:

  • next(bits) (line 39): @deprecated Prefer {@link nextInt} with explicit bounds: \nextInt(0, (1 << bits) - 1)``
  • nextInt() no-arg overload (line 55): @deprecated Prefer {@link nextInt} with explicit bounds: \nextInt(-2147483648, 2147483647)``

Using {@link nextInt} creates a clickable link in generated API docs, and the code examples show users exactly what parameters to pass.
|

@dubzzz dubzzz left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

github-actions Bot and others added 2 commits March 6, 2026 22:07
Update @fast-check/worker to use pure-rand v8, mirroring the upgrade
done in fast-check. Updates import paths from the v7-style
`pure-rand/generator/XorShift` to the v8-style
`pure-rand/generator/xorshift128plus`.

Co-authored-by: Nicolas DUBIEN <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Nicolas DUBIEN <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@dubzzz

dubzzz commented Mar 6, 2026

Copy link
Copy Markdown
Owner Author

@claude make sure that claude code will only open PRs following our template for PRs and use the emoji naming convention (check our rules on copilot)

@pkg-pr-new

pkg-pr-new Bot commented Mar 6, 2026

Copy link
Copy Markdown
@fast-check/ava

npm i https://pkg.pr.new/@fast-check/ava@6687

fast-check

npm i https://pkg.pr.new/fast-check@6687

@fast-check/jest

npm i https://pkg.pr.new/@fast-check/jest@6687

@fast-check/packaged

npm i https://pkg.pr.new/@fast-check/packaged@6687

@fast-check/poisoning

npm i https://pkg.pr.new/@fast-check/poisoning@6687

@fast-check/vitest

npm i https://pkg.pr.new/@fast-check/vitest@6687

@fast-check/worker

npm i https://pkg.pr.new/@fast-check/worker@6687

commit: 84bd527

Co-authored-by: Nicolas DUBIEN <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@claude

claude Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Claude finished @dubzzz's task in 1m 0s β€”β€” View job


Tasks

  • Gather context
  • Read CLAUDE.md and copilot rules
  • Find PR template
  • Create CLAUDE.md with PR template and emoji naming instructions
  • Commit and push changes

Summary

Created CLAUDE.md at the repository root with instructions for Claude Code to follow when opening PRs:

  1. PR title naming convention β€” gitmoji format per .github/copilot-instructions.md:

    • emoji Description for fast-check package changes
    • emoji(package-name) Description for other packages
    • 50-character max on the description part
  2. PR body β€” always use the template from .github/PULL_REQUEST_TEMPLATE.md, keeping all sections (Description + Checklist) intact

Claude Code automatically reads CLAUDE.md on every invocation, so these rules will be applied when it opens future PRs.
|

Instructs Claude Code to follow the gitmoji naming convention
and the PR template when opening pull requests.

Co-authored-by: Nicolas DUBIEN <[email protected]>
@dubzzz

dubzzz commented Mar 6, 2026

Copy link
Copy Markdown
Owner Author

@claude create a dedicated PR for the worker related changes, drop them from this PR

@dubzzz

dubzzz commented Mar 6, 2026

Copy link
Copy Markdown
Owner Author

@claude create a dedicated PR for the pr guidelines related changes, drop them from this PR

@claude

claude Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Claude finished @dubzzz's task in 1m 13s β€”β€” View job


Tasks

  • Gather context
  • Identify worker-related changes in the current PR
  • Create a new branch for worker changes
  • Cherry-pick worker commit and push new branch
  • Create a new PR for worker changes
  • Revert worker changes from current PR branch

Summary

Done! Here's what was done:

  1. New PR created: #6689 β€” ⚑️(worker) Bump pure-rand to v8 β€” contains the worker-related changes cherry-picked from this branch.

  2. This PR β€” the worker commit (⚑️(worker) Bump pure-rand to v8) has been reverted. The remaining changes are now only:

    • CLAUDE.md β€” PR naming and template guidelines
    • packages/fast-check/src/random/generator/Random.ts β€” deprecation of Random::next(n) and Random::nextInt()
      Β· New worker PR #6689

@claude

claude Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Claude finished @dubzzz's task in 1m 20s β€”β€” View job


Tasks

  • Gather context
  • Read CLAUDE.md content
  • Create new branch for CLAUDE.md changes
  • Commit and push CLAUDE.md to new branch
  • Create dedicated PR for CLAUDE.md
  • Remove CLAUDE.md from current PR branch
  • Push changes to current branch

Summary

  • Created #6690 with the CLAUDE.md PR guidelines changes
  • Removed CLAUDE.md from this PR

This PR now only contains the deprecation changes to packages/fast-check/src/random/generator/Random.ts.
| New PR #6690

@claude claude Bot mentioned this pull request Mar 6, 2026
5 tasks
github-actions Bot and others added 2 commits March 6, 2026 22:13
Co-authored-by: Nicolas DUBIEN <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Deprecate the Random::next(n) and Random::nextInt() methods.
@dubzzz
dubzzz enabled auto-merge (squash) March 6, 2026 22:16
@dubzzz
dubzzz merged commit c62a288 into main Mar 6, 2026
45 checks passed
@dubzzz
dubzzz deleted the claude/pr-6679-20260306-2203 branch March 6, 2026 22:24
@codecov

codecov Bot commented Mar 6, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 94.54%. Comparing base (7238a83) to head (9231112).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6687   +/-   ##
=======================================
  Coverage   94.54%   94.54%           
=======================================
  Files         210      210           
  Lines        5685     5685           
  Branches     1500     1500           
=======================================
  Hits         5375     5375           
  Misses        297      297           
  Partials       13       13           
Flag Coverage Ξ”
tests 94.54% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

dubzzz added a commit that referenced this pull request Mar 6, 2026
## Description

Add a `CLAUDE.md` file at the repository root so Claude Code follows our
PR naming convention (gitmoji format) and always uses the PR template
when opening pull requests.

Related to #6687.

## Checklist

β€” _Don't delete this checklist and make sure you do the following before
opening the PR_

- [x] I have a full understanding of every line in this PR β€” whether the
code was hand-written, AI-generated, copied from external sources or
produced by any other tool
- [x] I flagged the impact of my change (minor / patch / major) either
by running `pnpm run bump` or by following the instructions from the
changeset bot
- [x] I kept this PR focused on a single concern and did not bundle
unrelated changes
- [x] I followed the [gitmoji](https://gitmoji.dev/) specification for
the name of the PR, including the package scope (e.g. `πŸ›(vitest)
Something...`) when the change targets a package other than `fast-check`
- [x] I added relevant tests and they would have failed without my PR
(when applicable)

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Nicolas DUBIEN <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Nicolas DUBIEN <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@dubzzz dubzzz mentioned this pull request Jul 24, 2026
5 tasks
dubzzz added a commit that referenced this pull request Jul 24, 2026
## Description

`Random` no longer exposes the no-argument overload of `nextInt()` nor
the `next(bits)` method β€” both deprecated since 4.6.0 (#6687) β€” and
drops `nextBoolean()` as well, which was not used anywhere in the
codebase, the documentation, or the website. **Breaking change**: any
caller of these methods must switch to `nextInt(min, max)` with explicit
bounds β€” `nextInt(-2147483648, 2147483647)` replaces `nextInt()`,
`nextInt(0, (1 << bits) - 1)` replaces `next(bits)`, and `nextInt(0, 1)
=== 1` replaces `nextBoolean()`. Flagged as major via a changeset.

Generated values are not impacted: `nextDouble` now draws its two
integers directly through `uniformInt` with the exact bounds previously
used by `next(26)`/`next(27)`, so random sequences stay bit-for-bit
identical.

The motivation is to keep a single way to draw integers from `Random`
and finish the cleanup started with the deprecations of #6687. Every
other method was checked for usage before deciding its fate: `clone`,
`nextInt(min, max)`, `nextBigInt` and `getState` are all used by
production code (arbitraries, worker package), and `nextDouble` is used
by e2e tests and documented integrations (e.g. the faker randomizer
pattern from the blog) β€” they all stay. The PR is focused on this single
concern.

On the tests side, specs relying on the dropped methods
(`Random.spec.ts`, `Runner.spec.ts`, `func.spec.ts`, stubs and the
worker property spec) were switched to `nextInt` with explicit bounds β€”
they would fail to compile against the new signature otherwise β€” and the
`fakeRandom()` helper no longer exposes mocks for the removed methods
while now properly overriding `nextDouble`.

## Checklist

β€” _Don't delete this checklist and make sure you do the following before
opening the PR_

- [ ] I have a full understanding of every line in this PR β€” whether the
code was hand-written, AI-generated, copied from external sources or
produced by any other tool
- [ ] I flagged the impact of my change (minor / patch / major) either
by running `pnpm run bump` or by following the instructions from the
changeset bot
- [ ] I kept this PR focused on a single concern and did not bundle
unrelated changes
- [ ] I followed the [gitmoji](https://gitmoji.dev/) specification for
the name of the PR, including the package scope (e.g. `πŸ›(vitest)
Something...`) when the change targets a package other than `fast-check`
- [ ] I added relevant tests and they would have failed without my PR
(when applicable)

<!-- PRs not checking all the boxes may take longer before being
reviewed -->
<!-- More about contributing at
https://github.com/dubzzz/fast-check/blob/main/CONTRIBUTING.md -->

πŸ€– Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01WL9nDkBv45rMBMvqTHQZFm

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant