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

enable the avoid_dynamic_calls lint #232

Merged
merged 2 commits into from
Feb 18, 2022
Merged

enable the avoid_dynamic_calls lint #232

merged 2 commits into from
Feb 18, 2022

Conversation

devoncarew
Copy link
Contributor

  • enable the avoid_dynamic_calls lint
  • ignore the lint for the test/ directory (there are a fair number of dynamic calls here)
  • address the 2 lint issues found - in lib/src/equality.dart (some computations on ints being added to a map)

@devoncarew devoncarew requested a review from natebosch February 16, 2022 19:07
@@ -212,7 +212,7 @@ abstract class _UnorderedEquality<E, T extends Iterable<E>>
bool equals(T? elements1, T? elements2) {
if (identical(elements1, elements2)) return true;
if (elements1 == null || elements2 == null) return false;
var counts = HashMap(
var counts = HashMap<E, int?>(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should only assign non-null ints.

Suggested change
var counts = HashMap<E, int?>(
var counts = HashMap<E, int>(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but if you look down a few lines, we read from this as well:

var count = counts[e] ?? 0;

And counts[e] could return a null. I suppose I could use something like Map.update() to avoid the using a nullable type, but using a nullable type seems simpler here.

Copy link
Contributor

Choose a reason for hiding this comment

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

The null is only when e isn't a present key in the map. We don't need the generic on the map to be nullable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yup, that's the case; I'll make this non-nullable.

@devoncarew devoncarew requested a review from natebosch February 17, 2022 16:21
@devoncarew devoncarew merged commit e1407da into master Feb 18, 2022
@kevmoo kevmoo deleted the avoid_dynamic_calls branch October 19, 2022 01:38
mosuem pushed a commit to dart-lang/core that referenced this pull request Oct 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants