ποΈ Deprecate Random::next(n) and Random::nextInt()#6687
Conversation
Co-authored-by: Nicolas DUBIEN <[email protected]> Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
π¦ Changeset detectedLatest commit: 9231112 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
π 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. The template includes:
Thank you for your contribution! π |
| /** | ||
| * Generate an integer having `bits` random bits | ||
| * @param bits - Number of bits to generate | ||
| * @deprecated |
There was a problem hiding this comment.
@claude add details on the alternative, suggest calling nextInt instead with the right parameters
There was a problem hiding this comment.
Claude finished @dubzzz's task in 49s ββ View job
Tasks
- Read
Random.tsto understand current deprecation messages - Update
@deprecatedtag fornext(bits)at line 39 with alternative suggestion - Update
@deprecatedtag fornextInt()(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 |
There was a problem hiding this comment.
@claude add details on the alternative, suggest calling nextInt with the right parameters
There was a problem hiding this comment.
Claude finished @dubzzz's task in 1m 24s ββ View job
Tasks
- Gather context
- Read
Random.tsto understand the deprecated methods - Update deprecation notices with alternative
nextIntcalls - 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.
|
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]>
|
@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) |
@fast-check/ava
fast-check
@fast-check/jest
@fast-check/packaged
@fast-check/poisoning
@fast-check/vitest
@fast-check/worker
commit: |
Co-authored-by: Nicolas DUBIEN <[email protected]> Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Claude finished @dubzzz's task in 1m 0s ββ View job Tasks
SummaryCreated
Claude Code automatically reads |
Instructs Claude Code to follow the gitmoji naming convention and the PR template when opening pull requests. Co-authored-by: Nicolas DUBIEN <[email protected]>
|
@claude create a dedicated PR for the worker related changes, drop them from this PR |
|
@claude create a dedicated PR for the pr guidelines related changes, drop them from this PR |
|
Claude finished @dubzzz's task in 1m 13s ββ View job Tasks
SummaryDone! Here's what was done:
|
|
Claude finished @dubzzz's task in 1m 20s ββ View job Tasks
Summary
This PR now only contains the deprecation changes to |
This reverts commit da69699.
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.
Codecov Reportβ
All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. β View full report in Codecov by Sentry. π New features to boost your workflow:
|
## 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>
## 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]>
Mark
Random::next(n)andRandom::nextInt()(no-argument overload only) as@deprecatedfollowing the bump to pure-rand v8.Related to #6679.
Generated with Claude Code