Remove test flakiness records with misspelled field

Change-Id: I80f29ebc9aaed33df27fa0ac75d5a38cfd90d1d5
Reviewed-on: https://dart-review.googlesource.com/c/88727
Auto-Submit: William Hesse <whesse@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
diff --git a/tools/bots/update_flakiness.dart b/tools/bots/update_flakiness.dart
index c791b94..514592b 100755
--- a/tools/bots/update_flakiness.dart
+++ b/tools/bots/update_flakiness.dart
@@ -57,14 +57,7 @@
         testData["current"] = result["result"];
         testData["current_counter"] = 1;
       }
-      // Remove this code once all files are updated
-      const occurrencesMisspelled = "occurences";
-      var occurrences = testData[occurrencesMisspelled];
-      if (occurrences != null) {
-        testData["occurrences"] = occurrences;
-        testData.remove(occurrencesMisspelled);
-      }
-      occurrences = testData.putIfAbsent("occurrences", () => <String, dynamic>{});
+      var occurrences = testData.putIfAbsent("occurrences", () => <String, dynamic>{});
       occurrences.putIfAbsent(result["result"], () => 0);
       occurrences[result["result"]]++;
     }
@@ -79,6 +72,9 @@
   for (final key in keys) {
     final testData = data[key];
     if (testData["outcomes"].length < 2) continue;
+    // Remove this code once all files are updated
+    const occurrencesMisspelled = "occurences";
+    if (testData.containsKey(occurrencesMisspelled)) continue;
     // Forgive tests that have become deterministic again. If they flake less
     // than once in a 100 (p<1%), then if they flake again, the probability of
     // them getting past 5 runs of deflaking is 1%^5 = 0.00000001%.