Fixed SonarQube code smell 'Rename function and variable name to match the regular expression'.

This commit is contained in:
Pradip Parkale
2020-07-01 13:50:51 +05:30
committed by Akshay Joshi
parent 6dd3ca31be
commit b30c590866
5 changed files with 45 additions and 45 deletions

View File

@@ -215,7 +215,7 @@ class DataTypeReader:
return length, precision, typeval return length, precision, typeval
@staticmethod @staticmethod
def get_full_type(nsp, typname, isDup, numdims, typmod): def get_full_type(nsp, typname, is_dup, numdims, typmod):
""" """
Returns full type name with Length and Precision. Returns full type name with Length and Precision.

View File

@@ -547,9 +547,9 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
).format(arg) ).format(arg)
) )
try: try:
SQL, nameOrError = self.getSQL(gid, sid, did, data) SQL, name_or_error = self.getSQL(gid, sid, did, data)
if SQL is None: if SQL is None:
return nameOrError return name_or_error
SQL = SQL.strip('\n').strip(' ') SQL = SQL.strip('\n').strip(' ')
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
@@ -729,9 +729,9 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
except ValueError: except ValueError:
data[k] = v data[k] = v
sql, nameOrError = self.getSQL(gid, sid, did, data, vid) sql, name_or_error = self.getSQL(gid, sid, did, data, vid)
if sql is None: if sql is None:
return nameOrError return name_or_error
sql = sql.strip('\n').strip(' ') sql = sql.strip('\n').strip(' ')
@@ -967,7 +967,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
""" """
self.rule_temp_path = 'rules' self.rule_temp_path = 'rules'
SQL_data = '' sql_data = ''
SQL = render_template("/".join( SQL = render_template("/".join(
[self.rule_temp_path, 'sql/properties.sql']), tid=vid) [self.rule_temp_path, 'sql/properties.sql']), tid=vid)
@@ -989,16 +989,16 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
SQL = render_template("/".join( SQL = render_template("/".join(
[self.rule_temp_path, 'sql/create.sql']), [self.rule_temp_path, 'sql/create.sql']),
data=res, display_comments=display_comments) data=res, display_comments=display_comments)
SQL_data += '\n' sql_data += '\n'
SQL_data += SQL sql_data += SQL
return SQL_data return sql_data
def get_compound_trigger_sql(self, vid, display_comments=True): def get_compound_trigger_sql(self, vid, display_comments=True):
""" """
Get all compound trigger nodes associated with view node, Get all compound trigger nodes associated with view node,
generate their sql and render into sql tab generate their sql and render into sql tab
""" """
SQL_data = '' sql_data = ''
if self.manager.server_type == 'ppas' \ if self.manager.server_type == 'ppas' \
and self.manager.version >= 120000: and self.manager.version >= 120000:
@@ -1065,10 +1065,10 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
'sql/{0}/#{1}#/create.sql'.format( 'sql/{0}/#{1}#/create.sql'.format(
self.manager.server_type, self.manager.version)]), self.manager.server_type, self.manager.version)]),
data=res_rows, display_comments=display_comments) data=res_rows, display_comments=display_comments)
SQL_data += '\n' sql_data += '\n'
SQL_data += SQL sql_data += SQL
return SQL_data return sql_data
def get_trigger_sql(self, vid, display_comments=True): def get_trigger_sql(self, vid, display_comments=True):
""" """
@@ -1085,7 +1085,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
# Define template path # Define template path
self.trigger_temp_path = 'triggers' self.trigger_temp_path = 'triggers'
SQL_data = '' sql_data = ''
SQL = render_template("/".join( SQL = render_template("/".join(
[self.trigger_temp_path, [self.trigger_temp_path,
'sql/{0}/#{1}#/properties.sql'.format( 'sql/{0}/#{1}#/properties.sql'.format(
@@ -1158,10 +1158,10 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
'sql/{0}/#{1}#/create.sql'.format( 'sql/{0}/#{1}#/create.sql'.format(
self.manager.server_type, self.manager.version)]), self.manager.server_type, self.manager.version)]),
data=res_rows, display_comments=display_comments) data=res_rows, display_comments=display_comments)
SQL_data += '\n' sql_data += '\n'
SQL_data += SQL sql_data += SQL
return SQL_data return sql_data
def get_index_sql(self, did, vid, display_comments=True): def get_index_sql(self, did, vid, display_comments=True):
""" """
@@ -1171,7 +1171,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
""" """
self.index_temp_path = 'indexes' self.index_temp_path = 'indexes'
SQL_data = '' sql_data = ''
SQL = render_template("/".join( SQL = render_template("/".join(
[self.index_temp_path, [self.index_temp_path,
'sql/#{0}#/properties.sql'.format(self.manager.version)]), 'sql/#{0}#/properties.sql'.format(self.manager.version)]),
@@ -1204,9 +1204,9 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
[self.index_temp_path, [self.index_temp_path,
'sql/#{0}#/create.sql'.format(self.manager.version)]), 'sql/#{0}#/create.sql'.format(self.manager.version)]),
data=data, display_comments=display_comments) data=data, display_comments=display_comments)
SQL_data += '\n' sql_data += '\n'
SQL_data += SQL sql_data += SQL
return SQL_data return sql_data
@check_precondition @check_precondition
def sql(self, gid, sid, did, scid, vid, diff_schema=None, def sql(self, gid, sid, did, scid, vid, diff_schema=None,
@@ -1220,7 +1220,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if not json_resp: if not json_resp:
display_comments = False display_comments = False
SQL_data = '' sql_data = ''
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'sql/properties.sql']), [self.template_path, 'sql/properties.sql']),
vid=vid, vid=vid,
@@ -1289,15 +1289,15 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
SQL += render_template("/".join( SQL += render_template("/".join(
[self.template_path, 'sql/grant.sql']), data=result) [self.template_path, 'sql/grant.sql']), data=result)
SQL_data += SQL sql_data += SQL
SQL_data += self.get_rule_sql(vid, display_comments) sql_data += self.get_rule_sql(vid, display_comments)
SQL_data += self.get_trigger_sql(vid, display_comments) sql_data += self.get_trigger_sql(vid, display_comments)
SQL_data += self.get_compound_trigger_sql(vid, display_comments) sql_data += self.get_compound_trigger_sql(vid, display_comments)
SQL_data += self.get_index_sql(did, vid, display_comments) sql_data += self.get_index_sql(did, vid, display_comments)
if not json_resp: if not json_resp:
return SQL_data return sql_data
return ajax_response(response=SQL_data) return ajax_response(response=sql_data)
@check_precondition @check_precondition
def get_tblspc(self, gid, sid, did, scid): def get_tblspc(self, gid, sid, did, scid):
@@ -1531,7 +1531,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if data: if data:
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema
sql, nameOrError = self.getSQL(gid, sid, did, data, oid) sql, name_or_error = self.getSQL(gid, sid, did, data, oid)
if sql.find('DROP VIEW') != -1: if sql.find('DROP VIEW') != -1:
sql = gettext(""" sql = gettext("""
-- Changing the columns in a view requires dropping and re-creating the view. -- Changing the columns in a view requires dropping and re-creating the view.
@@ -1767,7 +1767,7 @@ class MViewNode(ViewNode, VacuumSettings):
if not json_resp: if not json_resp:
display_comments = False display_comments = False
SQL_data = '' sql_data = ''
status, result = self._fetch_properties(did, scid, vid) status, result = self._fetch_properties(did, scid, vid)
if not status: if not status:
@@ -1817,15 +1817,15 @@ class MViewNode(ViewNode, VacuumSettings):
SQL += render_template("/".join( SQL += render_template("/".join(
[self.template_path, 'sql/grant.sql']), data=result) [self.template_path, 'sql/grant.sql']), data=result)
SQL_data += SQL sql_data += SQL
SQL_data += self.get_rule_sql(vid, display_comments) sql_data += self.get_rule_sql(vid, display_comments)
SQL_data += self.get_trigger_sql(vid, display_comments) sql_data += self.get_trigger_sql(vid, display_comments)
SQL_data += self.get_index_sql(did, vid, display_comments) sql_data += self.get_index_sql(did, vid, display_comments)
SQL_data = SQL_data.strip('\n') sql_data = sql_data.strip('\n')
if not json_resp: if not json_resp:
return SQL_data return sql_data
return ajax_response(response=SQL_data) return ajax_response(response=sql_data)
@check_precondition @check_precondition
def get_table_vacuum(self, gid, sid, did, scid): def get_table_vacuum(self, gid, sid, did, scid):

View File

@@ -97,7 +97,7 @@ class BackupMessage(IProcessDesc):
self.database = _kwargs['database'] if 'database' in _kwargs else None self.database = _kwargs['database'] if 'database' in _kwargs else None
self.cmd = '' self.cmd = ''
def cmdArg(x): def cmd_arg(x):
if x: if x:
x = x.replace('\\', '\\\\') x = x.replace('\\', '\\\\')
x = x.replace('"', '\\"') x = x.replace('"', '\\"')
@@ -109,7 +109,7 @@ class BackupMessage(IProcessDesc):
if arg and len(arg) >= 2 and arg[:2] == '--': if arg and len(arg) >= 2 and arg[:2] == '--':
self.cmd += ' ' + arg self.cmd += ' ' + arg
else: else:
self.cmd += cmdArg(arg) self.cmd += cmd_arg(arg)
def get_server_details(self): def get_server_details(self):
# Fetch the server details like hostname, port, roles etc # Fetch the server details like hostname, port, roles etc

View File

@@ -81,7 +81,7 @@ class IEMessage(IProcessDesc):
if _storage: if _storage:
_storage = _storage.replace('\\', '/') _storage = _storage.replace('\\', '/')
def cmdArg(x): def cmd_arg(x):
if x: if x:
x = x.replace('\\', '\\\\') x = x.replace('\\', '\\\\')
x = x.replace('"', '\\"') x = x.replace('"', '\\"')
@@ -97,12 +97,12 @@ class IEMessage(IProcessDesc):
replace_next = True replace_next = True
self._cmd += ' ' + arg self._cmd += ' ' + arg
elif replace_next: elif replace_next:
arg = cmdArg(arg) arg = cmd_arg(arg)
if _storage is not None: if _storage is not None:
arg = arg.replace(_storage, '<STORAGE_DIR>') arg = arg.replace(_storage, '<STORAGE_DIR>')
self._cmd += ' "' + arg + '"' self._cmd += ' "' + arg + '"'
else: else:
self._cmd += cmdArg(arg) self._cmd += cmd_arg(arg)
@property @property
def message(self): def message(self):

View File

@@ -71,7 +71,7 @@ class RestoreMessage(IProcessDesc):
self.bfile = _bfile self.bfile = _bfile
self.cmd = '' self.cmd = ''
def cmdArg(x): def cmd_arg(x):
if x: if x:
x = x.replace('\\', '\\\\') x = x.replace('\\', '\\\\')
x = x.replace('"', '\\"') x = x.replace('"', '\\"')
@@ -83,7 +83,7 @@ class RestoreMessage(IProcessDesc):
if arg and len(arg) >= 2 and arg[:2] == '--': if arg and len(arg) >= 2 and arg[:2] == '--':
self.cmd += ' ' + arg self.cmd += ' ' + arg
else: else:
self.cmd += cmdArg(arg) self.cmd += cmd_arg(arg)
def get_server_details(self): def get_server_details(self):
# Fetch the server details like hostname, port, roles etc # Fetch the server details like hostname, port, roles etc