Skip to content
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

Merged

Conversation

annagrin
Copy link
Contributor

@annagrin annagrin commented Jun 13, 2022

Migrate frontend-server-common to null safety

Towards: #1327

@annagrin
Copy link
Contributor Author

I will delay this a bit until I make sure that frontend_server tests are running and passing: #1657

@annagrin annagrin requested a review from elliette June 21, 2022 17:12
@@ -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)) ?? '';
Copy link
Contributor

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) ?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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!)) {
Copy link
Contributor

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?

Copy link
Contributor Author

@annagrin annagrin Jun 23, 2022

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.

Copy link
Contributor

@elliette elliette left a 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!

@annagrin annagrin merged commit 3c30561 into dart-lang:master Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants