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

Simplify package_meta.dart #3572

Merged
merged 2 commits into from
Nov 6, 2023
Merged

Conversation

srawlins
Copy link
Member

@srawlins srawlins commented Nov 5, 2023

A few things:

  • PackageMetaProvider.getMessageForMissingPackageMeta was a very round-about way to provide some text to an error-message. It turns out every single call site referenced the same message, so just tear down all of the redirection.
  • Make PackageMeta.pathContext private.
  • Simplify PackageMetaProvider.fromDir with putIfAbsent.

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

///
/// For a given directory to be detected as an SDK, at least one of the given
/// paths must exist, for each list of paths.
// Update `_writeMockSdkBinFiles` in `test/src/utils.dart` if removing any
Copy link
Member

Choose a reason for hiding this comment

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

/// for line 30 and 31?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this is just supposed to be a code comment. Not part of the documentation (a little silly since its a private element).

@@ -104,6 +91,8 @@ class PackageMetaProvider {
///
/// Overriding this is typically done by overriding factories as rest of
/// `dartdoc` creates this object by calling these static factories.
// This class has a single direct subclass in this package, [PubPackageMeta],
Copy link
Member

Choose a reason for hiding this comment

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

Same for here ///?

Copy link
Member Author

Choose a reason for hiding this comment

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

I intended for that to be just an aside, not part of the doc comment. It's a little silly since we don't have clients really, but the docs are on pub. The sentence just didn't seem appropriate for a doc comment.

reasons.add('no name found in pubspec.yaml');
}
return reasons;
return [
Copy link
Member

Choose a reason for hiding this comment

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

It feels a little weird how this List and its conditional values are regenerated every time we want to check isValid. If _pubspec is final, could we not have just saved this as a field or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be easy to compute this value, even if multiple times (I think it's only a few times per package; not like a few times per field-being-documented or something.

We're following "Avoid storing what you can calculate" here. (Not that it would take much storage, one field per package as well.)

What I'd like to do is rename it and make it a getter (so it could be a field (without creating a private backing field)), but that is a breaking change with google3 so... too much work.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. Thanks for the explanation!

@srawlins srawlins merged commit acc64ad into dart-lang:main Nov 6, 2023
9 checks passed
@srawlins srawlins deleted the simplify-package-meta branch November 6, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants