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()):
|
||||
if isinstance(module.__dict__[key], PgAdminModule):
|
||||
yield module.__dict__[key]
|
||||
except Exception as _:
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
@property
|
||||
@ -372,7 +372,7 @@ def create_app(app_name=None):
|
||||
os.environ[
|
||||
'CORRUPTED_DB_BACKUP_FILE'] = backup_file_name
|
||||
app.logger.info('Database migration completed.')
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
app.logger.error('Database migration failed')
|
||||
app.logger.error(traceback.format_exc())
|
||||
raise RuntimeError('Migration failed')
|
||||
@ -384,7 +384,7 @@ def create_app(app_name=None):
|
||||
try:
|
||||
db_upgrade(app)
|
||||
os.environ['CORRUPTED_DB_BACKUP_FILE'] = ''
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
backup_db_file()
|
||||
|
||||
# check all tables are present in the db.
|
||||
@ -785,11 +785,10 @@ def create_app(app_name=None):
|
||||
)
|
||||
abort(401)
|
||||
login_user(user)
|
||||
elif config.SERVER_MODE and \
|
||||
not current_user.is_authenticated and \
|
||||
request.endpoint in ('redirects.index', 'security.login'):
|
||||
if app.PGADMIN_EXTERNAL_AUTH_SOURCE in [KERBEROS, WEBSERVER]:
|
||||
return authenticate.login()
|
||||
elif config.SERVER_MODE and not current_user.is_authenticated and \
|
||||
request.endpoint in ('redirects.index', 'security.login') and \
|
||||
app.PGADMIN_EXTERNAL_AUTH_SOURCE in [KERBEROS, WEBSERVER]:
|
||||
return authenticate.login()
|
||||
# if the server is restarted the in memory key will be lost
|
||||
# but the user session may still be active. Logout the user
|
||||
# to get the key again when login
|
||||
|
@ -91,7 +91,7 @@ class WebserverAuthentication(BaseAuthentication):
|
||||
"Webserver authenticate failed.")
|
||||
|
||||
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')
|
||||
if not useremail:
|
||||
useremail = ''
|
||||
|
@ -1296,9 +1296,6 @@ WHERE
|
||||
)
|
||||
status, res = conn.execute_scalar(SQL)
|
||||
|
||||
if not status:
|
||||
return status, res
|
||||
|
||||
return status, res
|
||||
|
||||
@check_precondition()
|
||||
@ -1325,7 +1322,7 @@ WHERE
|
||||
for k, v in rargs.items():
|
||||
try:
|
||||
data[k] = json.loads(v, encoding='utf-8')
|
||||
except ValueError as ve:
|
||||
except ValueError:
|
||||
data[k] = v
|
||||
|
||||
required_args = ['role_op', 'did', 'old_role_name',
|
||||
|
@ -266,7 +266,7 @@ def remove_saved_passwords(user_id):
|
||||
.filter(Server.user_id == user_id) \
|
||||
.update({Server.password: None, Server.tunnel_password: None})
|
||||
db.session.commit()
|
||||
except Exception as _:
|
||||
except Exception:
|
||||
db.session.rollback()
|
||||
raise
|
||||
|
||||
|
@ -161,7 +161,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
||||
test_gui_helper.close_process_watcher(self)
|
||||
test_gui_helper.close_bgprocess_popup(self)
|
||||
self.page.remove_server(self.server)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
print("PGUtilitiesBackupFeatureTest - "
|
||||
"Exception occurred in after method")
|
||||
finally:
|
||||
@ -221,7 +221,6 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
||||
click = False
|
||||
except Exception:
|
||||
retry -= 1
|
||||
pass
|
||||
|
||||
def initiate_restore(self):
|
||||
tools_menu = self.driver.find_element(
|
||||
@ -257,7 +256,6 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
||||
click = False
|
||||
except Exception:
|
||||
retry -= 1
|
||||
pass
|
||||
|
||||
def _check_escaped_characters(self, source_code, string_to_find, source):
|
||||
# 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,
|
||||
self.table_name)
|
||||
self.page.remove_server(self.server)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
print("PGUtilitiesMaintenanceFeatureTest - "
|
||||
"Exception occurred in after method")
|
||||
finally:
|
||||
|
@ -985,7 +985,7 @@ class Filemanager(object):
|
||||
try:
|
||||
# Check if the new file is inside the users directory
|
||||
pathlib.Path(new_name).relative_to(the_dir)
|
||||
except ValueError as _:
|
||||
except ValueError:
|
||||
return self.ERROR_NOT_ALLOWED
|
||||
|
||||
with open(new_name, 'wb') as f:
|
||||
|
@ -21,7 +21,7 @@ def get_all_themes():
|
||||
|
||||
try:
|
||||
all_themes.update(json.load(open(theme_file_path)))
|
||||
except Exception as _:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return all_themes
|
||||
|
@ -8,8 +8,7 @@
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
||||
import { Box, makeStyles } from '@material-ui/core';
|
||||
import {Accordion, AccordionSummary, AccordionDetails} from '@material-ui/core';
|
||||
import { Box, makeStyles, Accordion, AccordionSummary, AccordionDetails} from '@material-ui/core';
|
||||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
||||
import SaveIcon from '@material-ui/icons/Save';
|
||||
import PublishIcon from '@material-ui/icons/Publish';
|
||||
@ -323,14 +322,13 @@ const getDepChange = (currPath, newState, oldState, action)=>{
|
||||
|
||||
const getDeferredDepChange = (currPath, newState, oldState, action)=>{
|
||||
if(action.deferredDepChange) {
|
||||
let deferredPromiseList = action.deferredDepChange(currPath, newState, {
|
||||
return action.deferredDepChange(currPath, newState, {
|
||||
type: action.type,
|
||||
path: action.path,
|
||||
value: action.value,
|
||||
depChange: action.depChange,
|
||||
oldState: _.cloneDeep(oldState),
|
||||
});
|
||||
return deferredPromiseList;
|
||||
}
|
||||
};
|
||||
|
||||
@ -821,7 +819,6 @@ function SchemaPropertiesView({
|
||||
});
|
||||
}, [getInitData]);
|
||||
|
||||
let fullTabs = [];
|
||||
|
||||
/* A simple loop to get all the controls for the fields */
|
||||
schema.fields.forEach((field)=>{
|
||||
@ -831,10 +828,8 @@ function SchemaPropertiesView({
|
||||
|
||||
if(field.isFullTab) {
|
||||
tabsClassname[group] = classes.noPadding;
|
||||
fullTabs.push(group);
|
||||
}
|
||||
|
||||
readonly = true;
|
||||
if(modeSupported) {
|
||||
group = groupLabels[group] || group || defaultTab;
|
||||
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],
|
||||
tab[1])
|
||||
connection.close()
|
||||
except Exception as _:
|
||||
except Exception:
|
||||
self.dropDB()
|
||||
raise
|
||||
|
||||
|
@ -174,7 +174,7 @@ def load_servers():
|
||||
|
||||
for item in groups:
|
||||
all_servers.append(groups[item])
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
return internal_server_error(
|
||||
_('Unable to load the specified file.'))
|
||||
else:
|
||||
|
@ -492,7 +492,7 @@ def socket_input(data):
|
||||
enter_key_press(data)
|
||||
else:
|
||||
other_key_press(data)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
# Delete socket id from sessions.
|
||||
# request.sid: refer request.sid as socket id.
|
||||
sio.emit('pty-output',
|
||||
|
@ -765,7 +765,6 @@ define('tools.querytool', [
|
||||
/* If sql editor is in a new tab, event fired is not available
|
||||
* 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;
|
||||
if(open_new_tab_qt && open_new_tab_qt.includes('qt')) {
|
||||
pgBrowser.bind_beforeunload();
|
||||
@ -2010,7 +2009,7 @@ define('tools.querytool', [
|
||||
method: 'DELETE',
|
||||
contentType: 'application/json',
|
||||
})
|
||||
.done(function() {})
|
||||
.done(function() { /* This is intentional */ })
|
||||
.fail(function() {
|
||||
/* history clear fail should not affect query tool */
|
||||
});
|
||||
@ -2437,7 +2436,7 @@ define('tools.querytool', [
|
||||
},
|
||||
};
|
||||
},
|
||||
build:function() {},
|
||||
build:function() {/* */},
|
||||
settings:{
|
||||
message: null,
|
||||
},
|
||||
@ -2517,7 +2516,7 @@ define('tools.querytool', [
|
||||
function() {
|
||||
self.initTransaction();
|
||||
},
|
||||
function(error) {
|
||||
function() {
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin:query_tool:connected_fail:' + self.transId, xhr, error
|
||||
);
|
||||
@ -3430,8 +3429,8 @@ define('tools.querytool', [
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(history_entry),
|
||||
})
|
||||
.done(function() {})
|
||||
.fail(function() {});
|
||||
.done(function() { /* This is intentional */ })
|
||||
.fail(function() { /* This is intentional */ });
|
||||
|
||||
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)) {
|
||||
|
||||
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
|
||||
|
||||
|
@ -271,7 +271,7 @@ def save_changed_data(changed_data, columns_info, conn, command_obj,
|
||||
else:
|
||||
status, res = conn.execute_void(
|
||||
item['sql'], item['data'])
|
||||
except Exception as _:
|
||||
except Exception:
|
||||
failure_handle(res, item.get('row_id', 0))
|
||||
raise
|
||||
|
||||
|
@ -57,7 +57,7 @@ def validate_master_password(password):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
except Exception as _:
|
||||
except Exception:
|
||||
False
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ def set_masterpass_check_text(password, clear=False):
|
||||
.update({User.masterpass_check: masterpass_check})
|
||||
db.session.commit()
|
||||
|
||||
except Exception as _:
|
||||
except Exception:
|
||||
db.session.rollback()
|
||||
raise
|
||||
|
||||
|
@ -1272,7 +1272,7 @@ class PgadminPage:
|
||||
lambda d: d.find_element(By.XPATH, xpath))
|
||||
f_scroll, r_scroll = 0, 0
|
||||
return ele
|
||||
except (TimeoutException, NoSuchElementException) as e:
|
||||
except (TimeoutException, NoSuchElementException):
|
||||
tree_height = int((self.driver.find_element(
|
||||
By.XPATH, "//div[@class='file-tree']/div[1]/div/div").
|
||||
value_of_css_property('height')).split("px")[0])
|
||||
|
@ -1796,7 +1796,7 @@ def module_patch(*args):
|
||||
patch.getter = lambda: imported
|
||||
patch.attribute = '.'.join(components[i:])
|
||||
return patch
|
||||
except Exception as exc:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# did not find a module, just return the default mock
|
||||
|
Loading…
Reference in New Issue
Block a user