Thanks to visit codestin.com
Credit goes to github.com

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

[file_selector] Convert XTypeGroup to const #6476

Merged

Conversation

eugerossetto
Copy link
Contributor

Within the file_selector_platform_interface, XTypeGroup constructor was converted to const, meaning that from now on, this object needs to be constructed using const.

Issue:
#111906 [file_selector] XTypeGroup should be immutable

Related PR:
#6463 Annotate all creation of XTypeGroup with // ignore: prefer_const_contructor

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. (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, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM with nits. @ditman can you do the secondary review here?

@@ -31,6 +30,13 @@ class XTypeGroup {
/// The web wild cards for this group (ex: image/*, video/*)
final List<String>? webWildCards;

final List<String>? _extensions;

/// The extensions for this group
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This is missing the period at the end. (If you could fix the other comments' missing periods while you are touching this that would be great.)

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

This looks good to me, however it breaks the current prefer_const_constructors (and will possibly be a breaking change for users of the package (depending on their build config)).

Maybe a major version is too hardcore for this change (but maybe make this 2.2.0?).

Also, we need to deal with the prefer_const_constructors lint. We could disable it so we can land this, and fix usages of XTypeGroup across the repo, or fix Everything Everywhere All At Once in this PR.

Warning: You are using these overridden dependencies:
! file_selector_platform_interface 2.1.1 from path ../../file_selector/file_selector_platform_interface
Running command: "dart analyze --fatal-infos" in /tmp/cirrus-ci-build/packages/image_picker/image_picker_windows
Analyzing image_picker_windows...

   info - lib/image_picker_windows.dart:122:9 - Prefer const with constant constructors. - prefer_const_constructors
   info - lib/image_picker_windows.dart:146:9 - Prefer const with constant constructors. - prefer_const_constructors
   info - lib/image_picker_windows.dart:162:9 - Prefer const with constant constructors. - prefer_const_constructors

3 issues found.


�[31mThe following packages had errors:�[0m
�[31m  file_selector/file_selector�[0m
�[31m  file_selector_ios�[0m
�[31m  file_selector_linux�[0m
�[31m  file_selector_macos�[0m
�[31m  file_selector_web�[0m
�[31m  file_selector_windows�[0m
�[31m  image_picker_windows�[0m

@ditman ditman self-requested a review September 23, 2022 19:02
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

I've seen the PR that prepares the repo to land this. (I still think this might need a higher version number.)

@stuartmorgan-g
Copy link
Contributor

Maybe a major version is too hardcore for this change (but maybe make this 2.2.0?).

We don't consider adding consts to be a semver breaking change, but you're right that a minor change is a better match in semver for this—it's an API change, but a compatible one (other than lints)—so 2.2.0 sounds good.

@eugerossetto
Copy link
Contributor Author

Hi guys, thanks for the feedback, I applied all the requested changes, I hope this looks good for you.
If there's anything else you would like to add/change just let me know.

@ditman
Copy link
Member

ditman commented Sep 23, 2022

Hi guys, thanks for the feedback, I applied all the requested changes, I hope this looks good for you.
If there's anything else you would like to add/change just let me know.

This LGTM, but #6463 needs to land first so this can land without errors in CI.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM with one nit.

You'll need to merge in main now so that analyze will pass.


* Makes XTypeGroup constant and changes the initialization of it.
Copy link
Contributor

Choose a reason for hiding this comment

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

The second part of this is confusing since it's only referring to tests. How about just

* Makes `XTypeGroup`'s constructor constant.

@eugerossetto eugerossetto force-pushed the 111906-xtypegrup-constructor-change branch from 7cd2fd0 to 12e9583 Compare September 26, 2022 18:47
@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 26, 2022
@auto-submit
Copy link

auto-submit bot commented Sep 26, 2022

auto label is removed for flutter/plugins, pr: 6476, due to - The status or check suite legacy-version-analyze CHANNEL:2.10.5 has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite analyze CHANNEL:stable has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite downgraded_analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite analyze CHANNEL:master has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite legacy-version-analyze CHANNEL:3.0.5 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 26, 2022
@stuartmorgan-g
Copy link
Contributor

Looks like the other PR missed a few.

@eugerossetto
Copy link
Contributor Author

eugerossetto commented Sep 26, 2022

Hi Stuart, the pipeline informs that image_picker_windows is having issues with the lint, do you want me to open another PR to fix that?
On the other hand, we see that on CHANNEL:stable, several linters are failing, but we added them on the just merged PR.
This differs from the errors reported on the CHANNEL:master pipeline, which actually does not report failures on the file_selector package, is there something that we missed?
Thanks!

@stuartmorgan-g
Copy link
Contributor

On the other hand, we see that on CHANNEL:stable, several linters are failing, but we added them on the just merged PR. This differs from the errors reported on the CHANNEL:master pipeline, which actually does not report failures on the file_selector package, is there something that we missed? Thanks!

I don't follow the question; both runs that you linked to report the same set of failures. There's apparently another lint violation that you didn't suppress.

You should run dart ../plugins/script/tool/bin/flutter_plugin_tools.dart analyze over a checkout of the repo with this PR applied locally to make sure you've actually fixed all violations of lints that this will cause.

@eugerossetto
Copy link
Contributor Author

Hello Stuart, we're creating a PR to fix the lint issues on the image_picker_windows and another one to fix the new lint issues related to prefer_const_literals_to_create_immutables. In addition, we want to ask you if we should use ignore_for_file instead of ignore in every line, because there are a lot and some of them are just below each other, making them very hard to read.
Thanks!

@stuartmorgan-g
Copy link
Contributor

It's okay to do a file-level ignore since this should be very short-lived.

@baezfacundo baezfacundo force-pushed the 111906-xtypegrup-constructor-change branch from 4bffe59 to 4d1f556 Compare September 30, 2022 17:01
@ditman ditman added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 1, 2022
@auto-submit auto-submit bot merged commit 28c9c0d into flutter:main Oct 1, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 3, 2022
@adpinola adpinola deleted the 111906-xtypegrup-constructor-change branch October 11, 2022 12:46
adam-harwood pushed a commit to adam-harwood/flutter_plugins that referenced this pull request Nov 3, 2022
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: file_selector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants