Skip to content

Conversation

@andrewkolos
Copy link
Contributor

@andrewkolos andrewkolos commented Feb 13, 2024

In service of #143348.

Issue. The equals implementation of AssetsEntry is incorrect. It compares flavors lists using reference equality. This PR addresses this.

This also adds a test to make sure valid asset flavors declarations are parsed correctly.

While we are here, this PR also includes a couple of refactorings:

  • flutter_manifest_test.dart is a bit large. To better match our style guide, I've factored out some related tests into their own file.
  • A couple of changes to the _validateListType function in flutter_manifest.dart:
    • The function now returns a list of errors instead of accepting a list to append onto. This is more readable and also allows callers to know which errors were found by the call.
    • The function is renamed to _validateList and now accepts an Object? instead of an YamlList. If the argument is null, an appropriate error message is contained in the output. This saves callers that are only interested in validation from having to write their own null-check, which they all did before.
    • Some error strings were tweaked for increased readability and/or grammatical correctness.

@andrewkolos andrewkolos added the tool Affects the "flutter" command-line tool. See also t: labels. label Feb 13, 2024
@andrewkolos andrewkolos marked this pull request as ready for review February 13, 2024 04:21
}
return null;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Does ordering matter when you're checking the list of flavors?

For example, do [flavor1, flavor2] and [flavor2, flavor1] mean 2 different things?

Copy link
Contributor Author

@andrewkolos andrewkolos Feb 13, 2024

Choose a reason for hiding this comment

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

addressed in commit express flavors as an unordered set, rather than a list

Logically, they mean the same thing. To capture this idea, I've changed flavors to be a set rather than a list.

I am not 100% sure on the hashing function I wrote, but the chance of unexpected collision should be low. We also don't use it anywhere (only the equals implementation is used in tests).

case 'licenses':
if (yamlValue is! YamlList) {
errors.add('Expected "$yamlKey" to be a list of files, but got $yamlValue (${yamlValue.runtimeType})');
} else if (yamlValue.isEmpty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need to check within this case if the yamlValue.isEmpty and break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Empty lists should pass the _validateList check, so I don't think so.

Copy link
Contributor

@eliasyishak eliasyishak left a comment

Choose a reason for hiding this comment

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

lgtm

@andrewkolos andrewkolos added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 13, 2024
@auto-submit auto-submit bot merged commit 14bcc69 into flutter:master Feb 14, 2024
@andrewkolos andrewkolos deleted the fix-AssetsEntry-equals branch February 14, 2024 00:11
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants