Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faker::Alphanumeric.alphanumeric determinism fix #2996

Merged
merged 3 commits into from
Sep 6, 2024

Conversation

admtnnr
Copy link
Contributor

@admtnnr admtnnr commented Aug 27, 2024

Motivation / Background

This Pull Request has been created because the Faker::Alphanumeric.alphanumeric generator is not deterministic when using min_alpha and/or min_numeric.

Additional information

The generator is not currently deterministic when setting a custom Faker::Config.random due to the usage of the standard shuffle array method.

Unfortunately, this can't be caught by the tests in test/test_determinism.rb because the default keyword arguments do not trigger the non-determinism due to the early return when both min_alpha and min_numeric are 0.

I have added a test to the Faker::Alphanumeric test file for this case, but I'm happy to [re]move it if preferred.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug, refactor something, or add a feature.
  • Tests and Rubocop are passing before submitting your proposed changes.

If you're proposing a new generator or locale:

  • Double-check the existing generators documentation to make sure the new generator you want to add doesn't already exist.
  • You've reviewed and followed the Contributing guidelines.

Copy link
Contributor

@stefannibrasil stefannibrasil left a comment

Choose a reason for hiding this comment

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

Thank you for opening this PR and contributing to faker!

@stefannibrasil stefannibrasil merged commit caa5507 into faker-ruby:main Sep 6, 2024
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.

2 participants