Fix SonarQube code smells:

1) String literals should not be duplicated.
2) Prefer using an optional chain expression instead, as it's more concise and easier to read.
3) Expected the Promise rejection reason to be an Error.
This commit is contained in:
Akshay Joshi
2024-06-10 18:04:32 +05:30
parent 2d2aa45ec5
commit 8857f0d179
57 changed files with 210 additions and 205 deletions

View File

@@ -11,6 +11,7 @@ import secrets
import string
import urllib3
import ipaddress
from pgadmin.utils.constants import IP_ADDRESS_STRING
def get_my_ip():
@@ -29,11 +30,11 @@ def get_my_ip():
ip = ipaddress.ip_address(external_ip)
if isinstance(ip, ipaddress.IPv4Address):
return '{}/{}'.format(external_ip, 32)
return IP_ADDRESS_STRING.format(external_ip, 32)
elif isinstance(ip, ipaddress.IPv6Address):
return '{}/{}'.format(external_ip, 128)
return IP_ADDRESS_STRING.format(external_ip, 128)
return '{}/{}'.format(external_ip, 32)
return IP_ADDRESS_STRING.format(external_ip, 32)
def get_random_id():