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

feat: add avoid-shrink-wrap-in-lists #918

Merged
merged 2 commits into from
Jul 20, 2022
Merged

Conversation

incendial
Copy link
Member

@incendial incendial commented Jul 12, 2022

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix
[X] New rule
[ ] Changes an existing rule
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Implementing https://github.com/dart-lang/linter/issues/3496

@incendial incendial requested a review from dkrutskikh July 12, 2022 18:29
@incendial incendial self-assigned this Jul 12, 2022
@incendial incendial added type: enhancement New feature or request area-rules labels Jul 12, 2022
@incendial incendial added this to the 4.17.0 milestone Jul 12, 2022
@github-actions
Copy link

github-actions bot commented Jul 12, 2022

Dart Code Metrics unused files report of dart_code_metrics. ✅

Summary

  • Scanned package folders: bin, example, lib
  • No unused files found! ✅

@github-actions
Copy link

github-actions bot commented Jul 12, 2022

Dart Code Metrics analyze report of dart_code_metrics. ✅

Summary

  • Scanned folders: bin, example, lib, test

  • Total scanned files: 460

  • Total lines of source code: 8040

  • Total classes: 318

  • Average Cyclomatic Number per line of code: 0.35

  • Average Source Lines of Code per method: 6

  • Total tech debt: 1382.0 hours

  • Found issues: 6 ⚠

@codecov
Copy link

codecov bot commented Jul 12, 2022

Codecov Report

Merging #918 (1719595) into master (9fd3b58) will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     dart-lang/linter#918      +/-   ##
==========================================
+ Coverage   87.45%   87.52%   +0.06%     
==========================================
  Files         304      306       +2     
  Lines        6266     6300      +34     
==========================================
+ Hits         5480     5514      +34     
  Misses        786      786              
Impacted Files Coverage Δ
...c/analyzers/lint_analyzer/rules/rules_factory.dart 71.42% <ø> (ø)
...wrap_in_lists/avoid_shrink_wrap_in_lists_rule.dart 100.00% <100.00%> (ø)
...rules_list/avoid_shrink_wrap_in_lists/visitor.dart 100.00% <100.00%> (ø)
lib/src/utils/flutter_types_utils.dart 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9fd3b58...1719595. Read the comment docs.

) !=
null;

bool _hasParentList(InstanceCreationExpression node) =>
Copy link

@gabrielaraujoz gabrielaraujoz Jul 13, 2022

Choose a reason for hiding this comment

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

hey @incendial , awesome work! I took the liberty of reviewing your PR and I think there's one way to make it even better: when we have a list inside another like we're testing, we usually have to wrap them in an Expanded Widget (check the bad case scenario). Because of that, I believe it would be better if we test for that case as well in this rule.

WDYT? Does that make sense to you? Let me know if you need me to make the adjustments for you, I'd be glad to help!

Copy link
Member Author

@incendial incendial Jul 14, 2022

Choose a reason for hiding this comment

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

@gabrielaraujoz hi! Thanks for taking a look. Do you mean that we should first check if the ListView is in the Expanded and then if it's in the Column/Row/ListView?

Choose a reason for hiding this comment

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

Hey! If I'd do it, I'd check for both scenarios: if it's parent is an Expanded that has a Column/Row parent and the cases you're currently testing as well.

When working with Column and Row, if you have a widget with unbounded height/width you need to wrap it in a Flexible or Expanded, else you'll have the unbounded height/width exception. I don't believe this is necessary for ListViews tbh

Copy link
Member Author

Choose a reason for hiding this comment

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

@gabrielaraujoz but it looks like wrapping in Expanded is a subset of all cases when a ListView is in the Column/Row, isn't it? Meaning, that the current check already covers it

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@incendial incendial merged commit 73b31fe into master Jul 20, 2022
@incendial incendial deleted the avoid-shrink-wrap-in-lists branch July 20, 2022 11:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-rules type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants