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
authorJared Wein <jwein@mozilla.com>
Thu, 05 Jan 2017 00:38:24 -0500
changeset 456704 3d43f110b88c7b0e4ac3fa5453b2053bf9af77aa
parent 456703 579916ba9456e7be844a36cadf89261cc3cac702
child 456705 0be68b87d9dbd80e343368ea58ab7e4f3e246728
push id40575
push userjwwang@mozilla.com
push dateFri, 06 Jan 2017 02:27:46 +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) {