public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin][SonarQube] : Remove duplicates string literals.
4+ messages / 2 participants
[nested] [flat]
* [pgAdmin][SonarQube] : Remove duplicates string literals.
@ 2020-09-03 10:59 Pradip Parkale <[email protected]>
2020-09-03 12:54 ` Re: [pgAdmin][SonarQube] : Remove duplicates string literals. Akshay Joshi <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Pradip Parkale @ 2020-09-03 10:59 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
Attached is a patch for removing duplicates string literals.
/server_groups/servers/roles/__init__.py - 8 places
--
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
Attachments:
[application/octet-stream] sonar_Qube_v1.patch (5.1K, 3-sonar_Qube_v1.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/roles/__init__.py b/web/pgadmin/browser/server_groups/servers/roles/__init__.py
index 5c78c09ee..927101b81 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/roles/__init__.py
@@ -20,6 +20,8 @@ from pgadmin.utils.ajax import make_json_response, \
make_response as ajax_response, precondition_required, \
internal_server_error, forbidden, success_return, gone
from pgadmin.utils.driver import get_driver
+from pgadmin.utils.constants import ROLE_NOT_FOUND, \
+ ERROR_FETCHING_ROLE_INFORMATION
from config import PG_DEFAULT_DRIVER
@@ -641,10 +643,7 @@ rolmembership:{
if not status:
return internal_server_error(
_(
- "Error fetching role information from the database "
- "server.\n{0}"
- ).format(rset)
- )
+ ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
res = []
for row in rset['rows']:
@@ -676,10 +675,7 @@ rolmembership:{
if not status:
return internal_server_error(
_(
- "Error fetching role information from the database "
- "server.\n{0}"
- ).format(rset)
- )
+ ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
for row in rset['rows']:
return make_json_response(
@@ -693,7 +689,7 @@ rolmembership:{
status=200
)
- return gone(_("Could not find the role information."))
+ return gone(_(ROLE_NOT_FOUND))
def transform(self, rset):
for row in rset['rows']:
@@ -736,7 +732,7 @@ rolmembership:{
self.transform(res)
if len(res['rows']) == 0:
- return gone(_("Could not find the role information."))
+ return gone(_(ROLE_NOT_FOUND))
res['rows'][0]['is_sys_obj'] = (
res['rows'][0]['oid'] <= self.datlastsysoid)
@@ -853,10 +849,7 @@ rolmembership:{
if not status:
return internal_server_error(
_(
- "Error fetching role information from the database "
- "server.\n{0}"
- ).format(rset)
- )
+ ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
for row in rset['rows']:
return jsonify(
node=self.blueprint.generate_browser_node(
@@ -867,7 +860,7 @@ rolmembership:{
)
)
- return gone(_("Could not find the role information."))
+ return gone(_(ROLE_NOT_FOUND))
@check_precondition(action='update')
@validate_request
@@ -901,10 +894,7 @@ rolmembership:{
if not status:
return internal_server_error(
_(
- "Error fetching role information from the database "
- "server.\n{0}"
- ).format(rset)
- )
+ ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
for row in rset['rows']:
return jsonify(
@@ -917,7 +907,7 @@ rolmembership:{
)
)
- return gone(_("Could not find the role information."))
+ return gone(_(ROLE_NOT_FOUND))
@check_precondition(action='msql')
@validate_request
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js b/web/pgadmin/browser/server_groups/servers/static/js/server.js
index 9170e0d44..e48524924 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/server.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js
@@ -744,7 +744,6 @@ define('pgadmin.node.server', [
// Default values!
initialize: function(attrs, args) {
var isNew = (_.size(attrs) === 0);
- console.warn('warn');
if (isNew) {
this.set({'gid': args.node_info['server_group']._id});
diff --git a/web/pgadmin/utils/constants.py b/web/pgadmin/utils/constants.py
index 88ae50de2..76a392789 100644
--- a/web/pgadmin/utils/constants.py
+++ b/web/pgadmin/utils/constants.py
@@ -29,3 +29,8 @@ PGADMIN_NODE = 'pgadmin.node.%s'
UNAUTH_REQ = "Unauthorized request."
SERVER_CONNECTION_CLOSED = gettext(
'Not connected to server or connection with the server has been closed.')
+
+# Role module constant
+ROLE_NOT_FOUND = gettext("Could not find the role information.")
+ERROR_FETCHING_ROLE_INFORMATION = gettext(
+ "Error fetching role information from the database server.")
diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py
index 022856c0c..43be73820 100644
--- a/web/regression/python_test_utils/test_utils.py
+++ b/web/regression/python_test_utils/test_utils.py
@@ -1681,8 +1681,7 @@ def get_test_user(self, user_details,
def create_user_wise_test_client(user):
"""
- This function creates new test client and pem database connection as per
- provided user and execute the test cases.
+ This function creates new test client and execute the test cases.
:return: None
"""
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [pgAdmin][SonarQube] : Remove duplicates string literals.
2020-09-03 10:59 [pgAdmin][SonarQube] : Remove duplicates string literals. Pradip Parkale <[email protected]>
@ 2020-09-03 12:54 ` Akshay Joshi <[email protected]>
2020-09-03 13:49 ` Re: [pgAdmin][SonarQube] : Remove duplicates string literals. Pradip Parkale <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Akshay Joshi @ 2020-09-03 12:54 UTC (permalink / raw)
To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers
Hi Pradip
Following are the review comments:
- ROLE_NOT_FOUND already in wrapped in gettext() then no need to use
like gone(_(ROLE_NOT_FOUND)). In fact, can we use
self.not_found_error_msg()instead of new constant.
- Same with ERROR_FETCHING_ROLE_INFORMATION it's already in gettext,
also we can use this constant for string "
Error retrieving roles from the database server"
On Thu, Sep 3, 2020 at 4:30 PM Pradip Parkale <
[email protected]> wrote:
> Hi Hackers,
>
> Attached is a patch for removing duplicates string literals.
> /server_groups/servers/roles/__init__.py - 8 places
>
>
>
> --
> Thanks & Regards,
> Pradip Parkale
> Software Engineer | EnterpriseDB Corporation
>
--
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres <http://edbpostgres.com>*
*Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [pgAdmin][SonarQube] : Remove duplicates string literals.
2020-09-03 10:59 [pgAdmin][SonarQube] : Remove duplicates string literals. Pradip Parkale <[email protected]>
2020-09-03 12:54 ` Re: [pgAdmin][SonarQube] : Remove duplicates string literals. Akshay Joshi <[email protected]>
@ 2020-09-03 13:49 ` Pradip Parkale <[email protected]>
2020-09-07 13:18 ` Re: [pgAdmin][SonarQube] : Remove duplicates string literals. Akshay Joshi <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Pradip Parkale @ 2020-09-03 13:49 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers
Hi Akshay,
Please find the updated patch.
On Thu, Sep 3, 2020 at 6:24 PM Akshay Joshi <[email protected]>
wrote:
> Hi Pradip
>
> Following are the review comments:
>
> - ROLE_NOT_FOUND already in wrapped in gettext() then no need to use
> like gone(_(ROLE_NOT_FOUND)). In fact, can we use
>
> self.not_found_error_msg()instead of new constant.
>
> - Same with ERROR_FETCHING_ROLE_INFORMATION it's already in gettext,
> also we can use this constant for string "
>
> Error retrieving roles from the database server"
>
>
>
> On Thu, Sep 3, 2020 at 4:30 PM Pradip Parkale <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> Attached is a patch for removing duplicates string literals.
>> /server_groups/servers/roles/__init__.py - 8 places
>>
>>
>>
>> --
>> Thanks & Regards,
>> Pradip Parkale
>> Software Engineer | EnterpriseDB Corporation
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Sr. Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>
--
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
Attachments:
[application/octet-stream] sonar_Qube_v2.patch (6.5K, 3-sonar_Qube_v2.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/roles/__init__.py b/web/pgadmin/browser/server_groups/servers/roles/__init__.py
index 5c78c09ee..314cba7d7 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/roles/__init__.py
@@ -20,6 +20,7 @@ from pgadmin.utils.ajax import make_json_response, \
make_response as ajax_response, precondition_required, \
internal_server_error, forbidden, success_return, gone
from pgadmin.utils.driver import get_driver
+from pgadmin.utils.constants import ERROR_FETCHING_ROLE_INFORMATION
from config import PG_DEFAULT_DRIVER
@@ -111,6 +112,10 @@ class RoleView(PGChildNodeView):
'variables': [{'get': 'variables'}],
})
+ @staticmethod
+ def not_found_error_message():
+ return "Could not find the role information."
+
def _validate_input_dict_for_new(self, data, req_keys):
"""
This functions validates the input dict and check for required
@@ -619,10 +624,7 @@ rolmembership:{
if not status:
return internal_server_error(
- _(
- "Error retrieving roles from the database server.\n{0}"
- ).format(res)
- )
+ _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(res))
self.transform(res)
@@ -640,11 +642,7 @@ rolmembership:{
if not status:
return internal_server_error(
- _(
- "Error fetching role information from the database "
- "server.\n{0}"
- ).format(rset)
- )
+ _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
res = []
for row in rset['rows']:
@@ -676,10 +674,7 @@ rolmembership:{
if not status:
return internal_server_error(
_(
- "Error fetching role information from the database "
- "server.\n{0}"
- ).format(rset)
- )
+ ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
for row in rset['rows']:
return make_json_response(
@@ -693,7 +688,7 @@ rolmembership:{
status=200
)
- return gone(_("Could not find the role information."))
+ return gone(_(self.not_found_error_message()))
def transform(self, rset):
for row in rset['rows']:
@@ -729,14 +724,11 @@ rolmembership:{
if not status:
return internal_server_error(
- _(
- "Error retrieving roles from the database server.\n{0}"
- ).format(res)
- )
+ _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(res))
self.transform(res)
if len(res['rows']) == 0:
- return gone(_("Could not find the role information."))
+ return gone(_(self.not_found_error_message()))
res['rows'][0]['is_sys_obj'] = (
res['rows'][0]['oid'] <= self.datlastsysoid)
@@ -841,8 +833,7 @@ rolmembership:{
if not status:
return internal_server_error(
- _("Could not retrieve the role information.\n{0}").format(msg)
- )
+ _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(msg))
status, rset = self.conn.execute_dict(
render_template(self.sql_path + self._NODES_SQL,
@@ -853,10 +844,7 @@ rolmembership:{
if not status:
return internal_server_error(
_(
- "Error fetching role information from the database "
- "server.\n{0}"
- ).format(rset)
- )
+ ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
for row in rset['rows']:
return jsonify(
node=self.blueprint.generate_browser_node(
@@ -867,7 +855,7 @@ rolmembership:{
)
)
- return gone(_("Could not find the role information."))
+ return gone(_(self.not_found_error_message()))
@check_precondition(action='update')
@validate_request
@@ -900,11 +888,7 @@ rolmembership:{
if not status:
return internal_server_error(
- _(
- "Error fetching role information from the database "
- "server.\n{0}"
- ).format(rset)
- )
+ _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
for row in rset['rows']:
return jsonify(
@@ -917,7 +901,7 @@ rolmembership:{
)
)
- return gone(_("Could not find the role information."))
+ return gone(_(self.not_found_error_message()))
@check_precondition(action='msql')
@validate_request
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js b/web/pgadmin/browser/server_groups/servers/static/js/server.js
index 9170e0d44..e48524924 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/server.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js
@@ -744,7 +744,6 @@ define('pgadmin.node.server', [
// Default values!
initialize: function(attrs, args) {
var isNew = (_.size(attrs) === 0);
- console.warn('warn');
if (isNew) {
this.set({'gid': args.node_info['server_group']._id});
diff --git a/web/pgadmin/utils/constants.py b/web/pgadmin/utils/constants.py
index 88ae50de2..79ed661fb 100644
--- a/web/pgadmin/utils/constants.py
+++ b/web/pgadmin/utils/constants.py
@@ -29,3 +29,7 @@ PGADMIN_NODE = 'pgadmin.node.%s'
UNAUTH_REQ = "Unauthorized request."
SERVER_CONNECTION_CLOSED = gettext(
'Not connected to server or connection with the server has been closed.')
+
+# Role module constant
+ERROR_FETCHING_ROLE_INFORMATION = \
+ "Error fetching role information from the database server."
diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py
index 022856c0c..43be73820 100644
--- a/web/regression/python_test_utils/test_utils.py
+++ b/web/regression/python_test_utils/test_utils.py
@@ -1681,8 +1681,7 @@ def get_test_user(self, user_details,
def create_user_wise_test_client(user):
"""
- This function creates new test client and pem database connection as per
- provided user and execute the test cases.
+ This function creates new test client and execute the test cases.
:return: None
"""
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [pgAdmin][SonarQube] : Remove duplicates string literals.
2020-09-03 10:59 [pgAdmin][SonarQube] : Remove duplicates string literals. Pradip Parkale <[email protected]>
2020-09-03 12:54 ` Re: [pgAdmin][SonarQube] : Remove duplicates string literals. Akshay Joshi <[email protected]>
2020-09-03 13:49 ` Re: [pgAdmin][SonarQube] : Remove duplicates string literals. Pradip Parkale <[email protected]>
@ 2020-09-07 13:18 ` Akshay Joshi <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: Akshay Joshi @ 2020-09-07 13:18 UTC (permalink / raw)
To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers
Thanks, patch applied.
On Thu, Sep 3, 2020 at 7:19 PM Pradip Parkale <
[email protected]> wrote:
> Hi Akshay,
>
> Please find the updated patch.
>
>
> On Thu, Sep 3, 2020 at 6:24 PM Akshay Joshi <[email protected]>
> wrote:
>
>> Hi Pradip
>>
>> Following are the review comments:
>>
>> - ROLE_NOT_FOUND already in wrapped in gettext() then no need to use
>> like gone(_(ROLE_NOT_FOUND)). In fact, can we use
>>
>> self.not_found_error_msg()instead of new constant.
>>
>> - Same with ERROR_FETCHING_ROLE_INFORMATION it's already in gettext,
>> also we can use this constant for string "
>>
>> Error retrieving roles from the database server"
>>
>>
>>
>> On Thu, Sep 3, 2020 at 4:30 PM Pradip Parkale <
>> [email protected]> wrote:
>>
>>> Hi Hackers,
>>>
>>> Attached is a patch for removing duplicates string literals.
>>> /server_groups/servers/roles/__init__.py - 8 places
>>>
>>>
>>>
>>> --
>>> Thanks & Regards,
>>> Pradip Parkale
>>> Software Engineer | EnterpriseDB Corporation
>>>
>>
>>
>> --
>> *Thanks & Regards*
>> *Akshay Joshi*
>> *pgAdmin Hacker | Sr. Software Architect*
>> *EDB Postgres <http://edbpostgres.com>*
>>
>> *Mobile: +91 976-788-8246*
>>
>
>
> --
> Thanks & Regards,
> Pradip Parkale
> Software Engineer | EnterpriseDB Corporation
>
--
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres <http://edbpostgres.com>*
*Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2020-09-07 13:18 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03 10:59 [pgAdmin][SonarQube] : Remove duplicates string literals. Pradip Parkale <[email protected]>
2020-09-03 12:54 ` Akshay Joshi <[email protected]>
2020-09-03 13:49 ` Pradip Parkale <[email protected]>
2020-09-07 13:18 ` Akshay Joshi <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox