-
Notifications
You must be signed in to change notification settings - Fork 82
Migrate frontend-server-common to null safety #1650
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
Migrate frontend-server-common to null safety #1650
Conversation
I will delay this a bit until I make sure that frontend_server tests are running and passing: #1657 |
@@ -327,5 +329,5 @@ String _parseBasePathFromIndexHtml(String index) { | |||
} | |||
final contents = file.readAsStringSync(); | |||
final matches = RegExp(r'<base href="/([^>]*)/">').allMatches(contents); | |||
return matches.isEmpty ? '' : matches.first.group(1); | |||
return (matches.isEmpty ? null : matches.first.group(1)) ?? ''; |
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.
Why not matches.isEmpty ? '' : matches.first.group(1)
?
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.
first.group(1)
may be null as well...
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.
Got it! I have an (optional suggestion) to switch this to be an if/else, the ternary and null-coalescing operator together is a bit hard to read.
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!
@@ -104,20 +101,20 @@ class StdoutHandler { | |||
_badState = true; | |||
return; | |||
} | |||
if (message.startsWith(boundaryKey)) { | |||
if (message.startsWith(boundaryKey!)) { |
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.
Can we make boundaryKey non-nullable or handle it being null without the non null assert?
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.
Boundary key is set to null to indicate that the state machine is waiting for the new result from the frontend server (with a new boundary key) so I suspect we cannot make it non-nullable without changing the logic considerably. I will add a new non-null local to simply avoid repetition here.
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.
LGTM with one change requested. Thanks!
Migrate frontend-server-common to null safety
Towards: #1327