-
Notifications
You must be signed in to change notification settings - Fork 77
Fix alphabetical ordering single element map #2259
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
Conversation
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly fixes an issue with alphabetical ordering when adding to a single-element map by removing an erroneous special case. The logic change is sound, and the updates to existing tests, golden files, and the addition of a new regression test are all appropriate and verify the fix. I have one suggestion to improve the new test case by refactoring it to reduce code duplication, which will enhance its maintainability.
PR HealthLicense Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with
Coverage
|
| File | Coverage |
|---|---|
| pkgs/yaml_edit/lib/src/utils.dart | 💔 98 % ⬇️ 0 % |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check.
Changelog Entry ✔️
| Package | Changed Files |
|---|
Changes to files need to be accounted for in their respective changelogs.
This check can be disabled by tagging the PR with skip-changelog-check.
jonasfj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind, but this only maintains ordering if there is one.. this will now impose ordering on maps with 0 and 1 items, correct?
Perhaps we should make it an option. I don't mind the opinion either though..
No, the code coming after the removed code tests if all the elements are ordered. If so it will insert in the correct spot to preserve ordering. Otherwise it will append to the end. I think that has been the intention all the time, but I think the <=1-element special casing was added by mistake at some point.
I think the current behavior is a pretty good default. An option would be ideal - probably a function that selects the index, or just the index? It would require a bit of design, so let's ship this now, and make an option later. |
Fixes: #2258
We just need to skip the weird special casing, and everything works out.