[polari/wip/fmuellner/more-style-changes: 4/7] Switch switch indentation style



commit 10c68a35096ca231a025bf6cae7103de1027886b
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jul 28 06:10:36 2018 +0200

    Switch switch indentation style
    
    Not my preferred style, but it's what gjs uses, which sort of sets
    the canonical GNOME javascript style ...
    
    https://gitlab.gnome.org/GNOME/polari/merge_requests/93

 lint/eslintrc-legacy.json |   3 +-
 src/connections.js        |  12 +-
 src/ircParser.js          | 344 +++++++++++++++++++++++-----------------------
 src/pasteManager.js       |  30 ++--
 src/roomList.js           |  68 ++++-----
 src/tabCompletion.js      |  22 +--
 src/telepathyClient.js    |  28 ++--
 7 files changed, 253 insertions(+), 254 deletions(-)
---
diff --git a/lint/eslintrc-legacy.json b/lint/eslintrc-legacy.json
index 42b54fb..e4b2fb0 100644
--- a/lint/eslintrc-legacy.json
+++ b/lint/eslintrc-legacy.json
@@ -11,8 +11,7 @@
                 "CallExpression": { "arguments": "first" },
                 "ArrayExpression": "first",
                 "ObjectExpression": "first",
-                "MemberExpression": "off",
-                "SwitchCase": 1
+                "MemberExpression": "off"
             }
         ],
         "quotes": "off"
diff --git a/src/connections.js b/src/connections.js
index f7f7140..d5379a3 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -529,12 +529,12 @@ var ConnectionProperties = GObject.registerClass({
             return;
 
         switch (account.connection_error) {
-            case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REFUSED):
-            case Tp.error_get_dbus_name(Tp.Error.NETWORK_ERROR):
-                this._errorBox.show();
-                this._errorLabel.label = _("Polari disconnected due to a network error. Please check if the 
address field is correct.");
-                this._details.setErrorHint(ErrorHint.SERVER);
-                break;
+        case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REFUSED):
+        case Tp.error_get_dbus_name(Tp.Error.NETWORK_ERROR):
+            this._errorBox.show();
+            this._errorLabel.label = _("Polari disconnected due to a network error. Please check if the 
address field is correct.");
+            this._details.setErrorHint(ErrorHint.SERVER);
+            break;
         }
     }
 });
diff --git a/src/ircParser.js b/src/ircParser.js
index ef55311..4bf5b48 100644
--- a/src/ircParser.js
+++ b/src/ircParser.js
@@ -74,203 +74,203 @@ var IrcParser = class {
         let cmd = argv.shift().toUpperCase();
         let output = null;
         switch (cmd) {
-            case 'HELP': {
-                let command = argv.shift();
-                if (command)
-                    command = command.toUpperCase();
+        case 'HELP': {
+            let command = argv.shift();
+            if (command)
+                command = command.toUpperCase();
 
-                retval = (command == null || knownCommands[command] != null);
+            retval = (command == null || knownCommands[command] != null);
 
-                if (!retval) //error
-                    output = this._createFeedbackLabel(_(UNKNOWN_COMMAND_MESSAGE));
-                else if (command)
-                    output = this._createFeedbackUsage(command);
-                else
-                    output = this._createFeedbackGrid(_("Known commands:"),
-                                                      Object.keys(knownCommands));
+            if (!retval) //error
+                output = this._createFeedbackLabel(_(UNKNOWN_COMMAND_MESSAGE));
+            else if (command)
+                output = this._createFeedbackUsage(command);
+            else
+                output = this._createFeedbackGrid(_("Known commands:"),
+                                                  Object.keys(knownCommands));
+            break;
+        }
+        case 'INVITE': {
+            let nick = argv.shift();
+            if (!nick) {
+                this._createFeedbackUsage(cmd);
+                retval = false;
                 break;
             }
-            case 'INVITE': {
-                let nick = argv.shift();
-                if (!nick) {
-                    this._createFeedbackUsage(cmd);
-                    retval = false;
-                    break;
-                }
-                this._room.channel.connection.dup_contact_by_id_async(nick, [],
-                    (c, res) => {
-                        let contact;
-                        try {
-                            contact = c.dup_contact_by_id_finish(res);
-                        } catch (e) {
-                            logError(e, `Failed to get contact for ${nick}`);
-                            return;
-                        }
-                        this._room.add_member(contact);
-                    });
+            this._room.channel.connection.dup_contact_by_id_async(nick, [],
+                (c, res) => {
+                    let contact;
+                    try {
+                        contact = c.dup_contact_by_id_finish(res);
+                    } catch (e) {
+                        logError(e, `Failed to get contact for ${nick}`);
+                        return;
+                    }
+                    this._room.add_member(contact);
+                });
+            break;
+        }
+        case 'J':
+        case 'JOIN': {
+            let room = argv.shift();
+            if (!room) {
+                output = this._createFeedbackUsage(cmd);
+                retval = false;
                 break;
             }
-            case 'J':
-            case 'JOIN': {
-                let room = argv.shift();
-                if (!room) {
-                    output = this._createFeedbackUsage(cmd);
-                    retval = false;
-                    break;
-                }
-                if (argv.length)
-                    log(`Excess arguments to JOIN command: ${argv}`);
+            if (argv.length)
+                log(`Excess arguments to JOIN command: ${argv}`);
 
-                let account = this._room.account;
-                let app = Gio.Application.get_default();
-                let action = app.lookup_action('join-room');
-                action.activate(GLib.Variant.new('(ssu)',
-                                                 [account.get_object_path(),
-                                                  room,
-                                                  Utils.getTpEventTime()]));
+            let account = this._room.account;
+            let app = Gio.Application.get_default();
+            let action = app.lookup_action('join-room');
+            action.activate(GLib.Variant.new('(ssu)',
+                                             [account.get_object_path(),
+                                              room,
+                                              Utils.getTpEventTime()]));
+            break;
+        }
+        case 'KICK': {
+            let nick = argv.shift();
+            if (!nick) {
+                output = this._createFeedbackUsage(cmd);
+                retval = false;
                 break;
             }
-            case 'KICK': {
-                let nick = argv.shift();
-                if (!nick) {
-                    output = this._createFeedbackUsage(cmd);
-                    retval = false;
-                    break;
-                }
-                this._room.channel.connection.dup_contact_by_id_async(nick, [],
-                    (c, res) => {
-                        let contact;
-                        try {
-                            contact = c.dup_contact_by_id_finish(res);
-                        } catch (e) {
-                            logError(e, `Failed to get contact for ${nick}`);
-                            return;
-                        }
-                        this._room.remove_member(contact);
-                    });
+            this._room.channel.connection.dup_contact_by_id_async(nick, [],
+                (c, res) => {
+                    let contact;
+                    try {
+                        contact = c.dup_contact_by_id_finish(res);
+                    } catch (e) {
+                        logError(e, `Failed to get contact for ${nick}`);
+                        return;
+                    }
+                    this._room.remove_member(contact);
+                });
+            break;
+        }
+        case 'ME': {
+            if (!argv.length) {
+                output = this._createFeedbackUsage(cmd);
+                retval = false;
                 break;
             }
-            case 'ME': {
-                if (!argv.length) {
-                    output = this._createFeedbackUsage(cmd);
-                    retval = false;
-                    break;
-                }
-                let action = stripCommand(text);
-                let type = Tp.ChannelTextMessageType.ACTION;
-                let message = Tp.ClientMessage.new_text(type, action);
-                this._sendMessage(message);
+            let action = stripCommand(text);
+            let type = Tp.ChannelTextMessageType.ACTION;
+            let message = Tp.ClientMessage.new_text(type, action);
+            this._sendMessage(message);
+            break;
+        }
+        case 'MSG': {
+            let nick = argv.shift();
+            let message = argv.join(' ');
+            if (!nick || !message) {
+                output = this._createFeedbackUsage(cmd);
+                retval = false;
                 break;
             }
-            case 'MSG': {
-                let nick = argv.shift();
-                let message = argv.join(' ');
-                if (!nick || !message) {
-                    output = this._createFeedbackUsage(cmd);
-                    retval = false;
-                    break;
-                }
 
-                let account = this._room.account;
+            let account = this._room.account;
 
-                let app = Gio.Application.get_default();
-                let action = app.lookup_action('message-user');
-                action.activate(GLib.Variant.new('(sssu)',
-                                                 [account.get_object_path(),
-                                                  nick,
-                                                  message,
-                                                  Tp.USER_ACTION_TIME_NOT_USER_ACTION]));
-                break;
-            }
-            case 'NAMES': {
-                let channel = this._room.channel;
-                let members = channel.group_dup_members_contacts().map(m => m.alias);
-                output = this._createFeedbackGrid(_("Users on %s:").format(channel.identifier),
-                                                  members);
+            let app = Gio.Application.get_default();
+            let action = app.lookup_action('message-user');
+            action.activate(GLib.Variant.new('(sssu)',
+                                             [account.get_object_path(),
+                                              nick,
+                                              message,
+                                              Tp.USER_ACTION_TIME_NOT_USER_ACTION]));
+            break;
+        }
+        case 'NAMES': {
+            let channel = this._room.channel;
+            let members = channel.group_dup_members_contacts().map(m => m.alias);
+            output = this._createFeedbackGrid(_("Users on %s:").format(channel.identifier),
+                                              members);
+            break;
+        }
+        case 'NICK': {
+            let nick = argv.shift();
+            if (!nick) {
+                output = this._createFeedbackUsage(cmd);
+                retval = false;
                 break;
             }
-            case 'NICK': {
-                let nick = argv.shift();
-                if (!nick) {
-                    output = this._createFeedbackUsage(cmd);
-                    retval = false;
-                    break;
-                }
-                if (argv.length)
-                    log(`Excess arguments to NICK command: ${argv}`);
+            if (argv.length)
+                log(`Excess arguments to NICK command: ${argv}`);
 
-                this._app.setAccountNick(this._room.account, nick);
-                break;
-            }
-            case 'PART':
-            case 'CLOSE': {
-                let room = null;
-                let name = argv[0];
-                if (name)
-                    room = this._roomManager.lookupRoomByName(name, this._room.account);
-                if (room)
-                    argv.shift(); // first arg was a room name
-                else
-                    room = this._room;
+            this._app.setAccountNick(this._room.account, nick);
+            break;
+        }
+        case 'PART':
+        case 'CLOSE': {
+            let room = null;
+            let name = argv[0];
+            if (name)
+                room = this._roomManager.lookupRoomByName(name, this._room.account);
+            if (room)
+                argv.shift(); // first arg was a room name
+            else
+                room = this._room;
 
-                let app = Gio.Application.get_default();
-                let action = app.lookup_action('leave-room');
-                let param = GLib.Variant.new('(ss)', [room.id, argv.join(' ')]);
-                action.activate(param);
+            let app = Gio.Application.get_default();
+            let action = app.lookup_action('leave-room');
+            let param = GLib.Variant.new('(ss)', [room.id, argv.join(' ')]);
+            action.activate(param);
+            break;
+        }
+        case 'QUERY': {
+            let nick = argv.shift();
+            if (!nick) {
+                output = this._createFeedbackUsage(cmd);
+                retval = false;
                 break;
             }
-            case 'QUERY': {
-                let nick = argv.shift();
-                if (!nick) {
-                    output = this._createFeedbackUsage(cmd);
-                    retval = false;
-                    break;
-                }
 
-                let account = this._room.account;
+            let account = this._room.account;
 
-                let app = Gio.Application.get_default();
-                let action = app.lookup_action('message-user');
-                action.activate(GLib.Variant.new('(sssu)',
-                                                 [account.get_object_path(),
-                                                  nick,
-                                                  '',
-                                                  Utils.getTpEventTime()]));
-                break;
-            }
-            case 'QUIT': {
-                let presence = Tp.ConnectionPresenceType.OFFLINE;
-                let message = stripCommand(text);
-                this._room.account.request_presence_async(presence, 'offline', message,
-                    (a, res) => {
-                        try {
-                            a.request_presence_finish(res);
-                        } catch (e) {
-                            logError(e, 'Failed to disconnect');
-                        }
-                    });
-                break;
-            }
-            case 'SAY': {
-                if (!argv.length) {
-                    output = this._createFeedbackUsage(cmd);
-                    retval = false;
-                    break;
-                }
-                this._sendText(stripCommand(text));
-                break;
-            }
-            case 'TOPIC': {
-                if (argv.length)
-                    this._room.set_topic(stripCommand(text));
-                else
-                    output = this._createFeedbackLabel(this._room.topic || _("No topic set"));
-                break;
-            }
-            default:
-                output = this._createFeedbackLabel(_(UNKNOWN_COMMAND_MESSAGE));
+            let app = Gio.Application.get_default();
+            let action = app.lookup_action('message-user');
+            action.activate(GLib.Variant.new('(sssu)',
+                                             [account.get_object_path(),
+                                              nick,
+                                              '',
+                                              Utils.getTpEventTime()]));
+            break;
+        }
+        case 'QUIT': {
+            let presence = Tp.ConnectionPresenceType.OFFLINE;
+            let message = stripCommand(text);
+            this._room.account.request_presence_async(presence, 'offline', message,
+                (a, res) => {
+                    try {
+                        a.request_presence_finish(res);
+                    } catch (e) {
+                        logError(e, 'Failed to disconnect');
+                    }
+                });
+            break;
+        }
+        case 'SAY': {
+            if (!argv.length) {
+                output = this._createFeedbackUsage(cmd);
                 retval = false;
                 break;
+            }
+            this._sendText(stripCommand(text));
+            break;
+        }
+        case 'TOPIC': {
+            if (argv.length)
+                this._room.set_topic(stripCommand(text));
+            else
+                output = this._createFeedbackLabel(this._room.topic || _("No topic set"));
+            break;
+        }
+        default:
+            output = this._createFeedbackLabel(_(UNKNOWN_COMMAND_MESSAGE));
+            retval = false;
+            break;
         }
 
         if (output)
diff --git a/src/pasteManager.js b/src/pasteManager.js
index d22ee53..87f1c8c 100644
--- a/src/pasteManager.js
+++ b/src/pasteManager.js
@@ -131,13 +131,13 @@ var DropTargetIface = GObject.registerClass({
 
         let info = Polari.drag_dest_find_target(widget, context);
         switch (info) {
-            case DndTargetType.TEXT:
-            case DndTargetType.IMAGE:
-            case DndTargetType.URI_LIST:
-                Gdk.drag_status(context, Gdk.DragAction.COPY, time);
-                break;
-            default:
-                return Gdk.EVENT_PROPAGATE;
+        case DndTargetType.TEXT:
+        case DndTargetType.IMAGE:
+        case DndTargetType.URI_LIST:
+            Gdk.drag_status(context, Gdk.DragAction.COPY, time);
+            break;
+        default:
+            return Gdk.EVENT_PROPAGATE;
         }
 
         if (!this._dragHighlight) {
@@ -172,14 +172,14 @@ var DropTargetIface = GObject.registerClass({
         } else {
             let success = false;
             switch (info) {
-                case DndTargetType.TEXT:
-                    this.emit('text-dropped', data.get_text());
-                    success = true;
-                    break;
-                case DndTargetType.IMAGE:
-                    this.emit('image-dropped', data.get_pixbuf());
-                    success = true;
-                    break;
+            case DndTargetType.TEXT:
+                this.emit('text-dropped', data.get_text());
+                success = true;
+                break;
+            case DndTargetType.IMAGE:
+                this.emit('image-dropped', data.get_pixbuf());
+                success = true;
+                break;
             }
             Gtk.drag_finish(context, success, false, time);
         }
diff --git a/src/roomList.js b/src/roomList.js
index 22de603..5e3635f 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -380,46 +380,46 @@ var RoomListHeader = GObject.registerClass({
 
     _getStatusLabel() {
         switch (this._getConnectionStatus()) {
-            case Tp.ConnectionStatus.CONNECTED:
-                return _("Connected");
-            case Tp.ConnectionStatus.CONNECTING:
-                return _("Connecting…");
-            case Tp.ConnectionStatus.DISCONNECTED:
-                return _("Offline");
-            default:
-                return _("Unknown");
+        case Tp.ConnectionStatus.CONNECTED:
+            return _("Connected");
+        case Tp.ConnectionStatus.CONNECTING:
+            return _("Connecting…");
+        case Tp.ConnectionStatus.DISCONNECTED:
+            return _("Offline");
+        default:
+            return _("Unknown");
         }
     }
 
     _getErrorLabel() {
         switch (this._account.connection_error) {
 
-            case Tp.error_get_dbus_name(Tp.Error.CERT_REVOKED):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_INSECURE):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_LIMIT_EXCEEDED):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_INVALID):
-            case Tp.error_get_dbus_name(Tp.Error.ENCRYPTION_ERROR):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_NOT_PROVIDED):
-            case Tp.error_get_dbus_name(Tp.Error.ENCRYPTION_NOT_AVAILABLE):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_UNTRUSTED):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_EXPIRED):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_NOT_ACTIVATED):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_HOSTNAME_MISMATCH):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_FINGERPRINT_MISMATCH):
-            case Tp.error_get_dbus_name(Tp.Error.CERT_SELF_SIGNED):
-                return _("Could not connect to %s in a safe way.").format(this._account.display_name);
-
-            case Tp.error_get_dbus_name(Tp.Error.AUTHENTICATION_FAILED):
-                return _("%s requires a password.").format(this._account.display_name);
-
-            case Tp.error_get_dbus_name(Tp.Error.CONNECTION_FAILED):
-            case Tp.error_get_dbus_name(Tp.Error.CONNECTION_LOST):
-            case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REPLACED):
-            case Tp.error_get_dbus_name(Tp.Error.SERVICE_BUSY):
-                return _("Could not connect to %s. The server is busy.").format(this._account.display_name);
-
-            default:
-                return _("Could not connect to %s.").format(this._account.display_name);
+        case Tp.error_get_dbus_name(Tp.Error.CERT_REVOKED):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_INSECURE):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_LIMIT_EXCEEDED):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_INVALID):
+        case Tp.error_get_dbus_name(Tp.Error.ENCRYPTION_ERROR):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_NOT_PROVIDED):
+        case Tp.error_get_dbus_name(Tp.Error.ENCRYPTION_NOT_AVAILABLE):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_UNTRUSTED):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_EXPIRED):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_NOT_ACTIVATED):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_HOSTNAME_MISMATCH):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_FINGERPRINT_MISMATCH):
+        case Tp.error_get_dbus_name(Tp.Error.CERT_SELF_SIGNED):
+            return _("Could not connect to %s in a safe way.").format(this._account.display_name);
+
+        case Tp.error_get_dbus_name(Tp.Error.AUTHENTICATION_FAILED):
+            return _("%s requires a password.").format(this._account.display_name);
+
+        case Tp.error_get_dbus_name(Tp.Error.CONNECTION_FAILED):
+        case Tp.error_get_dbus_name(Tp.Error.CONNECTION_LOST):
+        case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REPLACED):
+        case Tp.error_get_dbus_name(Tp.Error.SERVICE_BUSY):
+            return _("Could not connect to %s. The server is busy.").format(this._account.display_name);
+
+        default:
+            return _("Could not connect to %s.").format(this._account.display_name);
         }
     }
 });
diff --git a/src/tabCompletion.js b/src/tabCompletion.js
index 4edb4e9..56ab953 100644
--- a/src/tabCompletion.js
+++ b/src/tabCompletion.js
@@ -129,17 +129,17 @@ var TabCompletion = class {
         }
 
         switch (keyval) {
-            case Gdk.KEY_Tab:
-            case Gdk.KEY_Down:
-                this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, 1);
-                return Gdk.EVENT_STOP;
-            case Gdk.KEY_ISO_Left_Tab:
-            case Gdk.KEY_Up:
-                this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, -1);
-                return Gdk.EVENT_STOP;
-            case Gdk.KEY_Escape:
-                this._cancel();
-                return Gdk.EVENT_STOP;
+        case Gdk.KEY_Tab:
+        case Gdk.KEY_Down:
+            this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, 1);
+            return Gdk.EVENT_STOP;
+        case Gdk.KEY_ISO_Left_Tab:
+        case Gdk.KEY_Up:
+            this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, -1);
+            return Gdk.EVENT_STOP;
+        case Gdk.KEY_Escape:
+            this._cancel();
+            return Gdk.EVENT_STOP;
         }
 
         if (Gdk.keyval_to_unicode(keyval) != 0) {
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 6549738..625f7a9 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -74,20 +74,20 @@ class SASLAuthHandler {
         debug(`Auth status for server "${name}": ${statusString}`);
 
         switch (status) {
-            case SASLStatus.NOT_STARTED:
-            case SASLStatus.IN_PROGRESS:
-            case SASLStatus.CLIENT_ACCEPTED:
-                break;
-
-            case SASLStatus.SERVER_SUCCEEDED:
-                this._proxy.AcceptSASLRemote();
-                break;
-
-            case SASLStatus.SUCCEEDED:
-            case SASLStatus.SERVER_FAILED:
-            case SASLStatus.CLIENT_FAILED:
-                this._channel.close_async(null);
-                break;
+        case SASLStatus.NOT_STARTED:
+        case SASLStatus.IN_PROGRESS:
+        case SASLStatus.CLIENT_ACCEPTED:
+            break;
+
+        case SASLStatus.SERVER_SUCCEEDED:
+            this._proxy.AcceptSASLRemote();
+            break;
+
+        case SASLStatus.SUCCEEDED:
+        case SASLStatus.SERVER_FAILED:
+        case SASLStatus.CLIENT_FAILED:
+            this._channel.close_async(null);
+            break;
         }
     }
 


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