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
This commit is contained in:
Florian Müllner 2019-01-30 00:22:10 +01:00
parent e2e02c9a2f
commit d008c6c5c5
2 changed files with 4 additions and 2 deletions

View File

@ -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()));

View File

@ -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