mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed code smell reported by SonarQube.
This commit is contained in:
@@ -11,8 +11,8 @@ import React, { useCallback } from 'react';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { FormInputText, FormInputSelect, FormInputSwitch, FormInputCheckbox, FormInputColor,
|
||||
FormInputFileSelect, FormInputToggle, InputSwitch, FormInputSQL, FormNote, FormInputDateTimePicker, PlainString } from '../components/FormComponents';
|
||||
import { InputSelect, InputText, InputCheckbox, InputDateTimePicker } from '../components/FormComponents';
|
||||
FormInputFileSelect, FormInputToggle, InputSwitch, FormInputSQL, FormNote, FormInputDateTimePicker, PlainString,
|
||||
InputSelect, InputText, InputCheckbox, InputDateTimePicker } from '../components/FormComponents';
|
||||
import Privilege from '../components/Privilege';
|
||||
import { evalFunc } from 'sources/utils';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
@@ -89,15 +89,11 @@ function isValueEqual(val1, val2) {
|
||||
/* If the orig value was null and new one is empty string, then its a "no change" */
|
||||
/* If the orig value and new value are of different datatype but of same value(numeric) "no change" */
|
||||
/* If the orig value is undefined or null and new value is boolean false "no change" */
|
||||
if ((_.isEqual(val1, val2)
|
||||
return (_.isEqual(val1, val2)
|
||||
|| ((val1 === null || _.isUndefined(val1)) && val2 === '')
|
||||
|| ((val1 === null || _.isUndefined(val1)) && typeof(val2) === 'boolean' && !val2)
|
||||
|| (attrDefined ? _.isEqual(val1.toString(), val2.toString()) : false
|
||||
))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
function getChangedData(topSchema, viewHelperProps, sessData, stringify=false, includeSkipChange=true) {
|
||||
|
||||
@@ -74,8 +74,7 @@ define([
|
||||
return m;
|
||||
}
|
||||
|
||||
var idx = 1,
|
||||
len = _.size(m);
|
||||
var idx, len = _.size(m);
|
||||
|
||||
switch (mode) {
|
||||
case 'properties':
|
||||
|
||||
@@ -1589,9 +1589,10 @@ define([
|
||||
if (_.isUndefined(rawValue) || _.isNull(rawValue)) return '';
|
||||
|
||||
var pass = '';
|
||||
for (var i = 0; i < rawValue.length; i++) {
|
||||
rawValue.forEach(() => {
|
||||
pass += '*';
|
||||
}
|
||||
});
|
||||
|
||||
return pass;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ import axios from 'axios';
|
||||
export function setPGCSRFToken(header, token) {
|
||||
if (!token) {
|
||||
// Throw error message.
|
||||
throw 'csrf-token meta tag has not been set';
|
||||
throw new Error('csrf-token meta tag has not been set');
|
||||
}
|
||||
|
||||
// Configure Backbone.sync to set CSRF-Token-header request header for
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
|
||||
import $ from 'jquery';
|
||||
import Mousetrap from 'mousetrap';
|
||||
import { findAndSetFocus } from './utils';
|
||||
import { parseShortcutValue } from './utils';
|
||||
import { findAndSetFocus, parseShortcutValue } from './utils';
|
||||
|
||||
class dialogTabNavigator {
|
||||
constructor(dialogContainer, backwardShortcut, forwardShortcut) {
|
||||
|
||||
@@ -220,7 +220,7 @@ var Notifier = {
|
||||
}
|
||||
this.alert(promptmsg, msg.replace(new RegExp(/\r?\n/, 'g'), '<br />'));
|
||||
},
|
||||
alert: (title, text, okLabel=gettext('OK'), onOkClick)=>{
|
||||
alert: (title, text, onOkClick, okLabel=gettext('OK'))=>{
|
||||
if(!modalInitialized) {
|
||||
initializeModalProvider();
|
||||
}
|
||||
|
||||
@@ -12,9 +12,8 @@ import { render } from 'react-dom';
|
||||
import { FileTreeX, TreeModelX } from 'pgadmin4-tree';
|
||||
import {Tree} from './tree';
|
||||
|
||||
import { IBasicFileSystemHost } from 'react-aspen';
|
||||
import { IBasicFileSystemHost, Directory } from 'react-aspen';
|
||||
import { ManageTreeNodes } from './tree_nodes';
|
||||
import { Directory } from 'react-aspen';
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
|
||||
var initBrowserTree = async (pgBrowser) => {
|
||||
@@ -29,8 +28,7 @@ var initBrowserTree = async (pgBrowser) => {
|
||||
const host: IBasicFileSystemHost = {
|
||||
pathStyle: 'unix',
|
||||
getItems: async (path) => {
|
||||
let nodes = await mtree.readNode(path);
|
||||
return nodes;
|
||||
return await mtree.readNode(path);
|
||||
},
|
||||
sortComparator: (a: FileEntry | Directory, b: FileEntry | Directory) => {
|
||||
// No nee to sort columns
|
||||
@@ -39,9 +37,13 @@ var initBrowserTree = async (pgBrowser) => {
|
||||
if (a.constructor === b.constructor) {
|
||||
return pgAdmin.natural_sort(a.fileName, b.fileName);
|
||||
}
|
||||
return a.constructor === Directory ? -1
|
||||
: b.constructor === Directory ? 1
|
||||
: 0
|
||||
let retval = 0;
|
||||
if (a.constructor === Directory) {
|
||||
retval = -1;
|
||||
} else if (b.constructor === Directory) {
|
||||
retval = 1;
|
||||
}
|
||||
return retval;
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import _ from 'underscore';
|
||||
import { FileType } from 'react-aspen'
|
||||
import { findInTree } from './tree';
|
||||
|
||||
import { dirname, unix } from 'path-fx';
|
||||
import { unix } from 'path-fx';
|
||||
|
||||
export class ManageTreeNodes {
|
||||
constructor(fs) {
|
||||
@@ -115,17 +115,17 @@ export class ManageTreeNodes {
|
||||
}
|
||||
}
|
||||
|
||||
async function jsonData(url) {
|
||||
let res = await fetch(url, {
|
||||
async function jsonData(fetch_url) {
|
||||
let result = await fetch(fetch_url, {
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'X-pgA-CSRFToken': pgAdmin.csrf_token
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status == 200) {
|
||||
if (result.status == 200) {
|
||||
try {
|
||||
let json = await res.json();
|
||||
let json = await result.json();
|
||||
return json.data;
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
@@ -146,7 +146,7 @@ export class ManageTreeNodes {
|
||||
}
|
||||
}
|
||||
|
||||
let d = await fill(treeData);
|
||||
await fill(treeData);
|
||||
if (node.children.length > 0) res(node.children);
|
||||
else res(null);
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ div.jsoneditor-value[contenteditable=true]:hover
|
||||
.jsoneditor .jsoneditor-text-errors {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border-top: 1px solid $color-gray;;
|
||||
border-top: 1px solid $color-gray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,9 +62,6 @@
|
||||
|
||||
display: -webkit-flex; /* Safari */
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.wcFrameButtonBar {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
|
||||
@@ -363,10 +363,10 @@
|
||||
keyPathAccessor: function(obj, path) {
|
||||
var res = obj;
|
||||
path = path.split('.');
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
for (let path_val of path) {
|
||||
if (_.isNull(res)) return null;
|
||||
if (_.isEmpty(path[i])) continue;
|
||||
if (!_.isUndefined(res[path[i]])) res = res[path[i]];
|
||||
if (_.isEmpty(path_val)) continue;
|
||||
if (!_.isUndefined(res[path_val])) res = res[path_val];
|
||||
}
|
||||
return _.isObject(res) && !_.isArray(res) ? null : res;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user