Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Issue #46 (Wrong result from local number) fix #47
Issue #46 (Wrong result from local number) fix #47
Changes from 3 commits
8b653cd
52b9cc1
092d162
bae0d72
04b33b0
3a51059
b2c4464
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This does not seem to be used anywhere anymore. Therefor this can be removed and the "Strict" can be removed from the new one.
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.
getMatchUsingPatternsStrict
was introduced to avoid duplicated code ingetMatchUsingPatterns
. As I wrote, I tried to localize changes maximally, but I suggest redesigning interfaces to avoid exceptions and non-valid metadata matches.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.
You misunderstood me. It seems like
getMatchUsingPatterns
is not used anywhere in the code base except here. It can safely be removed. WhengetMatchUsingPatterns
is removed we will only havegetMatchUsingPatternsStrict
which can be renamed togetMatchUsingPatterns
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.
MetadataMatcher already returns a nullable. That discussion could be made for the country code parser though
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.
Done.
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 believe there is something unsound here:
Currently the code in the parser assumes that if there was no exit code, then the next part is not a country code. (line 60)
But here this assumption is not taken into account.
However, some people want to be able to parse phone number starting with a country code without the exit code see: #39 . But I believe that's outside the scope of this PR
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.
Are there any tests that cover this case?
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 suggest not handling this case in this PR.
There is a list of test in the issue that I believe would not pass currently without the leading '+'. That is:
This is outside the scope of this Pull request though.
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.
OK.
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 explain to me why don't we do (as per my first comment)
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.
Earlier, there was no difference in whether the phone had an exit code or not; the parser tried to interpret the first digits as country code. So, my changes were an attempt to preserve the current way to process input.
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.
This comment is ambiguous. What is "it" in "we should use => it <=". And why "phone number validity", as metadatas you return already check validity ?
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.
That's a part of handling a partial input that starts with an exit code.
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 have updated the comment
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's not use the !
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.
That is not possible because it leads to compilation issues. This can be avoided with the transformation
CountryCodeParser.extractCountryCode
and_findDestinationMetadata
to return an optional, which causes to more remarkable code changes.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.
It seems like you were talking about the country_code_parser interface that throws when the country code is not found. Which could instead return a
String?
. That's a fair observation and I'm okay with that. At first glance this seems to be a small change but it'd be better if it was in a separate PR imo, just to make it easy to review.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.
Agreed. What do you think is the best to do in this case?