Fixed following code smells reported by SonarQube:

1) Immediately return this expression instead of assigning it to the temporary variable.
 2) Extract this nested ternary operation into an independent statement.
 3) Expected a `for-of` loop instead of a `for` loop with this simple iteration.
This commit is contained in:
Akshay Joshi
2022-01-18 14:49:54 +05:30
parent e3807ec3d6
commit 9f836f5433
62 changed files with 367 additions and 319 deletions

View File

@@ -77,7 +77,7 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, pgBrowser
erdToolEnabled: function(obj) {
/* Same as query tool */
var isEnabled = (() => {
return (() => {
if (!_.isUndefined(obj) && !_.isNull(obj)) {
if (_.indexOf(pgAdmin.unsupported_nodes, obj._type) == -1) {
if (obj._type == 'database' && obj.allowConn) {
@@ -94,7 +94,6 @@ export function initialize(gettext, url_for, $, _, pgAdmin, csrfToken, pgBrowser
return false;
}
})();
return isEnabled;
},
// Callback to draw ERD Tool for objects

View File

@@ -8,9 +8,8 @@
//////////////////////////////////////////////////////////////
import * as React from 'react';
import { CanvasWidget } from '@projectstorm/react-canvas-core';
import { CanvasWidget, Action, InputType } from '@projectstorm/react-canvas-core';
import axios from 'axios';
import { Action, InputType } from '@projectstorm/react-canvas-core';
import PropTypes from 'prop-types';
import _ from 'lodash';
import html2canvas from 'html2canvas';
@@ -40,8 +39,8 @@ export class KeyboardShortcutAction extends Action {
});
this.shortcuts = {};
for(let i=0; i<shortcut_handlers.length; i++){
let [key, handler] = shortcut_handlers[i];
for(let shortcut_val of shortcut_handlers){
let [key, handler] = shortcut_val;
if(key) {
this.shortcuts[this.shortcutKey(key.alt, key.control, key.shift, false, key.key.key_code)] = handler;
}