mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed following SonarQube code smells:
1) Remove this useless assignment to a variable. 2) Remove the unused local variable.
This commit is contained in:
parent
374c5e952f
commit
e38c38cd58
@ -91,7 +91,7 @@ class PgAdmin(Flask):
|
|||||||
for key in list(module.__dict__.keys()):
|
for key in list(module.__dict__.keys()):
|
||||||
if isinstance(module.__dict__[key], PgAdminModule):
|
if isinstance(module.__dict__[key], PgAdminModule):
|
||||||
yield module.__dict__[key]
|
yield module.__dict__[key]
|
||||||
except Exception as _:
|
except Exception:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -372,7 +372,7 @@ def create_app(app_name=None):
|
|||||||
os.environ[
|
os.environ[
|
||||||
'CORRUPTED_DB_BACKUP_FILE'] = backup_file_name
|
'CORRUPTED_DB_BACKUP_FILE'] = backup_file_name
|
||||||
app.logger.info('Database migration completed.')
|
app.logger.info('Database migration completed.')
|
||||||
except Exception as e:
|
except Exception:
|
||||||
app.logger.error('Database migration failed')
|
app.logger.error('Database migration failed')
|
||||||
app.logger.error(traceback.format_exc())
|
app.logger.error(traceback.format_exc())
|
||||||
raise RuntimeError('Migration failed')
|
raise RuntimeError('Migration failed')
|
||||||
@ -384,7 +384,7 @@ def create_app(app_name=None):
|
|||||||
try:
|
try:
|
||||||
db_upgrade(app)
|
db_upgrade(app)
|
||||||
os.environ['CORRUPTED_DB_BACKUP_FILE'] = ''
|
os.environ['CORRUPTED_DB_BACKUP_FILE'] = ''
|
||||||
except Exception as e:
|
except Exception:
|
||||||
backup_db_file()
|
backup_db_file()
|
||||||
|
|
||||||
# check all tables are present in the db.
|
# check all tables are present in the db.
|
||||||
@ -785,11 +785,10 @@ def create_app(app_name=None):
|
|||||||
)
|
)
|
||||||
abort(401)
|
abort(401)
|
||||||
login_user(user)
|
login_user(user)
|
||||||
elif config.SERVER_MODE and \
|
elif config.SERVER_MODE and not current_user.is_authenticated and \
|
||||||
not current_user.is_authenticated and \
|
request.endpoint in ('redirects.index', 'security.login') and \
|
||||||
request.endpoint in ('redirects.index', 'security.login'):
|
app.PGADMIN_EXTERNAL_AUTH_SOURCE in [KERBEROS, WEBSERVER]:
|
||||||
if app.PGADMIN_EXTERNAL_AUTH_SOURCE in [KERBEROS, WEBSERVER]:
|
return authenticate.login()
|
||||||
return authenticate.login()
|
|
||||||
# if the server is restarted the in memory key will be lost
|
# if the server is restarted the in memory key will be lost
|
||||||
# but the user session may still be active. Logout the user
|
# but the user session may still be active. Logout the user
|
||||||
# to get the key again when login
|
# to get the key again when login
|
||||||
|
@ -91,7 +91,7 @@ class WebserverAuthentication(BaseAuthentication):
|
|||||||
"Webserver authenticate failed.")
|
"Webserver authenticate failed.")
|
||||||
|
|
||||||
session['pass_enc_key'] = ''.join(
|
session['pass_enc_key'] = ''.join(
|
||||||
(random.choice(string.ascii_lowercase) for x in range(10)))
|
(random.choice(string.ascii_lowercase) for _ in range(10)))
|
||||||
useremail = request.environ.get('mail')
|
useremail = request.environ.get('mail')
|
||||||
if not useremail:
|
if not useremail:
|
||||||
useremail = ''
|
useremail = ''
|
||||||
|
@ -1296,9 +1296,6 @@ WHERE
|
|||||||
)
|
)
|
||||||
status, res = conn.execute_scalar(SQL)
|
status, res = conn.execute_scalar(SQL)
|
||||||
|
|
||||||
if not status:
|
|
||||||
return status, res
|
|
||||||
|
|
||||||
return status, res
|
return status, res
|
||||||
|
|
||||||
@check_precondition()
|
@check_precondition()
|
||||||
@ -1325,7 +1322,7 @@ WHERE
|
|||||||
for k, v in rargs.items():
|
for k, v in rargs.items():
|
||||||
try:
|
try:
|
||||||
data[k] = json.loads(v, encoding='utf-8')
|
data[k] = json.loads(v, encoding='utf-8')
|
||||||
except ValueError as ve:
|
except ValueError:
|
||||||
data[k] = v
|
data[k] = v
|
||||||
|
|
||||||
required_args = ['role_op', 'did', 'old_role_name',
|
required_args = ['role_op', 'did', 'old_role_name',
|
||||||
|
@ -266,7 +266,7 @@ def remove_saved_passwords(user_id):
|
|||||||
.filter(Server.user_id == user_id) \
|
.filter(Server.user_id == user_id) \
|
||||||
.update({Server.password: None, Server.tunnel_password: None})
|
.update({Server.password: None, Server.tunnel_password: None})
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
except Exception as _:
|
except Exception:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
|||||||
test_gui_helper.close_process_watcher(self)
|
test_gui_helper.close_process_watcher(self)
|
||||||
test_gui_helper.close_bgprocess_popup(self)
|
test_gui_helper.close_bgprocess_popup(self)
|
||||||
self.page.remove_server(self.server)
|
self.page.remove_server(self.server)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print("PGUtilitiesBackupFeatureTest - "
|
print("PGUtilitiesBackupFeatureTest - "
|
||||||
"Exception occurred in after method")
|
"Exception occurred in after method")
|
||||||
finally:
|
finally:
|
||||||
@ -221,7 +221,6 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
|||||||
click = False
|
click = False
|
||||||
except Exception:
|
except Exception:
|
||||||
retry -= 1
|
retry -= 1
|
||||||
pass
|
|
||||||
|
|
||||||
def initiate_restore(self):
|
def initiate_restore(self):
|
||||||
tools_menu = self.driver.find_element(
|
tools_menu = self.driver.find_element(
|
||||||
@ -257,7 +256,6 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
|||||||
click = False
|
click = False
|
||||||
except Exception:
|
except Exception:
|
||||||
retry -= 1
|
retry -= 1
|
||||||
pass
|
|
||||||
|
|
||||||
def _check_escaped_characters(self, source_code, string_to_find, source):
|
def _check_escaped_characters(self, source_code, string_to_find, source):
|
||||||
# For XSS we need to search against element's html code
|
# For XSS we need to search against element's html code
|
||||||
|
@ -170,7 +170,7 @@ class PGUtilitiesMaintenanceFeatureTest(BaseFeatureTest):
|
|||||||
test_utils.delete_table(self.server, self.database_name,
|
test_utils.delete_table(self.server, self.database_name,
|
||||||
self.table_name)
|
self.table_name)
|
||||||
self.page.remove_server(self.server)
|
self.page.remove_server(self.server)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print("PGUtilitiesMaintenanceFeatureTest - "
|
print("PGUtilitiesMaintenanceFeatureTest - "
|
||||||
"Exception occurred in after method")
|
"Exception occurred in after method")
|
||||||
finally:
|
finally:
|
||||||
|
@ -985,7 +985,7 @@ class Filemanager(object):
|
|||||||
try:
|
try:
|
||||||
# Check if the new file is inside the users directory
|
# Check if the new file is inside the users directory
|
||||||
pathlib.Path(new_name).relative_to(the_dir)
|
pathlib.Path(new_name).relative_to(the_dir)
|
||||||
except ValueError as _:
|
except ValueError:
|
||||||
return self.ERROR_NOT_ALLOWED
|
return self.ERROR_NOT_ALLOWED
|
||||||
|
|
||||||
with open(new_name, 'wb') as f:
|
with open(new_name, 'wb') as f:
|
||||||
|
@ -21,7 +21,7 @@ def get_all_themes():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
all_themes.update(json.load(open(theme_file_path)))
|
all_themes.update(json.load(open(theme_file_path)))
|
||||||
except Exception as _:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return all_themes
|
return all_themes
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
||||||
import { Box, makeStyles } from '@material-ui/core';
|
import { Box, makeStyles, Accordion, AccordionSummary, AccordionDetails} from '@material-ui/core';
|
||||||
import {Accordion, AccordionSummary, AccordionDetails} from '@material-ui/core';
|
|
||||||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
||||||
import SaveIcon from '@material-ui/icons/Save';
|
import SaveIcon from '@material-ui/icons/Save';
|
||||||
import PublishIcon from '@material-ui/icons/Publish';
|
import PublishIcon from '@material-ui/icons/Publish';
|
||||||
@ -323,14 +322,13 @@ const getDepChange = (currPath, newState, oldState, action)=>{
|
|||||||
|
|
||||||
const getDeferredDepChange = (currPath, newState, oldState, action)=>{
|
const getDeferredDepChange = (currPath, newState, oldState, action)=>{
|
||||||
if(action.deferredDepChange) {
|
if(action.deferredDepChange) {
|
||||||
let deferredPromiseList = action.deferredDepChange(currPath, newState, {
|
return action.deferredDepChange(currPath, newState, {
|
||||||
type: action.type,
|
type: action.type,
|
||||||
path: action.path,
|
path: action.path,
|
||||||
value: action.value,
|
value: action.value,
|
||||||
depChange: action.depChange,
|
depChange: action.depChange,
|
||||||
oldState: _.cloneDeep(oldState),
|
oldState: _.cloneDeep(oldState),
|
||||||
});
|
});
|
||||||
return deferredPromiseList;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -821,7 +819,6 @@ function SchemaPropertiesView({
|
|||||||
});
|
});
|
||||||
}, [getInitData]);
|
}, [getInitData]);
|
||||||
|
|
||||||
let fullTabs = [];
|
|
||||||
|
|
||||||
/* A simple loop to get all the controls for the fields */
|
/* A simple loop to get all the controls for the fields */
|
||||||
schema.fields.forEach((field)=>{
|
schema.fields.forEach((field)=>{
|
||||||
@ -831,10 +828,8 @@ function SchemaPropertiesView({
|
|||||||
|
|
||||||
if(field.isFullTab) {
|
if(field.isFullTab) {
|
||||||
tabsClassname[group] = classes.noPadding;
|
tabsClassname[group] = classes.noPadding;
|
||||||
fullTabs.push(group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly = true;
|
|
||||||
if(modeSupported) {
|
if(modeSupported) {
|
||||||
group = groupLabels[group] || group || defaultTab;
|
group = groupLabels[group] || group || defaultTab;
|
||||||
if(field.helpMessageMode && field.helpMessageMode.indexOf(viewHelperProps.mode) == -1) {
|
if(field.helpMessageMode && field.helpMessageMode.indexOf(viewHelperProps.mode) == -1) {
|
||||||
|
@ -52,7 +52,7 @@ class ERDTables(BaseTestGenerator):
|
|||||||
tables_utils.create_table(self.server, self.db_name, tab[0],
|
tables_utils.create_table(self.server, self.db_name, tab[0],
|
||||||
tab[1])
|
tab[1])
|
||||||
connection.close()
|
connection.close()
|
||||||
except Exception as _:
|
except Exception:
|
||||||
self.dropDB()
|
self.dropDB()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ def load_servers():
|
|||||||
|
|
||||||
for item in groups:
|
for item in groups:
|
||||||
all_servers.append(groups[item])
|
all_servers.append(groups[item])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
return internal_server_error(
|
return internal_server_error(
|
||||||
_('Unable to load the specified file.'))
|
_('Unable to load the specified file.'))
|
||||||
else:
|
else:
|
||||||
|
@ -492,7 +492,7 @@ def socket_input(data):
|
|||||||
enter_key_press(data)
|
enter_key_press(data)
|
||||||
else:
|
else:
|
||||||
other_key_press(data)
|
other_key_press(data)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# Delete socket id from sessions.
|
# Delete socket id from sessions.
|
||||||
# request.sid: refer request.sid as socket id.
|
# request.sid: refer request.sid as socket id.
|
||||||
sio.emit('pty-output',
|
sio.emit('pty-output',
|
||||||
|
@ -765,7 +765,6 @@ define('tools.querytool', [
|
|||||||
/* If sql editor is in a new tab, event fired is not available
|
/* If sql editor is in a new tab, event fired is not available
|
||||||
* instead, a poller is set up who will check
|
* instead, a poller is set up who will check
|
||||||
*/
|
*/
|
||||||
//var browser_qt_preferences = pgBrowser.get_preferences_for_module('browser');
|
|
||||||
var open_new_tab_qt = self.browser_preferences.new_browser_tab_open;
|
var open_new_tab_qt = self.browser_preferences.new_browser_tab_open;
|
||||||
if(open_new_tab_qt && open_new_tab_qt.includes('qt')) {
|
if(open_new_tab_qt && open_new_tab_qt.includes('qt')) {
|
||||||
pgBrowser.bind_beforeunload();
|
pgBrowser.bind_beforeunload();
|
||||||
@ -2010,7 +2009,7 @@ define('tools.querytool', [
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
})
|
})
|
||||||
.done(function() {})
|
.done(function() { /* This is intentional */ })
|
||||||
.fail(function() {
|
.fail(function() {
|
||||||
/* history clear fail should not affect query tool */
|
/* history clear fail should not affect query tool */
|
||||||
});
|
});
|
||||||
@ -2437,7 +2436,7 @@ define('tools.querytool', [
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
build:function() {},
|
build:function() {/* */},
|
||||||
settings:{
|
settings:{
|
||||||
message: null,
|
message: null,
|
||||||
},
|
},
|
||||||
@ -2517,7 +2516,7 @@ define('tools.querytool', [
|
|||||||
function() {
|
function() {
|
||||||
self.initTransaction();
|
self.initTransaction();
|
||||||
},
|
},
|
||||||
function(error) {
|
function() {
|
||||||
pgBrowser.Events.trigger(
|
pgBrowser.Events.trigger(
|
||||||
'pgadmin:query_tool:connected_fail:' + self.transId, xhr, error
|
'pgadmin:query_tool:connected_fail:' + self.transId, xhr, error
|
||||||
);
|
);
|
||||||
@ -3430,8 +3429,8 @@ define('tools.querytool', [
|
|||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
data: JSON.stringify(history_entry),
|
data: JSON.stringify(history_entry),
|
||||||
})
|
})
|
||||||
.done(function() {})
|
.done(function() { /* This is intentional */ })
|
||||||
.fail(function() {});
|
.fail(function() { /* This is intentional */ });
|
||||||
|
|
||||||
self.gridView.history_collection.add(history_entry);
|
self.gridView.history_collection.add(history_entry);
|
||||||
},
|
},
|
||||||
@ -5159,7 +5158,7 @@ define('tools.querytool', [
|
|||||||
if(data.data_obj.db_id == db_did && !_.isEqual(db_name, data.data_obj.db_name)) {
|
if(data.data_obj.db_id == db_did && !_.isEqual(db_name, data.data_obj.db_name)) {
|
||||||
|
|
||||||
var message = `Current database has been moved or renamed to ${data.data_obj.db_name}. Click on the OK button to refresh the database name.`,
|
var message = `Current database has been moved or renamed to ${data.data_obj.db_name}. Click on the OK button to refresh the database name.`,
|
||||||
title = self.url_params.title;
|
title = '';
|
||||||
|
|
||||||
if(self.is_query_tool) {// for query tool
|
if(self.is_query_tool) {// for query tool
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ def save_changed_data(changed_data, columns_info, conn, command_obj,
|
|||||||
else:
|
else:
|
||||||
status, res = conn.execute_void(
|
status, res = conn.execute_void(
|
||||||
item['sql'], item['data'])
|
item['sql'], item['data'])
|
||||||
except Exception as _:
|
except Exception:
|
||||||
failure_handle(res, item.get('row_id', 0))
|
failure_handle(res, item.get('row_id', 0))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ def validate_master_password(password):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
except Exception as _:
|
except Exception:
|
||||||
False
|
False
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ def set_masterpass_check_text(password, clear=False):
|
|||||||
.update({User.masterpass_check: masterpass_check})
|
.update({User.masterpass_check: masterpass_check})
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
except Exception as _:
|
except Exception:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -1272,7 +1272,7 @@ class PgadminPage:
|
|||||||
lambda d: d.find_element(By.XPATH, xpath))
|
lambda d: d.find_element(By.XPATH, xpath))
|
||||||
f_scroll, r_scroll = 0, 0
|
f_scroll, r_scroll = 0, 0
|
||||||
return ele
|
return ele
|
||||||
except (TimeoutException, NoSuchElementException) as e:
|
except (TimeoutException, NoSuchElementException):
|
||||||
tree_height = int((self.driver.find_element(
|
tree_height = int((self.driver.find_element(
|
||||||
By.XPATH, "//div[@class='file-tree']/div[1]/div/div").
|
By.XPATH, "//div[@class='file-tree']/div[1]/div/div").
|
||||||
value_of_css_property('height')).split("px")[0])
|
value_of_css_property('height')).split("px")[0])
|
||||||
|
@ -1796,7 +1796,7 @@ def module_patch(*args):
|
|||||||
patch.getter = lambda: imported
|
patch.getter = lambda: imported
|
||||||
patch.attribute = '.'.join(components[i:])
|
patch.attribute = '.'.join(components[i:])
|
||||||
return patch
|
return patch
|
||||||
except Exception as exc:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# did not find a module, just return the default mock
|
# did not find a module, just return the default mock
|
||||||
|
Loading…
Reference in New Issue
Block a user