-
Notifications
You must be signed in to change notification settings - Fork 23
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
Parsing option: lenient. #36
Conversation
@@ -116,9 +116,30 @@ class Pubspec { | |||
} | |||
} | |||
|
|||
factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json); | |||
factory Pubspec.fromJson(Map json, {bool lenient = false}) { |
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.
Isn't permissive
a better way to write it?
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.
Dart SDK doesn't have either, and Java's date parsing uses lenient.
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.
Also shouldn't this be the default mode?
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 think defaulting to strict mode is better. (e.g. being explicit that we don't need strict checks).
@@ -116,9 +116,31 @@ class Pubspec { | |||
} | |||
} | |||
|
|||
factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json); | |||
factory Pubspec.fromJson(Map json, {bool lenient = false}) { |
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.
Please add a doc comment describing what lenient
does.
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.
Added, PTAL.
Do we still need this parsing mode if we get rid of the broken package on pub? |
We may not need it right now (assumed that package will be removed), but I'd rather use lenient parsing on the read-access part of the pub site. While we would remember this incident for a few more months, it could be well forgotten in a year or so, and the next similar incident could cause similar issues. Having said that, it may be worth to add logging to |
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.
please do a clean squash-merge 😄
I would, but I have no permission to do so, please do the merge for me. |
A bit of alternative to @jonasfj's per-property parsing: instead of parsing it on per-property, we remove the top-level key on each reporter error.
This does not yet delegate the lenient flag to embedded classes like
Dependency
(and I'm not sure if it is feasible to without eitherjson_serializable
support or using zones).