Fixed SonarQube issues with the tag unused. All the unused variables, assignments, code comments are fixed.

This commit is contained in:
Aditya Toshniwal 2020-06-25 11:09:43 +05:30 committed by Akshay Joshi
parent a1fd9ea3ce
commit d3b3d07f2e
19 changed files with 40 additions and 64 deletions

View File

@ -126,7 +126,7 @@ define('pgadmin.node.rule', [
if (m && m.get('name') == '_RETURN') {
return true;
}
if (m.isNew() || m.node_info.server.version >= 90400) {
if (m.isNew && m.isNew() || m.node_info && m.node_info.server.version >= 90400) {
return false;
}
return true;
@ -236,7 +236,6 @@ define('pgadmin.node.rule', [
//Check if we are not child of rule
var prev_i = t.hasParent(i) ? t.parent(i) : null,
prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null,
prev_e = prev_j ? t.itemData(prev_j) : null,
prev_k = t.hasParent(prev_j) ? t.parent(prev_j) : null,
prev_f = prev_k ? t.itemData(prev_k) : null;
return (_.isNull(prev_f) || prev_f._type != 'catalog');
@ -249,7 +248,7 @@ define('pgadmin.node.rule', [
else if('view' == d._type || 'table' == d._type){
prev_i = t.hasParent(i) ? t.parent(i) : null;
prev_j = t.hasParent(prev_i) ? t.parent(prev_i) : null;
prev_e = prev_j ? t.itemData(prev_j) : null;
var prev_e = prev_j ? t.itemData(prev_j) : null;
return (!_.isNull(prev_e) && prev_e._type == 'schema');
}
i = t.hasParent(i) ? t.parent(i) : null;

View File

@ -282,7 +282,6 @@ def index(sid=None, did=None):
"""
rates = {}
settings = {}
# Get the server version
if sid is not None:

View File

@ -86,10 +86,6 @@ class PGDataypeFeatureTest(BaseFeatureTest):
NavMenuLocators.file_menu_css)
file_menu.click()
# pref_menu_item = self.page.find_by_css_selector(
# NavMenuLocators.preference_menu_item_css)
# pref_menu_item.click()
self.page.retry_click(
(By.CSS_SELECTOR, NavMenuLocators.preference_menu_item_css),
(By.XPATH, NavMenuLocators.specified_preference_tree_node

View File

@ -165,7 +165,7 @@ SELECT generate_series(1, {}) as id1, 'dummy' as id2""".format(
(By.CSS_SELECTOR,
QueryToolLocators.query_output_cells)))
canvas = self.page.find_by_css_selector(
self.page.find_by_css_selector(
QueryToolLocators.query_output_canvas_css)
self._check_ondemand_result(row_id_to_find)
@ -176,7 +176,7 @@ SELECT generate_series(1, {}) as id1, 'dummy' as id2""".format(
self.page.click_execute_query_button()
# wait for header of the table to be visible
canvas = self.page.find_by_css_selector(
self.page.find_by_css_selector(
QueryToolLocators.query_output_canvas_css)
# wait for the rows in the table to be displayed
@ -187,7 +187,6 @@ SELECT generate_series(1, {}) as id1, 'dummy' as id2""".format(
# Select all rows in a table
multiple_check = True
count = 0
while multiple_check:
try:
select_all = self.wait.until(EC.element_to_be_clickable(
@ -196,7 +195,6 @@ SELECT generate_series(1, {}) as id1, 'dummy' as id2""".format(
multiple_check = False
except (StaleElementReferenceException,
ElementClickInterceptedException):
count += 1
pass
self._check_ondemand_result(row_id_to_find)
@ -218,7 +216,7 @@ SELECT generate_series(1, {}) as id1, 'dummy' as id2""".format(
QueryToolLocators.query_output_cells))
)
canvas = self.wait.until(EC.presence_of_element_located(
self.wait.until(EC.presence_of_element_located(
(By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css)))
self._check_ondemand_result(row_id_to_find)
@ -668,8 +666,6 @@ SELECT 1, pg_sleep(300)"""
self.server['sslmode']
)
pg_cursor = connection.cursor()
pg_cursor.execute('select version()')
version_string = pg_cursor.fetchone()
# check if jit is turned on
jit_enabled = False
@ -681,10 +677,6 @@ SELECT 1, pg_sleep(300)"""
except Exception as e:
pass
is_edb = False
if len(version_string) > 0:
is_edb = 'EnterpriseDB' in version_string[0]
connection.close()
return connection.server_version >= 110000 and jit_enabled

View File

@ -38,7 +38,6 @@ class CheckForXssFeatureTest(BaseFeatureTest):
scenarios = [
("Test XSS check for panels and query tool", dict())
]
# test_table_name = "<h1>X"
test_type_name = '"<script>alert(1)</script>"'
def before(self):

View File

@ -242,7 +242,6 @@ def file_manager_config_js():
@login_required
def file_manager_config(trans_id):
"""render the required json"""
# trans_id = Filemanager.create_new_transaction()
data = Filemanager.get_trasaction_selection(trans_id)
pref = Preferences.module('file_manager')
file_dialog_view = pref.preference('file_dialog_view').get()

View File

@ -21,7 +21,7 @@ def user_info():
email = config.DESKTOP_USER
p1 = ''.join([
random.choice(string.ascii_letters + string.digits)
for n in range(32)
for _ in range(32)
])
else:

View File

@ -1577,10 +1577,6 @@ define([
formatter: JSONBCellFormatter,
});
Backgrid.Extension.DatepickerCell = Backgrid.Cell.extend({
editor: DatepickerCellEditor,
});
var DatepickerCellEditor = Backgrid.InputCellEditor.extend({
events: {},
initialize: function() {
@ -1594,12 +1590,16 @@ define([
input.model.trigger(
'backgrid:edited', input.model, input.column, command
);
command = input = null;
input = null;
},
});
},
});
Backgrid.Extension.DatepickerCell = Backgrid.Cell.extend({
editor: DatepickerCellEditor,
});
// Reference:
// https://github.com/wyuenho/backgrid-moment-cell/blob/master/backgrid-moment-cell.js
/**

View File

@ -301,7 +301,7 @@ function keyboardShortcutsQueryTool(
/*open submenu if any*/
if(currLi.hasClass('dropdown-submenu')){
currLi.find('.dropdown-menu').addClass('show');
currLi = currLi.find('.dropdown-menu .dropdown-item').first().trigger('focus');
currLi.find('.dropdown-menu .dropdown-item').first().trigger('focus');
}
} else if(keyCode === LEFT_KEY) {
/*close submenu*/

View File

@ -71,7 +71,7 @@
// Backform Form view
// A collection of field models.
var Form = Backform.Form = Backbone.View.extend({
Backform.Form = Backbone.View.extend({
fields: undefined,
errorModel: undefined,
tagName: "form",
@ -100,8 +100,7 @@
this.cleanup();
this.$el.empty();
var form = this,
$form = this.$el,
var $form = this.$el,
model = this.model,
controls = this.controls;
@ -265,7 +264,6 @@
},
onChange: function(e) {
var model = this.model,
$el = $(e.target),
attrArr = this.field.get("name").split('.'),
name = attrArr.shift(),
path = attrArr.join('.'),
@ -348,10 +346,7 @@
this.clearInvalid();
this.$el.find(':input').not('button').each(function(ix, el) {
var attrArr = $(el).attr('name').split('.'),
name = attrArr.shift(),
path = attrArr.join('.'),
error = self.keyPathAccessor(errorModel.toJSON(), $(el).attr('name'));
var error = self.keyPathAccessor(errorModel.toJSON(), $(el).attr('name'));
if (_.isEmpty(error)) return;
@ -406,9 +401,9 @@
// Built-in controls
var UneditableInputControl = Backform.UneditableInputControl = Control;
Backform.UneditableInputControl = Control;
var HelpControl = Backform.HelpControl = Control.extend({
Backform.HelpControl = Control.extend({
template: _.template([
'<label class="<%=Backform.controlLabelClassName%>">&nbsp;</label>',
'<div class="<%=Backform.controlsClassName%>">',
@ -417,13 +412,13 @@
].join("\n"))
});
var SpacerControl = Backform.SpacerControl = Control.extend({
Backform.SpacerControl = Control.extend({
template: _.template([
'<div class="<%=Backform.controlsClassName%>"></div>'
].join("\n"))
});
var TextareaControl = Backform.TextareaControl = Control.extend({
Backform.TextareaControl = Control.extend({
defaults: {
label: "",
maxlength: 4000,
@ -476,7 +471,7 @@
});
// Note: Value here is null or an array. Since jQuery val() returns either.
var MultiSelectControl = Backform.MultiSelectControl = SelectControl.extend({
Backform.MultiSelectControl = SelectControl.extend({
defaults: {
label: "",
options: [], // List of options as [{label:<label>, value:<value>}, ...]
@ -564,9 +559,9 @@
}
});
var CheckboxControl = Backform.CheckboxControl = BooleanControl;
Backform.CheckboxControl = BooleanControl;
var RadioControl = Backform.RadioControl = InputControl.extend({
Backform.RadioControl = InputControl.extend({
defaults: {
type: "radio",
label: "",
@ -605,7 +600,7 @@
});
// Requires the Bootstrap Datepicker to work.
var DatepickerControl = Backform.DatepickerControl = InputControl.extend({
Backform.DatepickerControl = InputControl.extend({
defaults: {
type: "text",
label: "",
@ -627,7 +622,7 @@
}
});
var ButtonControl = Backform.ButtonControl = Control.extend({
Backform.ButtonControl = Control.extend({
defaults: {
type: "submit",
label: "Submit",

View File

@ -1053,7 +1053,7 @@ var UriCell = Backgrid.UriCell = Cell.extend({
@class Backgrid.EmailCell
@extends Backgrid.StringCell
*/
var EmailCell = Backgrid.EmailCell = StringCell.extend({
Backgrid.EmailCell = StringCell.extend({
/** @property */
className: "email-cell",
@ -1126,7 +1126,7 @@ var NumberCell = Backgrid.NumberCell = Cell.extend({
@class Backgrid.IntegerCell
@extends Backgrid.NumberCell
*/
var IntegerCell = Backgrid.IntegerCell = NumberCell.extend({
Backgrid.IntegerCell = NumberCell.extend({
/** @property */
className: "integer-cell",
@ -1245,7 +1245,7 @@ var DatetimeCell = Backgrid.DatetimeCell = Cell.extend({
@class Backgrid.DateCell
@extends Backgrid.DatetimeCell
*/
var DateCell = Backgrid.DateCell = DatetimeCell.extend({
Backgrid.DateCell = DatetimeCell.extend({
/** @property */
className: "date-cell",
@ -1261,7 +1261,7 @@ var DateCell = Backgrid.DateCell = DatetimeCell.extend({
@class Backgrid.TimeCell
@extends Backgrid.DatetimeCell
*/
var TimeCell = Backgrid.TimeCell = DatetimeCell.extend({
Backgrid.TimeCell = DatetimeCell.extend({
/** @property */
className: "time-cell",
@ -1365,7 +1365,7 @@ var BooleanCellEditor = Backgrid.BooleanCellEditor = CellEditor.extend({
@class Backgrid.BooleanCell
@extends Backgrid.Cell
*/
var BooleanCell = Backgrid.BooleanCell = Cell.extend({
Backgrid.BooleanCell = Cell.extend({
/** @property */
className: "boolean-cell",
@ -2234,7 +2234,7 @@ var EmptyHeaderCell = Backgrid.EmptyHeaderCell = Backbone.View.extend({
@class Backgrid.HeaderRow
@extends Backgrid.Row
*/
var HeaderRow = Backgrid.HeaderRow = Backgrid.Row.extend({
Backgrid.HeaderRow = Backgrid.Row.extend({
/**
Initializer.
@ -2753,7 +2753,7 @@ var Body = Backgrid.Body = Backbone.View.extend({
@class Backgrid.Footer
@extends Backbone.View
*/
var Footer = Backgrid.Footer = Backbone.View.extend({
Backgrid.Footer = Backbone.View.extend({
/** @property */
tagName: "tfoot",
@ -2832,7 +2832,7 @@ var Footer = Backgrid.Footer = Backbone.View.extend({
- Backgrid.Row
- Backgrid.Footer
*/
var Grid = Backgrid.Grid = Backbone.View.extend({
Backgrid.Grid = Backbone.View.extend({
/** @property */
tagName: "table",

View File

@ -820,7 +820,6 @@ define([
Privileges array is generated based on
the type of nodes selected.
*/
var privModel = self.privModel;
var PrivModel = pgNode.Model.extend({
defaults: {
acl: undefined,
@ -849,8 +848,8 @@ define([
present in object privileges array(object_priv)
*/
var data = {};
if (privModel) {
data = privModel.toJSON();
if (self.privModel) {
data = self.privModel.toJSON();
var rolePrivs = data['acl'];
if (!_.isUndefined(rolePrivs) && rolePrivs.length > 0) {
for (var idx in rolePrivs) {
@ -875,7 +874,7 @@ define([
}
// Instantiate privModel
privModel = self.privModel = new PrivModel(data, {
self.privModel = new PrivModel(data, {
node_info: self.info,
});

View File

@ -490,7 +490,7 @@ export default class SchemaDiffUI {
var self = this,
node_type = data.type,
source_oid = data.oid,
target_oid = data.oid;
target_oid;
self.model.set({
'source_ddl': undefined,

View File

@ -338,7 +338,6 @@ def poll(trans_id):
primary_keys = None
types = {}
client_primary_key = None
rset = None
has_oids = False
oids = None
additional_messages = None

View File

@ -36,7 +36,7 @@ class ColParamsJSONDecoder(json.JSONDecoder):
try:
retval = json.JSONDecoder.decode(self, obj)
if type(retval) == str:
retVal = obj
retval = obj
except (ValueError, TypeError, KeyError):
retval = obj

View File

@ -16,7 +16,7 @@ class _PGCSRFProtect(CSRFProtect):
super(_PGCSRFProtect, self).__init__(*args, **kwargs)
def init_app(self, app):
res = super(_PGCSRFProtect, self).init_app(app)
super(_PGCSRFProtect, self).init_app(app)
self._pg_csrf_exempt(app)
def _pg_csrf_exempt(self, app):

View File

@ -85,4 +85,4 @@ class DriverRegistry(ABCMeta):
from werkzeug.utils import find_modules
for module_name in find_modules(__package__, True):
module = import_module(module_name)
import_module(module_name)

View File

@ -798,7 +798,6 @@ class PgadminPage:
break
except TimeoutException:
retry -= 1
pass
def toggle_open_server(self, tree_item_text):
def check_for_password_dialog_or_tree_open(driver):

View File

@ -120,5 +120,5 @@ class TestClient(testing.FlaskClient):
return res
def logout(self):
res = self.get('/logout?next=/browser/', follow_redirects=False)
self.get('/logout?next=/browser/', follow_redirects=False)
self.csrf_token = None