[gnome-shell] cleanup: Avoid variable declarations in case clauses



commit d008c6c5c5a108e740713b2e5a3c39c0c3191234
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Jan 30 00:22:10 2019 +0100

    cleanup: Avoid variable declarations in case clauses
    
    While allowed by the syntax, they are problematic because the
    variable is in the scope of the switch() statement, but only
    valid if a particular case clause is reached.
    
    Add braces to limit the variables' scope to the corresponding
    case clause to avoid that problem.
    
    Spotted by eslint.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607

 js/ui/components/networkAgent.js | 3 ++-
 js/ui/lookingGlass.js            | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/components/networkAgent.js b/js/ui/components/networkAgent.js
index 892e6ca4d..bc653bc60 100644
--- a/js/ui/components/networkAgent.js
+++ b/js/ui/components/networkAgent.js
@@ -679,12 +679,13 @@ var NetworkAgent = class {
         let connectionSetting = connection.get_setting_connection();
         let connectionType = connectionSetting.get_connection_type();
         switch (connectionType) {
-        case '802-11-wireless':
+        case '802-11-wireless': {
             let wirelessSetting = connection.get_setting_wireless();
             let ssid = NM.utils_ssid_to_utf8(wirelessSetting.get_ssid().get_data());
             title = _("Authentication required by wireless network");
             body = _("Passwords or encryption keys are required to access the wireless network 
“%s”.").format(ssid);
             break;
+        }
         case '802-3-ethernet':
             title = _("Wired 802.1X authentication");
             body = _("A password is required to connect to “%s”.".format(connection.get_id()));
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index edcfdecc8..32550b7a3 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -549,7 +549,7 @@ var Inspector = GObject.registerClass({
 
     _onScrollEvent(actor, event) {
         switch (event.get_scroll_direction()) {
-        case Clutter.ScrollDirection.UP:
+        case Clutter.ScrollDirection.UP: {
             // select parent
             let parent = this._target.get_parent();
             if (parent != null) {
@@ -557,6 +557,7 @@ var Inspector = GObject.registerClass({
                 this._update(event);
             }
             break;
+        }
 
         case Clutter.ScrollDirection.DOWN:
             // select child


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]