Conversation
- handle possible NPEs - extend unit tests
core/src/main/java/org/mobilitydata/gtfsvalidator/input/GtfsFeedName.java
Outdated
Show resolved
Hide resolved
barbeau
left a comment
There was a problem hiding this comment.
I support making -f optional but I'm not convinced that wrapping null within GtfsFeedName is the right way to approach this. Seems dangerous and prone to future NPEs.
Instead, I think a better approach would be to have a new -c command line parameter for country code and truly make -f optional, and deprecate it in future releases (unless we see other value in keeping it). If either are provided you can validate phone number, and if neither are provided you skip that rule.
core/src/main/java/org/mobilitydata/gtfsvalidator/input/GtfsFeedName.java
Outdated
Show resolved
Hide resolved
- implement -c
- implement new class CountryCode
- adjust existing code to use this instead of GtfsFeedName
- add unit tests
- make phone number validation conditional
- adjust country code definition in tests - up small caps in tests
|
Thanks for working in that direction! One more thing came to my mind. Let's remove the monolithic ValidationContext and inject only direct dependencies. "Inject only direct dependencies" is one of the main DI principles at Google. Here is what it means. This approach is not recommended: This one is preferred: So, instead of injecting ValidationContext, we should inject the CountryCode instead. This change will also simplify our unit tests since they will not have to create the full ValidationContext which may grow in the future. How does that sound? |
barbeau
left a comment
There was a problem hiding this comment.
Thanks @lionel-nj! Some comments in-line. The README and other docs also need to be updated.
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/parsing/RowParser.java
Outdated
Show resolved
Hide resolved
- implement field getter - remove asUnvalidatedString to simplify code - update unit tests
barbeau
left a comment
There was a problem hiding this comment.
Thanks @lionel-nj, some thoughts in-line.
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Outdated
Show resolved
Hide resolved
|
Oh, if this is a breaking change, the commit/PR title should include a |
TODO: remove mocks
|
Removing mocks from |
aababilov
left a comment
There was a problem hiding this comment.
Nice, can't wait to see it merged!
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/input/CountryCode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/parsing/RowParser.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/parsing/RowParser.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/mobilitydata/gtfsvalidator/parsing/RowParser.java
Outdated
Show resolved
Hide resolved
# Conflicts: # core/src/main/java/org/mobilitydata/gtfsvalidator/parsing/RowParser.java # core/src/test/java/org/mobilitydata/gtfsvalidator/parsing/RowParserTest.java # processor/src/main/java/org/mobilitydata/gtfsvalidator/processor/TableLoaderGenerator.java
- use special code ZZ for unknown or invalid territories - adapt unit tests - override toString - remove support for null value
|
Thanks @aababilov for reviewing! I provided the changes you suggested in the previous commits. At the exception of this one: #851 (comment)
Since we do not have support for |
main/src/test/java/org/mobilitydata/gtfsvalidator/cli/ArgumentsTest.java
Outdated
Show resolved
Hide resolved
|
Beautiful! Please format the code and submit it, I can't wait to see it in upstream! |
|
Thanks @aababilov for this feedback! |
closes #539
Summary:
This PR provides support to make
-fan optional argument when running the validator. This is required to run the validator programatically for:Expected behavior:
if
-fis now optional. If provided, phone numbers will be validated according to the country code, else phone number validation is skipped.No NPEs should be thrown.
Please make sure these boxes are checked before submitting your pull request - thanks!
gradle testto make sure you didn't break anything[ ] Include screenshot(s) showing how this pull request works and fixes the issue(s)