Fixed issues reported by SonarQube with tag 'bad-practice'.

This commit is contained in:
Aditya Toshniwal 2020-06-22 12:18:59 +05:30 committed by Akshay Joshi
parent 9e40995ab0
commit 6620f9263d
4 changed files with 50 additions and 60 deletions

View File

@ -1056,16 +1056,16 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
create_req = False create_req = False
for key in required_create_keys: for key in required_create_keys:
if key in diff_dict: if key in diff_dict and \
if (key == 'columns' and (( ((key == 'columns' and
'added' in diff_dict[key] and (('added' in diff_dict[key] and
len(diff_dict[key]['added']) > 0 len(diff_dict[key]['added']) > 0) or
) or ('changed' in diff_dict[key] and ('changed' in diff_dict[key] and
len(diff_dict[key]['changed']) > 0) or ( len(diff_dict[key]['changed']) > 0) or
'deleted' in diff_dict[key] and ('deleted' in diff_dict[key] and
len(diff_dict[key]['deleted']) > 0) len(diff_dict[key]['deleted']) > 0))) or
)) or key != 'columns': key != 'columns'):
create_req = True create_req = True
if create_req: if create_req:
diff = self.get_sql_from_index_diff(sid=src_params['sid'], diff = self.get_sql_from_index_diff(sid=src_params['sid'],

View File

@ -17,32 +17,30 @@ define(
title = _.escape(title); title = _.escape(title);
message = _.escape(message); message = _.escape(message);
info = _.escape(info); info = _.escape(info);
let text = '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">\ let text ='<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">'
<div class="panel panel-default">\ + '<div class="panel panel-default">'
<div class="panel-heading" role="tab" id="headingOne">\ + '<div class="panel-heading" role="tab" id="headingOne">'
<h4 class="panel-title">\ + '<h4 class="panel-title">'
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">\ + '<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">' + gettext('Error message') + '</a>'
' + gettext('Error message') + '</a>\ + '</h4>'
</h4>\ + '</div>'
</div>\ + '<div id="collapseOne" class="panel-collapse collapse show" role="tabpanel" aria-labelledby="headingOne">'
<div id="collapseOne" class="panel-collapse collapse show" role="tabpanel" aria-labelledby="headingOne">\ + '<div class="panel-body" style="overflow: auto;">' + message + '</div>'
<div class="panel-body" style="overflow: auto;">' + message + '</div>\ + '</div>'
</div>\ + '</div>';
</div>';
if (info != null && info != '') { if (info != null && info != '') {
text += '<div class="panel panel-default">\ text += '<div class="panel panel-default">'
<div class="panel-heading" role="tab" id="headingTwo">\ + '<div class="panel-heading" role="tab" id="headingTwo">'
<h4 class="panel-title">\ + '<h4 class="panel-title">'
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">\ + '<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">' + gettext('Additional info') + '</a>'
' + gettext('Additional info') + '</a>\ + '</h4>'
</h4>\ + '</div>'
</div>\ + '<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">'
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">\ + '<div class="panel-body" style="overflow: auto;">' + info + '</div>'
<div class="panel-body" style="overflow: auto;">' + info + '</div>\ + '</div>'
</div>\ + '</div>'
</div>\ + '</div>';
</div>';
} }
text += '</div>'; text += '</div>';

View File

@ -60,9 +60,8 @@ define([
}, },
// listen and respond to changes in dialog settings. // listen and respond to changes in dialog settings.
settingUpdated: function(key, oldValue, newValue) { settingUpdated: function(key, oldValue, newValue) {
switch (key) { if(key === 'pg_msg') {
case 'pg_msg': let doc = iframe.contentWindow || iframe.contentDocument;
var doc = iframe.contentWindow || iframe.contentDocument;
if (doc.document) { if (doc.document) {
doc = doc.document; doc = doc.document;
} }
@ -70,8 +69,6 @@ define([
doc.open(); doc.open();
doc.write(newValue); doc.write(newValue);
doc.close(); doc.close();
break;
} }
}, },
// listen to internal dialog events. // listen to internal dialog events.
@ -79,8 +76,7 @@ define([
// triggered when a dialog option gets update. // triggered when a dialog option gets update.
// warning! this will not be triggered for settings updates. // warning! this will not be triggered for settings updates.
onupdate: function(option, oldValue, newValue) { onupdate: function(option, oldValue, newValue) {
switch (option) { if(option === 'resizable') {
case 'resizable':
if (newValue) { if (newValue) {
this.elements.content.removeAttribute('style'); this.elements.content.removeAttribute('style');
iframe && iframe.removeAttribute('style'); iframe && iframe.removeAttribute('style');
@ -88,7 +84,6 @@ define([
this.elements.content.style.minHeight = 'inherit'; this.elements.content.style.minHeight = 'inherit';
iframe && (iframe.style.minHeight = 'inherit'); iframe && (iframe.style.minHeight = 'inherit');
} }
break;
} }
}, },
}, },
@ -124,13 +119,13 @@ define([
if (contentType.indexOf('text/html') == 0) { if (contentType.indexOf('text/html') == 0) {
var alertMessage = promptmsg; var alertMessage = promptmsg;
if (type === 'error') { if (type === 'error') {
alertMessage = '\ alertMessage =
<div class="media text-danger text-14">\ '<div class="media text-danger text-14">'
<div class="media-body media-middle">\ + '<div class="media-body media-middle">'
<div class="alert-text" role="alert">' + promptmsg + '</div><br/>\ + '<div class="alert-text" role="alert">' + promptmsg + '</div><br/>'
<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>\ + '<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>'
</div>\ + '</div>'
</div>'; + '</div>';
} }
alertify.notify( alertify.notify(
@ -173,13 +168,13 @@ define([
} }
} }
if (contentType.indexOf('text/html') >= 0) { if (contentType.indexOf('text/html') >= 0) {
var alertMessage = '\ var alertMessage =
<div class="media text-danger text-14">\ '<div class="media text-danger text-14">'
<div class="media-body media-middle">\ + '<div class="media-body media-middle">'
<div class="alert-text" role="alert">' + gettext('INTERNAL SERVER ERROR') + '</div><br/>\ + '<div class="alert-text" role="alert">' + gettext('INTERNAL SERVER ERROR') + '</div><br/>'
<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>\ + '<div class="alert-text" role="alert">' + gettext('Click for details.') + '</div>'
</div>\ + '</div>'
</div>'; + '</div>';
alertify.notify( alertify.notify(
alertMessage, 'error', 0, () => { alertMessage, 'error', 0, () => {

View File

@ -581,15 +581,12 @@ define([
// triggered when a dialog option gets update. // triggered when a dialog option gets update.
onupdate: function(option, oldValue, newValue) { onupdate: function(option, oldValue, newValue) {
if(option === 'resizable') {
switch (option) {
case 'resizable':
if (newValue) { if (newValue) {
this.elements.content.removeAttribute('style'); this.elements.content.removeAttribute('style');
} else { } else {
this.elements.content.style.minHeight = 'inherit'; this.elements.content.style.minHeight = 'inherit';
} }
break;
} }
}, },