Skip to content

Fixed toLocalPart; Fixed tests; Fixed formatting#1624

Merged
kingthorin merged 2 commits intodatafaker-net:mainfrom
rcriosbr:main
Aug 22, 2025
Merged

Fixed toLocalPart; Fixed tests; Fixed formatting#1624
kingthorin merged 2 commits intodatafaker-net:mainfrom
rcriosbr:main

Conversation

@rcriosbr
Copy link
Copy Markdown
Contributor

Trying to revert the formatting, I messed up my fork. So I thought it best to close the previous PR and start all over again. Here is a new PR. Sorry for the mess.

As suggested, instead of creating a public method, I left the method as private and changed the emailAddress(String name) and safeEmailAddress(String name) methods to use it. This way, it is transparent to users.

According to the diff, it seems that this time I didn't mess up the formatting, and I ran all the tests and none of them failed.

@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Aug 21, 2025

PR Summary

  • Introduction of Methods for Email Generation
    Two methods have been added to the Internet class that facilitate the creation of email addresses based on the user's name. The methods in question are emailAddress(String name) and safeEmailAddress(String name).

  • Enhancements to Documentation
    To provide greater clarity on the usage of these new methods, detailed explanations and examples are now included in the Javadoc comments.

  • Creation of toLocalPart Method
    An additional method toLocalPart(String name) has been created. This private method allows for names to be converted into a valid email local part by removing accents and managing prefixes/suffixes.

  • Extension of Validation Regex
    To ensure accurate verification of valid character inputs for email parts, a static Pattern LOCALPART has been expanded.

  • Updated Test Cases
    The email address tests within the InternetTest class have been modified to incorporate the new name-based email generation methods. Modifications to these tests are mirrored in the assertions as well.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 21, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 76.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.26%. Comparing base (ab88b11) to head (ceb00c7).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...in/java/net/datafaker/providers/base/Internet.java 76.00% 1 Missing and 5 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1624      +/-   ##
============================================
- Coverage     92.40%   92.26%   -0.14%     
- Complexity     3356     3357       +1     
============================================
  Files           331      331              
  Lines          6613     6636      +23     
  Branches        654      662       +8     
============================================
+ Hits           6111     6123      +12     
- Misses          346      349       +3     
- Partials        156      164       +8     

☔ 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.

@kingthorin kingthorin requested a review from Copilot August 21, 2025 21:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements improved email address generation from names by adding a new toLocalPart method that converts names to valid email local parts. The implementation handles prefixes, suffixes, and special characters while using only first and last names for email generation.

  • Adds a private toLocalPart method that extracts first/last names and removes prefixes/suffixes
  • Updates emailAddress(String) and safeEmailAddress(String) methods to use the new conversion logic
  • Enhances test coverage with comprehensive test cases for various name formats

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/java/net/datafaker/providers/base/Internet.java Implements toLocalPart method and updates email generation methods with improved documentation
src/test/java/net/datafaker/providers/base/InternetTest.java Adds comprehensive test cases for name-to-email conversion including edge cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <[email protected]>
@kingthorin kingthorin merged commit 7b7237a into datafaker-net:main Aug 22, 2025
13 checks passed
@asolntsev asolntsev added this to the 2.4.5 milestone Aug 22, 2025
@asolntsev asolntsev added the enhancement New feature or request label Aug 22, 2025
@bodiam
Copy link
Copy Markdown
Contributor

bodiam commented Aug 23, 2025

@rcriosbr Thanks for your contribution, it's much appreciated, and thanks to all for providing feedback and a quick merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants