-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Create categories for doctor validators #20758
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
Conversation
This reverts commit 05c2880.
category (e.g. IntelliJ). Also make Android Studio and Android toolchain use separate categories. At this stage, flutter doctor output matches what it was previously. (The summary() method itself has not yet been changed )
Output is still unchanged.
muddying the pull.
# Conflicts: # bin/internal/engine.version
mehmetf
left a comment
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.
Good first cut! Some comments.
| class AndroidWorkflow extends DoctorValidator implements Workflow { | ||
| AndroidWorkflow() : super('Android toolchain - develop for Android devices'); | ||
| class AndroidWorkflow implements Workflow { | ||
| AndroidWorkflow(); |
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.
You can remove the constructor.
| AndroidSdk: AndroidSdk.locateAndroidSdk, | ||
| AndroidStudio: AndroidStudio.latestValid, | ||
| AndroidWorkflow: () => new AndroidWorkflow(), | ||
| AndroidValidator: () => new AndroidValidator(), |
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.
What's the difference between a validator and a workflow?
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.
Currently, the workflow just checks whether we should run the validators associated with it.
I thought it'd be strange to split a validator and have only one of them with the workflow attached. If it'd be better to keep the workflow on the validator, I don't mind undoing this part of the change.
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 didn't mean for you to undo this change but it would be good to have a better explanation of Validator vs Workflow in comments.
So a workflow is just a collection of validators then?
This is confusing because down below, you have a list of workflows and a list of validators in the same class. Are these just validators that don't belong to any workflow?
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'm more or less breaking the old, implicit relationship where a workflow is-a validator (both workflow classes were also validators and DoctorValidatorProvider also made that assumption), so they're now two totally separate classes. A validator is still a validator (checks for installed software and generates doctor output), while a workflow checks if the environment is one where we can list or launch devices.
The only relation between validators and workflows now is that we use Workflow.appliesToHostPlatform to decide whether to add a validator to the validator list (skipping the iOS validator if we're not on Mac).
The validators in the provider are effectively the same as they used to be. The new workflows list is there because I can no longer have the validators list do double duty, so I'm explicitly listing them instead of using the old code that got them implicitly by checking which validators were also workflows.
Workflow might be a bad name for it now, since the class scope is a lot smaller now that the validator methods have been pulled out. But I don't know what would be a good, unconfusing name.
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. Thanks for the context.
| ValidationResult result; | ||
|
|
||
| if (currentCategory.isGrouped) { | ||
| if (finishedGroups.contains(currentCategory)) { |
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.
When could this happen? Should this be an assert instead?
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 meant to add to finishedGroups after handling a grouped category.
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.
What I meant was whether this is a natural occurrence or not. If the validators are grouped properly and each group executes once, why would we ever see a finished group? If this is valid case, please explain it as a comment above "continue". If it is not a valid case, please assert it (i.e. throw IllegalStateException if it happens).
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.
We're iterating over validators rather than categories. The first time we encounter a category, we skip ahead and round up all the output associated with that category. But we don't modify the validators list at all, so we'll continue to encounter that category (once for each validator in it).
| (DoctorValidator v) => v.category == currentCategory)) { | ||
| results.add(await subValidator.validate()); | ||
| } | ||
| result = _mergeValidationResults(results); |
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.
Where is finishedGroups updated?
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.
See above.
| static const ValidatorCategory flutter = ValidatorCategory('flutter', false); | ||
| static const ValidatorCategory ide = ValidatorCategory('ide', false); | ||
| static const ValidatorCategory device = ValidatorCategory('device', false); | ||
| static const ValidatorCategory other = ValidatorCategory('other', 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.
All grouped is false. Why do we need isGrouped then?
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.
Changed android and ios to true, though since the validators aren't split yet, the true/false value doesn't visibly change anything.
|
@tvolkert Since this is tooling, please review when you get the chance. This is an important step in making doctor more extensible. |
tvolkert
left a comment
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.
Tests?
| // Whether we should bundle results for validators sharing this cateogry, | ||
| // or let each stand alone. | ||
| final bool isGrouped; | ||
| const ValidatorCategory(this.name, this.isGrouped); |
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.
Does this need to be public?
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 used it to create fake grouped categories in the (newly added) tests.
# Conflicts: # packages/flutter_tools/lib/src/doctor.dart
|
|
||
| @override | ||
| List<Workflow> get workflows { | ||
| _workflows ??= <Workflow>[iosWorkflow, androidWorkflow]; |
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.
Defines categories for doctor validators. Modifies diagnose() and summary() to group output based on category for applicable categories. This change should not affect diagnose() and summary() output.
Grouping is currently disabled and will be enabled on a per-category basis in future changes. (This ensures that IDE validators aren't incorrectly grouped together.)
Note: The commit "Change ValidatorCategory to handle..." contains the changes to diagnose() but the commit message does not reflect this.