merge method

IgnoredLeaksSet merge(
  1. IgnoredLeaksSet? other
)

Merges two ignore lists.

In the result object the ignore limit for a class is the maximum of two original ignore limits.

Implementation

IgnoredLeaksSet merge(IgnoredLeaksSet? other) {
  if (other == null) return this;
  final map = {...byClass};
  for (final theClass in other.byClass.keys) {
    if (!map.containsKey(theClass)) {
      map[theClass] = other.byClass[theClass];
      continue;
    }
    final otherCount = other.byClass[theClass];
    final thisCount = byClass[theClass];
    if (thisCount == null || otherCount == null) {
      map[theClass] = null;
      continue;
    }
    map[theClass] = max(thisCount, otherCount);
  }
  return IgnoredLeaksSet(
    byClass: map,
    ignoreAll: ignoreAll || other.ignoreAll,
  );
}