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

Implementing switch expressions in flutter_tools/ #145632

Merged
merged 10 commits into from Mar 29, 2024

Conversation

nate-thegrate
Copy link
Contributor

This pull request is step 12 in the journey to make this entire repository more readable.

(previous PRs: #139048, #139882, #141591, #142279, #142634, #142793, #143293, #143496, #143634, #143812, #144580)

We're getting close to the end! 😄

@github-actions github-actions bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop labels Mar 23, 2024
@nate-thegrate nate-thegrate marked this pull request as ready for review March 23, 2024 16:54
Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

Thanks, these look a lot nicer!

Copy link
Member

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com>
@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 29, 2024
@auto-submit auto-submit bot merged commit a17d4b3 into flutter:master Mar 29, 2024
123 checks passed
'attached' => DeviceConnectionInterface.attached,
'wireless' => DeviceConnectionInterface.wireless,
_ => throw Exception('Unsupported DeviceConnectionInterface name "$name"'),
};
}

/// Returns a `DeviceConnectionInterface`'s string name.
String getNameForDeviceConnectionInterface(DeviceConnectionInterface connectionInterface) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could/should be deprecated and usages should just use name!

case ValidationType.partial:
return 'partial';
}
return switch (type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could just have the success -> installed bit and then a default to using name

Copy link
Contributor

Choose a reason for hiding this comment

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

Won't the default make it so that the lint about not using all of the enum values doesn't fire if a new enum value is added (which could have a type name that doesn't match the enum name). Without the default, the lint will require considering this switch when one is added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it would clean things up nicely, but it would also break that style guideline.

But I think it's possible to get rid of the switch expression altogether:

enum ValidationType {
  crash,
  missing,
  partial,
  notAvailable,
  success('installed');

  const ValidationType([this.label]);
  final String? label;

  @override
  String toString() => label ?? name;
}

@nate-thegrate nate-thegrate deleted the switch-expressions-12 branch March 30, 2024 01:00
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Mar 30, 2024
flutter/flutter@8528881...d12ba5c

2024-03-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 08eb5ad6e498 to 3588d31a98f6 (1 revision) (flutter/flutter#146031)
2024-03-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from df581c316485 to 08eb5ad6e498 (2 revisions) (flutter/flutter#146028)
2024-03-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5df1042cd927 to df581c316485 (1 revision) (flutter/flutter#146025)
2024-03-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from dce6ce366c74 to 5df1042cd927 (2 revisions) (flutter/flutter#146024)
2024-03-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 221b49ae4a82 to dce6ce366c74 (1 revision) (flutter/flutter#146023)
2024-03-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0a751669e722 to 221b49ae4a82 (1 revision) (flutter/flutter#146022)
2024-03-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8ec35b6d63ba to 0a751669e722 (2 revisions) (flutter/flutter#146020)
2024-03-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4b6836f8ef00 to 8ec35b6d63ba (3 revisions) (flutter/flutter#146014)
2024-03-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4c079a6ff502 to 4b6836f8ef00 (3 revisions) (flutter/flutter#146010)
2024-03-29 nate.w5687@gmail.com Implementing switch expressions in `flutter_tools/` (flutter/flutter#145632)
2024-03-29 godofredoc@google.com Generate test metrics consistently. (flutter/flutter#145943)
2024-03-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 32c9dab552f0 to 4c079a6ff502 (3 revisions) (flutter/flutter#146007)
2024-03-29 ian@hixie.ch Add flutter_goldens README (flutter/flutter#145278)
2024-03-29 ian@hixie.ch Remove state shared across tests (flutter/flutter#145281)
2024-03-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8480145cc39d to 32c9dab552f0 (1 revision) (flutter/flutter#146005)
2024-03-29 leroux_bruno@yahoo.fr InputDecorator M3 tests migration - Step7 - container (flutter/flutter#145583)
2024-03-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 7176173ea303 to 8480145cc39d (3 revisions) (flutter/flutter#146001)
2024-03-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from b16c0f136cdd to 7176173ea303 (1 revision) (flutter/flutter#145994)
2024-03-29 polinach@google.com Upgrade leak_tracker. (flutter/flutter#145997)
2024-03-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 68aa9ba386e1 to b16c0f136cdd (10 revisions) (flutter/flutter#145990)
2024-03-29 engine-flutter-autoroll@skia.org Roll Packages from 924c7e6 to 51faaa1 (8 revisions) (flutter/flutter#145986)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC dit@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: desktop Running on desktop autosubmit Merge PR when tree becomes green via auto submit App platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants