[pgAdmin][SonarQube] Fixes for 13 rules.

2020-08-03 Thread Aditya Toshniwal
Hi Hackers,

Attached is the patch to fix around 27 SonarQube related issues raised for
rules:

   1. Remove this assignment to the local variable, the value is never used.
   2. Rename local variables to match the regular expression
   3. Add logic to this except clause or eliminate it and rethrow the
   exception automatically.
   4. Rename fields to match the regular expression
   5. Extract this nested conditional expression into an independent
   statement.
   6. Change this default value to "None" and initialize this parameter
   inside the function/method.
   7. Update this function so that its implementation is not identical to
   __repr__
   8. Refactor this method to not always return the same value
   9. Reraise this exception to stop the application as the user expects
   10. Add missing parameters _w _PY3. This method overrides
   simplejson.decoder.JSONDecoder.decode.
   11. Remove this redundant continue.
   12. Remove this unused function declaration
   13. Remove this identity check; it will always be False.

Please review.

-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*

"Don't Complain about Heat, Plant a TREE"


sonarqube.many-13.patch
Description: Binary data


Re: [pgAdmin4][Patch] - SonarQube Issues - 12 (String literals should not be duplicated)

2020-08-03 Thread Akshay Joshi
Hi Yogesh

Instead of declaring global variables, I would suggest declaring them as a
class variable (constants). Make the changes and resend the patch

On Mon, Aug 3, 2020 at 10:40 AM Yogesh Mahajan <
yogesh.maha...@enterprisedb.com> wrote:

> Hi,
>
> Please find patch which fixes 15+ issues related to rule -
> 1.String literals should not be duplicated
>
> Thanks,
> Yogesh Mahajan
> QA - Team
> EnterpriseDB Corporation
>
> Phone: +91-9741705709
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres *

*Mobile: +91 976-788-8246*


pgAdmin 4 commit: Fixed SonarQube issues.

2020-08-03 Thread Akshay Joshi
Fixed SonarQube issues.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=32d904058ad2e9cdcc4eef68d462fde63486eb5e
Author: Shubham Agarwal 

Modified Files
--
web/regression/python_test_utils/test_utils.py | 227 +
1 file changed, 117 insertions(+), 110 deletions(-)



pgAdmin 4 commit: Fixed following SonarQube issues:

2020-08-03 Thread Akshay Joshi
Fixed following SonarQube issues:
  - Remove this assignment to the local variable, the value is never used.
  - Rename local variables to match the regular expression
  - Add logic to this except clause or eliminate it and rethrow the exception 
automatically.
  - Rename fields to match the regular expression
  - Extract this nested conditional expression into an independent statement.
  - Change this default value to "None" and initialize this parameter inside 
the function/method.
  - Update this function so that its implementation is not identical to __repr__
  - Refactor this method to not always return the same value
  - Reraise this exception to stop the application as the user expects
  - Add missing parameters _w _PY3. This method overrides 
simplejson.decoder.JSONDecoder.decode.
  - Remove this redundant continue.
  - Remove this unused function declaration
  - Remove this identity check; it will always be False.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=536593bf8a2e734a96d67f27b5a330d592c28d8f
Author: Aditya Toshniwal 

Modified Files
--
tools/dependency_inventory.py  |  1 -
.../browser/server_groups/servers/__init__.py  |  8 +++--
.../server_groups/servers/databases/__init__.py|  2 --
.../databases/schemas/foreign_tables/__init__.py   |  9 +++--
.../schemas/tables/partitions/__init__.py  |  2 +-
.../servers/databases/schemas/types/__init__.py| 14 
web/pgadmin/misc/bgprocess/processes.py| 21 +--
web/pgadmin/misc/file_manager/__init__.py  | 41 +++---
web/pgadmin/tools/debugger/__init__.py |  6 ++--
web/pgadmin/tools/schema_diff/directory_compare.py |  3 +-
web/pgadmin/tools/sqleditor/__init__.py|  5 +--
.../tools/sqleditor/utils/start_running_query.py   |  5 +--
web/pgadmin/utils/ajax.py  |  2 +-
web/pgadmin/utils/csv.py   |  6 ++--
web/pgadmin/utils/driver/psycopg2/connection.py| 39 +---
.../utils/driver/psycopg2/server_manager.py|  7 ++--
web/pgadmin/utils/session.py   |  8 ++---
web/regression/python_test_utils/test_utils.py |  6 ++--
web/regression/runtests.py |  2 ++
19 files changed, 74 insertions(+), 113 deletions(-)



pgAdmin 4 commit: Corrected the syntax as per jinja standards. refs #56

2020-08-03 Thread Akshay Joshi
Corrected the syntax as per jinja standards. refs #5632

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=87d08de3a0f0b0a05c0fb87151974bcef9e4bb26

Modified Files
--
.../databases/schemas/tables/templates/columns/sql/10_plus/update.sql | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgAdmin 4 commit: Fixed cognitive complexity issues reported by SonarQu

2020-08-03 Thread Akshay Joshi
Fixed cognitive complexity issues reported by SonarQube.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=eb2c5546018bc60777a3ae54be8b2f03e3b15bf4
Author: Nikhil Mohite 

Modified Files
--
web/pgadmin/tools/maintenance/__init__.py  | 38 +++
.../sqleditor/utils/query_tool_preferences.py  |  2 +-
web/pgadmin/tools/user_management/__init__.py  | 76 ++
web/pgadmin/utils/route.py | 30 ++---
4 files changed, 96 insertions(+), 50 deletions(-)



pgAdmin 4 commit: Improve code coverage and API test cases for Schemas.

2020-08-03 Thread Akshay Joshi
Improve code coverage and API test cases for Schemas. Fixes #5327

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=318d712c4f1f8399b8ec2a70d32e84a1f0cfeb14
Author: Satish V 

Modified Files
--
docs/en_US/release_notes_4_25.rst  |   1 +
.../tests/domain_constraints_test_data.json|   5 +-
.../databases/schemas/tests/schema_test_data.json  | 296 +
.../databases/schemas/tests/test_schema_add.py |  62 +++--
.../databases/schemas/tests/test_schema_delete.py  |  48 +++-
.../schemas/tests/test_schema_delete_multiple.py   |  24 +-
.../schemas/tests/test_schema_dependents.py|  77 ++
.../databases/schemas/tests/test_schema_get.py |  70 +++--
.../schemas/tests/test_schema_get_children.py  |  84 ++
.../databases/schemas/tests/test_schema_node.py|  86 ++
.../databases/schemas/tests/test_schema_put.py |  54 ++--
.../databases/schemas/tests/test_schema_sql.py |  88 ++
.../servers/databases/schemas/tests/utils.py   |   6 +
13 files changed, 820 insertions(+), 81 deletions(-)



pgAdmin 4 commit: Ensure that the original file format should be retain

2020-08-03 Thread Akshay Joshi
Ensure that the original file format should be retained when saving the same 
file in SQL editor. Fixes #3767

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=43e127de3167311c4e65654cd1a6f2059ea14d50
Author: Yogesh Mahajan 

Modified Files
--
docs/en_US/release_notes_4_25.rst |  1 +
web/pgadmin/misc/file_manager/__init__.py |  7 +++
web/pgadmin/tools/sqleditor/__init__.py   | 12 +++-
3 files changed, 19 insertions(+), 1 deletion(-)



Re: [pgAdmin][Patch] RM3767 - pgAdmin4 loses the file format

2020-08-03 Thread Akshay Joshi
Thanks, patch applied.

On Thu, Jul 30, 2020 at 5:43 PM Yogesh Mahajan <
yogesh.maha...@enterprisedb.com> wrote:

> Hi,
>
> Please find an attached patch which enables pgAdmin to retain original
> file format while saving the same file in SQL-Editor.
> However, if a new file is created with the 'Save as' option, a new fill
> will be created with utf-8 encoding.
> After editing the file having encoding 'UTF-8 with BOM' from SQL-editor,
> the file was getting saved with 'UTF-8' encoding.
> Now pgAdmin will retain the original encoding of 'UTF-8 with BOM'.
>
> Thanks,
>
> Yogesh Mahajan
> QA - Team
> EnterpriseDB Corporation
>
> Phone: +91-9741705709
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres *

*Mobile: +91 976-788-8246*


Re: [pgAdmin 4 - Housekeeping #5327][Code Coverage] Improve API test cases for Schemas and Catalog Objects

2020-08-03 Thread Akshay Joshi
Thanks, patch applied.

On Fri, Jul 31, 2020 at 3:49 PM Satish V  wrote:

> Hi Hackers,
>
> Please find the patch which improves the code coverage for Schema alone.
> Kindly create another RM for the Catalog Objects. Please review the patch.
>
> Thanks,
> Sathish V
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres *

*Mobile: +91 976-788-8246*


Re: Patch for SonarQube code scan fixes.

2020-08-03 Thread Akshay Joshi
Thanks, patch applied.

On Fri, Jul 31, 2020 at 6:35 PM Nikhil Mohite <
nikhil.moh...@enterprisedb.com> wrote:

> Hi Team,
>
> I have fixed some code smell issues in the SonarQube scan, PFA patch.
> Details as follows:
>
> 1. Utils Route:
>
>- Refactor this function to reduce its Cognitive Complexity from 16 to
>the 15 allowed.
>
> 2. User Management:
>
>- Refactor this function to reduce its Cognitive Complexity from 16 to
>the 15 allowed.
>- Refactor this function to reduce its Cognitive Complexity from 18 to
>the 15 allowed.
>
> 3. Query tool preferences:
>
>- Merge these implicitly concatenated strings; or did you forget a
>comma?
>
> 4. Tool Maintenance:
>
>- Refactor this function to reduce its Cognitive Complexity from 16 to
>the 15 allowed.
>- Refactor this function to reduce its Cognitive Complexity from 20 to
>the 15 allowed.
>
>
> Regards,
> Nikhil Mohite.
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres *

*Mobile: +91 976-788-8246*


Re: [pgAdmin][SonarQube] Fixes for 13 rules.

2020-08-03 Thread Akshay Joshi
Thanks, patch applied.

On Mon, Aug 3, 2020 at 12:47 PM Aditya Toshniwal <
aditya.toshni...@enterprisedb.com> wrote:

> Hi Hackers,
>
> Attached is the patch to fix around 27 SonarQube related issues raised for
> rules:
>
>1. Remove this assignment to the local variable, the value is never
>used.
>2. Rename local variables to match the regular expression
>3. Add logic to this except clause or eliminate it and rethrow the
>exception automatically.
>4. Rename fields to match the regular expression
>5. Extract this nested conditional expression into an independent
>statement.
>6. Change this default value to "None" and initialize this parameter
>inside the function/method.
>7. Update this function so that its implementation is not identical to
>__repr__
>8. Refactor this method to not always return the same value
>9. Reraise this exception to stop the application as the user expects
>10. Add missing parameters _w _PY3. This method overrides
>simplejson.decoder.JSONDecoder.decode.
>11. Remove this redundant continue.
>12. Remove this unused function declaration
>13. Remove this identity check; it will always be False.
>
> Please review.
>
> --
> Thanks,
> Aditya Toshniwal
> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
> 
> "Don't Complain about Heat, Plant a TREE"
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres *

*Mobile: +91 976-788-8246*


Re: [pgAdmin][RM5632] Cannot specify start with value during setup of an identity column

2020-08-03 Thread Akshay Joshi
Hi Rahul

Fixed the issue by modifying the condition from 'is false' to ' == false'.

On Fri, Jul 31, 2020 at 12:42 PM Rahul Shirsat <
rahul.shir...@enterprisedb.com> wrote:

> Hi Akshay,
>
> A syntactical error in a jinja template caught yesterday in Yogesh's local
> setup of pgAdmin by running a test suite for the changes done in this RM.
> It's strange going through several testings, even on Jenkins, it passed but
> failed on Yogesh's machine.
>
> I have made changes for this issue and rechecked with Yogesh, which seems
> to be fixed now.
>
> Could you please apply these relevant changes for this RM?
>
> On Wed, Jul 29, 2020 at 6:31 PM Akshay Joshi <
> akshay.jo...@enterprisedb.com> wrote:
>
>> Thanks, patch applied.
>>
>> On Wed, Jul 29, 2020 at 3:52 PM Rahul Shirsat <
>> rahul.shir...@enterprisedb.com> wrote:
>>
>>> Hi Hackers,
>>>
>>> Ignore the previous patch. Find below the rebased patch.
>>>
>>> On Wed, Jul 29, 2020 at 2:36 PM Rahul Shirsat <
>>> rahul.shir...@enterprisedb.com> wrote:
>>>
 Hi Hackers,

 Please find the patch below which fixes the issue of Start value while
 updating the identity column.

 *Some additional issues were also found during development, which are
 too fixed now :*


1. While changing of identity (*ALWAYS / BY DEFAULT*) including 
 *sequence
options, it only updates identity* - *Fixed*
2. *Cycled option issue - **Fixed*
Steps to reproduce :
- Update cycled to Yes, save it.
- Now change it to No, trying saving, gives error.

 --
 *Rahul Shirsat*
 Software Engineer | EnterpriseDB Corporation.

>>>
>>>
>>> --
>>> *Rahul Shirsat*
>>> Software Engineer | EnterpriseDB Corporation.
>>>
>>
>>
>> --
>> *Thanks & Regards*
>> *Akshay Joshi*
>> *pgAdmin Hacker | Sr. Software Architect*
>> *EDB Postgres *
>>
>> *Mobile: +91 976-788-8246*
>>
>
>
> --
> *Rahul Shirsat*
> Software Engineer | EnterpriseDB Corporation.
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres *

*Mobile: +91 976-788-8246*


[pgAdmin4][Patch] - SonarQube Fixes

2020-08-03 Thread Khushboo Vashi
Hi,

Please find the attached patch to fix the sonarqube code smells having the
rule "String literals should not be duplicated".

Thanks,
Khushboo


sonarqube_fixes.patch
Description: Binary data


Re: WIP: SQL Formatter

2020-08-03 Thread Aditya Toshniwal
Hi,

On Fri, Jul 31, 2020 at 6:03 PM Dave Page  wrote:

> Hi
>
> Currently, all the CodeMirrors in pgAdmin use the settings from the Query
>> tool -> Editor, even though they're not related.  I think you're right.
>> We should move all CodeMirror settings out of the Query tool and move it to
>> a new node - "SQL" may be. Editor and Auto-format would be sub nodes under
>> SQL. With that, the editor settings will apply at all the places where
>> CodeMirror editing is used(function body, query tool). What do you say ?
>>
>
> Turns out that's more work than I really have time for at the moment,
> because it means making the editors be able to handle automatic reloads of
> multiple preference sections. We can always think about moving the
> formatting preferences into their own section later.
>
> In the meantime, this update to the patch does what was originally
> suggested and puts the options into a Query Tool -> SQL Formatting section.
>
Cool.

>
> Comments? Obviously docs will need updating too, once we're all happy with
> the basics.
>
It works nice. A shortcut and auto format only selected text would be
helpful.

>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EDB: http://www.enterprisedb.com
>
>

-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*

"Don't Complain about Heat, Plant a TREE"


Re: WIP: SQL Formatter

2020-08-03 Thread Dave Page
On Mon, Aug 3, 2020 at 10:31 AM Aditya Toshniwal <
aditya.toshni...@enterprisedb.com> wrote:

> Hi,
>
> On Fri, Jul 31, 2020 at 6:03 PM Dave Page  wrote:
>
>> Hi
>>
>> Currently, all the CodeMirrors in pgAdmin use the settings from the Query
>>> tool -> Editor, even though they're not related.  I think you're right.
>>> We should move all CodeMirror settings out of the Query tool and move it to
>>> a new node - "SQL" may be. Editor and Auto-format would be sub nodes under
>>> SQL. With that, the editor settings will apply at all the places where
>>> CodeMirror editing is used(function body, query tool). What do you say ?
>>>
>>
>> Turns out that's more work than I really have time for at the moment,
>> because it means making the editors be able to handle automatic reloads of
>> multiple preference sections. We can always think about moving the
>> formatting preferences into their own section later.
>>
>> In the meantime, this update to the patch does what was originally
>> suggested and puts the options into a Query Tool -> SQL Formatting section.
>>
> Cool.
>
>>
>> Comments? Obviously docs will need updating too, once we're all happy
>> with the basics.
>>
> It works nice. A shortcut and auto format only selected text would be
> helpful.
>

Yeah, the shortcut crossed my mind. Any thoughts on what it could be? I was
struggling to find something that made sense and wasn't used by Chrome or
elsewhere.

Formatting only the selected text might be troublesome; it may create some
very strange results if a partial statement is selected.

Thanks.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EDB: http://www.enterprisedb.com


Re: WIP: SQL Formatter

2020-08-03 Thread Aditya Toshniwal
Hi,

On Mon, Aug 3, 2020 at 3:06 PM Dave Page  wrote:

>
>
> On Mon, Aug 3, 2020 at 10:31 AM Aditya Toshniwal <
> aditya.toshni...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> On Fri, Jul 31, 2020 at 6:03 PM Dave Page  wrote:
>>
>>> Hi
>>>
>>> Currently, all the CodeMirrors in pgAdmin use the settings from the
 Query tool -> Editor, even though they're not related.  I think you're
 right. We should move all CodeMirror settings out of the Query tool and
 move it to a new node - "SQL" may be. Editor and Auto-format would be sub
 nodes under SQL. With that, the editor settings will apply at all the
 places where CodeMirror editing is used(function body, query tool). What do
 you say ?

>>>
>>> Turns out that's more work than I really have time for at the moment,
>>> because it means making the editors be able to handle automatic reloads of
>>> multiple preference sections. We can always think about moving the
>>> formatting preferences into their own section later.
>>>
>>> In the meantime, this update to the patch does what was originally
>>> suggested and puts the options into a Query Tool -> SQL Formatting section.
>>>
>> Cool.
>>
>>>
>>> Comments? Obviously docs will need updating too, once we're all happy
>>> with the basics.
>>>
>> It works nice. A shortcut and auto format only selected text would be
>> helpful.
>>
>
> Yeah, the shortcut crossed my mind. Any thoughts on what it could be? I
> was struggling to find something that made sense and wasn't used by Chrome
> or elsewhere.
>
I can only find Shift+Cmd+K available.

>
> Formatting only the selected text might be troublesome; it may create some
> very strange results if a partial statement is selected.
>
Formatter should not be blamed in that case. It did what was asked. :P

>
>
Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EDB: http://www.enterprisedb.com
>
>

-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*

"Don't Complain about Heat, Plant a TREE"


Re: [pgAdmin4][Patch] - SonarQube Issues - 12 (String literals should not be duplicated)

2020-08-03 Thread Yogesh Mahajan
Hello,

Please find the attached patch -


Thanks,
Yogesh Mahajan
QA - Team
EnterpriseDB Corporation

Phone: +91-9741705709


On Mon, Aug 3, 2020 at 12:56 PM Akshay Joshi 
wrote:

> Hi Yogesh
>
> Instead of declaring global variables, I would suggest declaring them as a
> class variable (constants). Make the changes and resend the patch
>
> On Mon, Aug 3, 2020 at 10:40 AM Yogesh Mahajan <
> yogesh.maha...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find patch which fixes 15+ issues related to rule -
>> 1.String literals should not be duplicated
>>
>> Thanks,
>> Yogesh Mahajan
>> QA - Team
>> EnterpriseDB Corporation
>>
>> Phone: +91-9741705709
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Sr. Software Architect*
> *EDB Postgres *
>
> *Mobile: +91 976-788-8246*
>


SonarQubeFix12_v2.patch
Description: Binary data


Re: [pgAdmin4][Patch] - SonarQube Fixes

2020-08-03 Thread Akshay Joshi
Hi Khushboo

As per offline discussion, multiple developers declaring the constant for
the same string and error messages. To avoid that only one developer should
work on this task.
Suggestions:

   - We should have a common class for Constants (which are not module
   specific).
   - For module specific constants we should not declare them as Global
   variables if possible declare them as the Class variable.
   - For common error messages(if any) we can define functions in
   PGChildNodeView.

Please incorporate the changes send by Yogesh.

On Mon, Aug 3, 2020 at 1:36 PM Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi,
>
> Please find the attached patch to fix the sonarqube code smells having the
> rule "String literals should not be duplicated".
>
> Thanks,
> Khushboo
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres *

*Mobile: +91 976-788-8246*