Skip to content

Conversation

@anisalibegic
Copy link
Contributor

Part of #84014.

@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Jun 7, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla bot added the cla: yes label Jun 7, 2021
assert(path.extension(file.path) == '.html');
final Iterable<String> matches = _pattern.allMatches(file.readAsStringSync())
.map((RegExpMatch m ) => m.group(0));
.map((RegExpMatch m ) => m.group(0)!);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure m.group(0) cannot be null?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe, group(0) should always be non-null since it is the entire match of the pattern [1] and allMatches above only returns matches.

[1] https://master-api.flutter.dev/flutter/dart-core/Match/group.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @goderbauer mentioned, using group(0) while iterating through all matches makes no harm since it won't iterate if there are no matches.. and if there are then it will return an entire match (which must exist) making it safe to use null assertion operator.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

assert(path.extension(file.path) == '.html');
final Iterable<String> matches = _pattern.allMatches(file.readAsStringSync())
.map((RegExpMatch m ) => m.group(0));
.map((RegExpMatch m ) => m.group(0)!);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe, group(0) should always be non-null since it is the entire match of the pattern [1] and allMatches above only returns matches.

[1] https://master-api.flutter.dev/flutter/dart-core/Match/group.html

@fluttergithubbot fluttergithubbot merged commit d90ee21 into flutter:master Jun 8, 2021
@Piinks Piinks added a: null-safety Support for Dart's null safety feature c: tech-debt Technical debt, code quality, testing, etc. labels Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: null-safety Support for Dart's null safety feature c: contributor-productivity Team-specific productivity, code health, technical debt. c: tech-debt Technical debt, code quality, testing, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants