mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-09 23:15:58 -06:00
Fixed SonarQube issues.
This commit is contained in:
parent
fa6b77b42c
commit
d1c94ac73d
@ -239,11 +239,11 @@ class AzureProvider(AbsProvider):
|
||||
except ResourceNotFoundError:
|
||||
pass
|
||||
except Exception as e:
|
||||
error(args, e)
|
||||
error(str(e))
|
||||
|
||||
if svr is not None:
|
||||
error(args, 'Azure Database for PostgreSQL instance {} already '
|
||||
'exists.'.format(args.name))
|
||||
error('Azure Database for PostgreSQL instance {} already '
|
||||
'exists.'.format(args.name))
|
||||
|
||||
db_password = self._database_pass if self._database_pass is not None \
|
||||
else args.db_password
|
||||
@ -273,7 +273,7 @@ class AzureProvider(AbsProvider):
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
error(e)
|
||||
error(str(e))
|
||||
|
||||
server = poller.result()
|
||||
|
||||
@ -313,7 +313,7 @@ class AzureProvider(AbsProvider):
|
||||
firewall_rules.append(firewall_rule.__dict__)
|
||||
return firewall_rules
|
||||
|
||||
def _delete_azure_instance(self, args, name):
|
||||
def _delete_azure_instance(self, args):
|
||||
""" Delete an Azure instance """
|
||||
# Obtain the management client object
|
||||
postgresql_client = self._get_azure_client('postgresql')
|
||||
@ -326,7 +326,7 @@ class AzureProvider(AbsProvider):
|
||||
args.name
|
||||
)
|
||||
except Exception as e:
|
||||
error(args, e)
|
||||
error(str(e))
|
||||
|
||||
poller.result()
|
||||
|
||||
@ -353,7 +353,7 @@ class AzureProvider(AbsProvider):
|
||||
|
||||
def cmd_delete_instance(self, args):
|
||||
""" Delete an Azure instance """
|
||||
self._delete_azure_instance(args, args.name)
|
||||
self._delete_azure_instance(args)
|
||||
|
||||
|
||||
def load():
|
||||
|
@ -10,7 +10,6 @@
|
||||
import datetime
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def debug(message):
|
||||
|
@ -828,7 +828,7 @@ class Filemanager(object):
|
||||
path = old
|
||||
path = split_path(path)[0] # extract path
|
||||
|
||||
if not path[-1] == '/':
|
||||
if path[-1] != '/':
|
||||
path += '/'
|
||||
|
||||
newname = new
|
||||
@ -838,8 +838,6 @@ class Filemanager(object):
|
||||
oldpath_sys = "{0}{1}".format(the_dir, old)
|
||||
newpath_sys = "{0}{1}".format(the_dir, newpath)
|
||||
|
||||
error_msg = gettext('Renamed successfully.')
|
||||
code = 1
|
||||
try:
|
||||
os.rename(oldpath_sys, newpath_sys)
|
||||
except Exception as e:
|
||||
@ -865,8 +863,6 @@ class Filemanager(object):
|
||||
|
||||
Filemanager.check_access_permission(the_dir, path)
|
||||
|
||||
err_msg = ''
|
||||
code = 1
|
||||
try:
|
||||
if os.path.isdir(orig_path):
|
||||
os.rmdir(orig_path)
|
||||
@ -886,8 +882,7 @@ class Filemanager(object):
|
||||
return unauthorized(self.ERROR_NOT_ALLOWED['Error'])
|
||||
|
||||
the_dir = self.dir if self.dir is not None else ''
|
||||
err_msg = ''
|
||||
code = 1
|
||||
|
||||
try:
|
||||
path = req.form.get('currentpath')
|
||||
|
||||
@ -930,7 +925,6 @@ class Filemanager(object):
|
||||
Checks whether given file exists or not
|
||||
"""
|
||||
the_dir = self.dir if self.dir is not None else ''
|
||||
err_msg = ''
|
||||
code = 1
|
||||
|
||||
name = unquote(name)
|
||||
@ -1087,16 +1081,16 @@ class Filemanager(object):
|
||||
the_dir, "{}{}".format(path, path)
|
||||
)
|
||||
|
||||
name = os.path.basename(path)
|
||||
filename = os.path.basename(path)
|
||||
if orig_path and len(orig_path) > 0:
|
||||
dir_path = os.path.dirname(orig_path)
|
||||
else:
|
||||
dir_path = os.path.dirname(path)
|
||||
|
||||
response = send_from_directory(dir_path, name,
|
||||
response = send_from_directory(dir_path, filename,
|
||||
mimetype='application/octet-stream',
|
||||
as_attachment=True)
|
||||
response.headers["filename"] = name
|
||||
response.headers["filename"] = filename
|
||||
|
||||
return response
|
||||
|
||||
|
@ -148,13 +148,13 @@ function getTableData(res, node) {
|
||||
}
|
||||
|
||||
function createSingleLineStatistics(data, prettifyFields) {
|
||||
var row = data['rows'][0],
|
||||
let row = data['rows'][0],
|
||||
columns = data['columns'],
|
||||
res = [],
|
||||
name,
|
||||
value;
|
||||
|
||||
for (var idx in columns) {
|
||||
for (let idx in columns) {
|
||||
name = columns[idx]['name'];
|
||||
if (row && row[name]) {
|
||||
value =
|
||||
@ -227,11 +227,11 @@ export default function Statistics({ nodeData, item, node, ...props }) {
|
||||
setLoaderText('');
|
||||
|
||||
if (err?.response?.data?.info == 'CRYPTKEY_MISSING') {
|
||||
Notify.pgNotifier('error', err.request, 'The master password is not set', function(msg) {
|
||||
Notify.pgNotifier('error', err.request, 'The master password is not set', function(mesg) {
|
||||
setTimeout(function() {
|
||||
if (msg == 'CRYPTKEY_SET') {
|
||||
if (mesg == 'CRYPTKEY_SET') {
|
||||
setMsg('No statistics are available for the selected object.');
|
||||
} else if (msg == 'CRYPTKEY_NOT_SET') {
|
||||
} else if (mesg == 'CRYPTKEY_NOT_SET') {
|
||||
setMsg(gettext('The master password is not set.'));
|
||||
}
|
||||
}, 100);
|
||||
|
@ -79,7 +79,7 @@ function parseQuery(query, useRegex=false, matchCase=false) {
|
||||
function getRegexFinder(query) {
|
||||
return (stream) => {
|
||||
query.lastIndex = stream.pos;
|
||||
var match = query.exec(stream.string);
|
||||
let match = query.exec(stream.string);
|
||||
if (match && match.index == stream.pos) {
|
||||
stream.pos += match[0].length || 1;
|
||||
return 'searching';
|
||||
@ -94,7 +94,7 @@ function getRegexFinder(query) {
|
||||
|
||||
function getPlainStringFinder(query, matchCase) {
|
||||
return (stream) => {
|
||||
var matchIndex = (matchCase ? stream.string : stream.string.toLowerCase()).indexOf(query, stream.pos);
|
||||
let matchIndex = (matchCase ? stream.string : stream.string.toLowerCase()).indexOf(query, stream.pos);
|
||||
if(matchIndex == -1) {
|
||||
stream.skipToEnd();
|
||||
} else if(matchIndex == stream.pos) {
|
||||
@ -281,7 +281,7 @@ FindDialog.propTypes = {
|
||||
};
|
||||
|
||||
function handleDrop(editor, e) {
|
||||
var dropDetails = null;
|
||||
let dropDetails = null;
|
||||
try {
|
||||
dropDetails = JSON.parse(e.dataTransfer.getData('text'));
|
||||
|
||||
@ -298,7 +298,7 @@ function handleDrop(editor, e) {
|
||||
return;
|
||||
}
|
||||
|
||||
var cursor = editor.coordsChar({
|
||||
let cursor = editor.coordsChar({
|
||||
left: e.x,
|
||||
top: e.y,
|
||||
});
|
||||
@ -324,7 +324,7 @@ function calcFontSize(fontSize) {
|
||||
return '1em';
|
||||
}
|
||||
|
||||
function handlePaste(editor, e) {
|
||||
function handlePaste(_editor, e) {
|
||||
let copiedText = e.clipboardData.getData('text');
|
||||
checkTrojanSource(copiedText, true);
|
||||
}
|
||||
@ -423,7 +423,7 @@ export default function CodeMirror({currEditor, name, value, options, events, re
|
||||
let pref = pgWindow?.pgAdmin?.Browser?.get_preferences_for_module('sqleditor') || {};
|
||||
if (autocomplete && pref.autocomplete_on_key_press) {
|
||||
editor.current.on('keyup', (cm, event)=>{
|
||||
var pattern = new RegExp('^[ -~]{1}$');
|
||||
let pattern = new RegExp('^[ -~]{1}$');
|
||||
if (!cm.state.completionActive && (event.key == 'Backspace' || pattern.test(event.key))) {
|
||||
OrigCodeMirror.commands.autocomplete(cm, null, {completeSingle: false});
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ export function downloadBlob(blob, fileName) {
|
||||
|
||||
document.body.appendChild(link);
|
||||
|
||||
if (getBrowser() === 'IE' && window.navigator.msSaveBlob) {
|
||||
if (getBrowser() == 'IE' && window.navigator.msSaveBlob) {
|
||||
// IE10+ : (has Blob, but not a[download] or URL)
|
||||
window.navigator.msSaveBlob(blob, fileName);
|
||||
} else {
|
||||
|
@ -253,7 +253,7 @@ export class ResultSetUtils {
|
||||
|
||||
poll() {
|
||||
let delay = 1;
|
||||
var seconds = parseInt((Date.now() - this.startTime.getTime()) / 1000);
|
||||
let seconds = parseInt((Date.now() - this.startTime.getTime()) / 1000);
|
||||
// calculate & return fall back polling timeout
|
||||
if (seconds >= 10 && seconds < 30) {
|
||||
delay = 500;
|
||||
@ -389,7 +389,7 @@ export class ResultSetUtils {
|
||||
|
||||
document.body.appendChild(link);
|
||||
|
||||
if (getBrowser() === 'IE' && window.navigator.msSaveBlob) {
|
||||
if (getBrowser() == 'IE' && window.navigator.msSaveBlob) {
|
||||
// IE10+ : (has Blob, but not a[download] or URL)
|
||||
window.navigator.msSaveBlob(respBlob, fileName);
|
||||
} else {
|
||||
@ -539,7 +539,7 @@ export class ResultSetUtils {
|
||||
|
||||
// Create columns
|
||||
data.colinfo.forEach(function(c) {
|
||||
var isPK = false,
|
||||
let isPK = false,
|
||||
isEditable = data.can_edit && (!self.isQueryTool || c.is_editable);
|
||||
|
||||
// Check whether this column is a primary key
|
||||
|
Loading…
Reference in New Issue
Block a user