Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[flutter_plugin_tools] Improve 'repository' check #4244

Merged
merged 3 commits into from Aug 20, 2021

Conversation

stuartmorgan
Copy link
Contributor

Ensures that the full relative path in the 'repository' link is correct,
not just the last segment. This ensure that path-level errors (e.g.,
linking to the group directory rather than the package itself for
app-facing packages) are caught.

Also fixes the errors that this improved check catches, including
several cases where a previously unfederated package wasn't fixed when
it was moved to a subdirectory.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

@flutter-dashboard
Copy link

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@stuartmorgan stuartmorgan removed the request for review from LHLL August 17, 2021 15:48
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -65,8 +66,8 @@ class PubspecCheckCommand extends PackageLoopingCommand {
@override
Future<PackageResult> runForPackage(Directory package) async {
Copy link
Member

Choose a reason for hiding this comment

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

nit: s/package/packageDir here and elsewhere as per my previous comment about packages sometimes being an object, sometimes being a path and sometimes being a directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an override that exists in almost every command in the tool, and it's called package in every case; I really don't want to make just one command inconsistent in this regard.

Instead I'll do a follow-up PR shortly to introduce a Package object that we can start switching over to, and make sure the initial round of conversion in that PR includes all of the runForPackage instances.

errorMessages
.add('The "repository" link should end with the package name.');
} else {
final String packagePath =
Copy link
Member

Choose a reason for hiding this comment

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

nit s/packagePath/relativePackagePath

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, done.

String headerSection(
String name, {
bool isPlugin = false,
bool includeRepository = true,
String? repositoryPackageRelativePath,
Copy link
Member

Choose a reason for hiding this comment

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

Relative to what?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed to repositoryPackagesDirRelativePath, and added discussion of it to the comment (which I completely forgot to do originally).

Comment on lines 445 to 451
containsAllInOrder(<Matcher>[
contains('Missing "implements: plugin_a" in "plugin" section.'),
]),
Copy link
Member

Choose a reason for hiding this comment

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

FYI I'm running into this problem with pigeon too where I assert the error text matches for a certain scenario but they are a bit fragile. It would be better to assert on a codename for errors like some other compilers do.

Error: Missing "implements: foo" in "plugin" section. [missing_implements] then use assert(error, contains('[missing_implements]')

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 accidentally sent a PR from a branch that was on top of another PR, rather than master; this isn't actually part of the change. But in general this would apply to the whole tool though, so is worth considering.

The main difference relative to a compiler is that being directly read by humans is the only intended use case for these log messages. That means that the text itself is actually the thing I want to assert on, because if we somehow broke things such that instead of:

Missing "implements: plugin_a" in "plugin" section. [missing_implements]

it just printed:

[missing_implements]

that would be really bad.

I assume what you mean when you say they are fragile is that if the wording of the message changes, the tests need to change as well. Sometimes that is indeed mildly annoying (e.g., if it's a typo fix) but in most cases that's actually the desired outcome because having a clear, detailed error message is a critical part of the desired behavior.

(There's also no "ignore missing_implements" option, nor do we ever intend to build one since this isn't a general-purpose tool, which is the other main use case for having those kind of machine-friendly error names.)

Ensures that the full relative path in the 'repository' link is correct,
not just the last segment. This ensure that path-level errors (e.g.,
linking to the group directory rather than the package itself for
app-facing packages) are caught.

Also fixes the errors that this improved check catches, including
several cases where a previously unfederated package wasn't fixed when
it was moved to a subdirectory.
@stuartmorgan
Copy link
Contributor Author

submit-queue status is wrong yet again; landing into what is actually a green tree.

@stuartmorgan stuartmorgan merged commit b1fe191 into flutter:master Aug 20, 2021
@stuartmorgan stuartmorgan deleted the pubspec-check-repository branch August 20, 2021 18:50
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 20, 2021
fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
Ensures that the full relative path in the 'repository' link is correct,
not just the last segment. This ensure that path-level errors (e.g.,
linking to the group directory rather than the package itself for
app-facing packages) are caught.

Also fixes the errors that this improved check catches, including
several cases where a previously unfederated package wasn't fixed when
it was moved to a subdirectory.
amantoux pushed a commit to amantoux/plugins that referenced this pull request Sep 27, 2021
Ensures that the full relative path in the 'repository' link is correct,
not just the last segment. This ensure that path-level errors (e.g.,
linking to the group directory rather than the package itself for
app-facing packages) are caught.

Also fixes the errors that this improved check catches, including
several cases where a previously unfederated package wasn't fixed when
it was moved to a subdirectory.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants