Bug 1328802 - Enable the no-unsafe-finally rule for eslint and fix the four errors that are triggered by it by moving the control flow statement outside of the finally block. r?mossop draft
authorJared Wein <jwein@mozilla.com>
Thu, 05 Jan 2017 00:38:24 -0500
changeset 456217 0f7907193b38e39dce5b1021a6638d1554727c7e
parent 456216 fd871a9379c992be218e1fff82c3875817c2dd91
child 456218 1212f952dce1e13228dcc4b2efac2c1e0701e5cc
push id40429
push userbmo:jaws@mozilla.com
push dateThu, 05 Jan 2017 05:38:48 +0000
reviewersmossop
bugs1328802
milestone53.0a1
Bug 1328802 - Enable the no-unsafe-finally rule for eslint and fix the four errors that are triggered by it by moving the control flow statement outside of the finally block. r?mossop MozReview-Commit-ID: 7UFBBpvptdd
browser/base/content/browser-gestureSupport.js
toolkit/.eslintrc.js
toolkit/components/telemetry/TelemetryStorage.jsm
toolkit/modules/WindowsRegistry.jsm
toolkit/mozapps/extensions/internal/GMPProvider.jsm
--- a/browser/base/content/browser-gestureSupport.js
+++ b/browser/base/content/browser-gestureSupport.js
@@ -1146,18 +1146,18 @@ var gHistorySwipeAnimation = {
     let url = "";
     try {
       url = URL.createObjectURL(aBlob);
       img.onload = function() {
         URL.revokeObjectURL(url);
       };
     } finally {
       img.src = url;
-      return img;
     }
+    return img;
   },
 
   /**
    * Scales the background of a given box element (which uses a given snapshot
    * as background) based on a given scale factor.
    * @param aSnapshot
    *        The snapshot that is used as background of aBox.
    * @param aScale
--- a/toolkit/.eslintrc.js
+++ b/toolkit/.eslintrc.js
@@ -166,16 +166,19 @@ module.exports = {
     // "no-undef": "error",
 
     // Error on newline where a semicolon is needed
     "no-unexpected-multiline": "error",
 
     // No unreachable statements
     "no-unreachable": "error",
 
+    // Disallow control flow statements in finally blocks
+    "no-unsafe-finally": "error",
+
     // Disallow negating the left operand of relational operators
     "no-unsafe-negation": "error",
 
     // Disallow unused labels
     "no-unused-labels": "error",
 
     // No declaring variables that are never used
     "no-unused-vars": ["error", {
--- a/toolkit/components/telemetry/TelemetryStorage.jsm
+++ b/toolkit/components/telemetry/TelemetryStorage.jsm
@@ -1516,18 +1516,18 @@ var TelemetryStorageImpl = {
           try {
             yield OS.File.remove(file.path);
           } catch (ex) {
             this._log.error("_scanPendingPings - failed to remove file " + file.path, ex);
           } finally {
             Telemetry.getHistogramById("TELEMETRY_DISCARDED_PENDING_PINGS_SIZE_MB")
                      .add(Math.floor(info.size / 1024 / 1024));
             Telemetry.getHistogramById("TELEMETRY_PING_SIZE_EXCEEDED_PENDING").add();
-            continue;
           }
+          continue;
         }
 
         let id = OS.Path.basename(file.path);
         if (!UUID_REGEX.test(id)) {
           this._log.trace("_scanPendingPings - filename is not a UUID: " + id);
           id = Utils.generateUUID();
         }
 
--- a/toolkit/modules/WindowsRegistry.jsm
+++ b/toolkit/modules/WindowsRegistry.jsm
@@ -79,12 +79,12 @@ var WindowsRegistry = {
         registry.removeValue(aKey);
         result = !registry.hasValue(aKey);
       } else {
         result = true;
       }
     } catch (ex) {
     } finally {
       registry.close();
-      return result;
     }
+    return result;
   }
 };
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -307,18 +307,18 @@ GMPWrapper.prototype = {
         this._log.info("findUpdates() - updateTask succeeded for " +
                        this._plugin.id);
       } catch (e) {
         this._log.error("findUpdates() - updateTask for " + this._plugin.id +
                         " threw", e);
         throw e;
       } finally {
         this._updateTask = null;
-        return true;
       }
+      return true;
     }.bind(this));
 
     return this._updateTask;
   },
 
   get pluginMimeTypes() { return []; },
   get pluginLibraries() {
     if (this.isInstalled) {