-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Generate safe email
and domain_name
by default (RFC 2606)
#2733
Generate safe email
and domain_name
by default (RFC 2606)
#2733
Conversation
faker-ruby is transitioning to no longer generating potentially real email and url addresses. The migration plan is: First step: - change `email` and `domain_name` to be RFC 2606 compliant. Both now generate safe values by default using the Reserved Top Level DNS Names: `example` and `test`. To maintain backwards compatibility and give users the option to use non-safe domains at their own risk, custom domains are allowed. Documentation and tests have been updated. - add deprecation message for `free_email` and `safe_email` to use `email` instead. Second step: - remove deprecated generators and locales. Co-authored-by: Thiago Araujo <thd.araujo@gmail.com>
# Keyword arguments: safe ('example' and 'test' suffixes) | ||
Faker::Internet.domain_suffix #=> "info" | ||
Faker::Internet.domain_suffix(safe: true) #=> "example" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (minor): since we're making breaking changes here, it may be good to also rename this to #tld
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify more why you think this is a breaking change? If the argument is not provided, the generator still works 🤔
I like the idea of using tld
. Maybe we can introduce an alias in another PR? This one is already getting too big 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me know what you think and I will merge this once I hear back from you :) Thanks for the review @Zeragamba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this PR being a breaking change or not. The way this PR handles the problem is by maintaining backwards compatibility for those who want to use unsafe domains. What is going to change is the behavior: the results will be safe by default. It doesn't seem like a breaking change to me. What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you, Stefanni.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vbrazo did you mean to approve this PR? Just checking because I see your comments but not an approval 🍡 Thank you!
lib/faker/default/internet.rb
Outdated
@@ -1,6 +1,7 @@ | |||
# frozen_string_literal: true | |||
|
|||
module Faker | |||
# rubocop:disable Style/IfUnlessModifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: should this also be disabled in the project's rubocop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind disabling it for the project! I wasn't sure this was what we wanted so I only added it here.
I will push a commit once I figure out how to fix my ssh keys to be able to push again ><
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it in 4a46759
Faker::Internet.email(name: 'Nancy') #=> "nancy@terry.test" | ||
Faker::Internet.email(name: 'Janelle Santiago', separators: ['+']) #=> "janelle+santiago@becker.example" | ||
Faker::Internet.email(domain: 'gmail.com') #=> "foo@gmail.com" | ||
Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'test') #=> "sam-smith@test.test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding more examples and completing the Internet doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
Faker now does the right thing by default, awesome! faker-ruby/faker#2733
Prior to this commit, the following deprecation warning was appearing in the terminal: NOTE: Faker::Internet.safe_email is deprecated; use email instead. It will be removed on or after 2023-10. More here: faker-ruby/faker#2733
Prior to this commit, the following deprecation warning was appearing in the terminal: NOTE: Faker::Internet.safe_email is deprecated; use email instead. It will be removed on or after 2023-10. More here: faker-ruby/faker#2733
* build(deps-dev): Bump faker from 3.2.3 to 3.3.1 Bumps [faker](https://github.com/faker-ruby/faker) from 3.2.3 to 3.3.1. - [Release notes](https://github.com/faker-ruby/faker/releases) - [Changelog](https://github.com/faker-ruby/faker/blob/main/CHANGELOG.md) - [Commits](faker-ruby/faker@v3.2.3...v3.3.1) --- updated-dependencies: - dependency-name: faker dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * fix: Use `Faker::Internet.email` instead of `free_email` ## Related PR - faker-ruby/faker#2733 - faker-ruby/faker#2841 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Toshimaru <me@toshimaru.net>
Summary
Fixes #2431
faker-ruby is transitioning to no longer generating potentially real email and url addresses.
The migration plan is:
First step:
email
anddomain_name
to be RFC 2606 compliant. Both now generate safe values by default using the Reserved Top Level DNS Names:example
andtest
. To maintain backwards compatibility and give users the option to use non-safe domains at their own risk, custom domains are allowed.free_email
andsafe_email
to useemail
instead.Second step (after October 2023):
To give users time, once the first step is released, users will have until October 2023 to make the necessary changes.
Other Information
# rubocop:disable Style/IfUnlessModifier
because inline conditionals are hard to read and therefore to refactor. With the explicit conditionals, it's easier to extract them to a method, etc.