Skip to content

Conversation

@tonyzhao1
Copy link
Contributor

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.

tonyzhao1 and others added 7 commits August 10, 2018 11:18
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 )
@tonyzhao1
Copy link
Contributor Author

@mehmetf @tvolkert

Copy link
Contributor

@mehmetf mehmetf left a 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();
Copy link
Contributor

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(),
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

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. Thanks for the context.

ValidationResult result;

if (currentCategory.isGrouped) {
if (finishedGroups.contains(currentCategory)) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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

Choose a reason for hiding this comment

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

Where is finishedGroups updated?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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.

@mehmetf
Copy link
Contributor

mehmetf commented Aug 28, 2018

@tvolkert Since this is tooling, please review when you get the chance. This is an important step in making doctor more extensible.

Copy link
Contributor

@tvolkert tvolkert left a 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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.


@override
List<Workflow> get workflows {
_workflows ??= <Workflow>[iosWorkflow, androidWorkflow];
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI - I had to change this code slightly because it introduced an issue on Windows (#21418). I've expanded this to work like the method above it, and only add the workflows to the list if they apply to the host platform.

PR: #21423

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants