From dea5335ce50399d6c7508755e170da0d41442c28 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Wed, 12 Jun 2024 18:09:06 +0530 Subject: [PATCH] =?UTF-8?q?Fixed=20the=20following=20SonarQube=20code=20sm?= =?UTF-8?q?ells:=201)=C2=A0Do=20not=20use=20the=20Array=20index=20in=20key?= =?UTF-8?q?s.=202)=20Import=20from=20the=20same=20module=20should=20be=20m?= =?UTF-8?q?erged.=203)=20Mutable=20variables=20should=20not=20be=20exporte?= =?UTF-8?q?d.=204)=20Variables=20should=20not=20be=20initialized=20to=20un?= =?UTF-8?q?defined.=205)=20startswith=20or=20endswith=20method=20should=20?= =?UTF-8?q?be=20used.=206)=C2=A0Unwrap=20this=20unnecessarily=20grouped=20?= =?UTF-8?q?subpattern.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additionally, addressed many other SonarQube rules. --- Dockerfile | 4 ++-- docs/en_US/theme/pgadmin4/layout.html | 6 +++--- runtime/src/js/pgadmin.js | 4 ++-- .../servers/databases/schemas/static/js/child.js | 2 +- .../tables/columns/static/js/column.ui.js | 2 +- .../servers/databases/schemas/utils.py | 4 ++-- .../dashboard/static/js/SystemStats/Storage.jsx | 8 ++++---- .../dashboard/static/js/SystemStats/Summary.jsx | 4 ++-- web/pgadmin/misc/cloud/static/js/aws.js | 3 +-- web/pgadmin/misc/cloud/static/js/azure.js | 2 +- .../misc/cloud/static/js/azure_schema.ui.js | 2 +- .../misc/cloud/static/js/cloud_components.jsx | 3 +-- web/pgadmin/static/js/Explain/Graphical.jsx | 4 ++-- .../static/js/SchemaView/DataGridView.jsx | 2 +- web/pgadmin/static/js/SchemaView/index.jsx | 9 +++------ .../static/js/components/PgReactTableStyled.jsx | 8 ++++---- web/pgadmin/static/js/window.js | 2 +- web/pgadmin/tools/backup/__init__.py | 2 +- .../tools/debugger/static/js/DebuggerModule.js | 2 +- .../static/js/erd_tool/dialogs/TableDialog.js | 2 +- web/pgadmin/tools/import_export/__init__.py | 2 +- web/pgadmin/tools/restore/__init__.py | 2 +- .../static/js/components/QueryToolComponent.jsx | 2 +- .../js/components/dialogs/MacrosDialog.jsx | 2 +- .../js/components/sections/GraphVisualiser.jsx | 3 +-- .../static/js/UserManagementDialog.jsx | 16 ++++++++-------- web/pgadmin/utils/driver/psycopg3/__init__.py | 2 +- .../javascript/fake_browser/browser.js | 2 +- web/regression/javascript/genericFunctions.jsx | 2 +- 29 files changed, 51 insertions(+), 57 deletions(-) diff --git a/Dockerfile b/Dockerfile index c6e0c3d9c..ae624d569 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,7 +70,7 @@ FROM alpine:latest AS env-builder # Install dependencies COPY requirements.txt / -RUN apk add --no-cache \ +RUN apk add --no-cache \ make \ python3 \ py3-pip && \ @@ -187,7 +187,7 @@ COPY LICENSE /pgadmin4/LICENSE COPY DEPENDENCIES /pgadmin4/DEPENDENCIES # Install runtime dependencies and configure everything in one RUN step -RUN apk add \ +RUN apk add --no-cache \ python3 \ py3-pip \ postfix \ diff --git a/docs/en_US/theme/pgadmin4/layout.html b/docs/en_US/theme/pgadmin4/layout.html index 9ab59aef6..1bd6eeb70 100644 --- a/docs/en_US/theme/pgadmin4/layout.html +++ b/docs/en_US/theme/pgadmin4/layout.html @@ -14,12 +14,12 @@ {% trans copyright=copyright|e %}
  • © Copyright {{ copyright }}.
  • {% endtrans %} {%- endif %} {%- endif %} -
  • index
  • +
  • index
  • {%- if next %} -
  • next |
  • +
  • next |
  • {%- endif %} {%- if prev %} -
  • previous |
  • +
  • previous |
  • {%- endif %} diff --git a/runtime/src/js/pgadmin.js b/runtime/src/js/pgadmin.js index 0f3a3ad13..174e1780f 100644 --- a/runtime/src/js/pgadmin.js +++ b/runtime/src/js/pgadmin.js @@ -212,7 +212,7 @@ function launchPgAdminWindow() { // https://github.com/nwjs/nw.js/issues/7973 pgadminWindow.on('close', function () { // Resize Window - resizeHeightBy = pgadminWindow.window.outerHeight - pgadminWindow.window.innerHeight; + let resizeHeightBy = pgadminWindow.window.outerHeight - pgadminWindow.window.innerHeight; pgadminWindow.resizeBy(0, -resizeHeightBy); // Remove 'close' event handler, and then close window pgadminWindow.removeAllListeners('close'); @@ -554,7 +554,7 @@ function getSubMenu(menuItem) { if (sub.submenu?.items?.length) { sub.submenu.items.forEach((m) => { if (m.type == 'checkbox') { - m.label == item.label ? m.checked = true : m.checked = false; + m.checked = m.label == item.label; } }); } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/child.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/child.js index d36e5cff7..7dabd881f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/child.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/child.js @@ -10,7 +10,7 @@ import * as Node from 'pgbrowser/node'; import * as SchemaTreeNode from './schema_child_tree_node'; -let SchemaChildNode = Node.extend({ +const SchemaChildNode = Node.extend({ parent_type: ['schema', 'catalog'], canDrop: SchemaTreeNode.isTreeItemOfChildOfSchema, canDropCascade: SchemaTreeNode.isTreeItemOfChildOfSchema, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js index b89d6ac56..afa4b8d5d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui.js @@ -587,7 +587,7 @@ export default class ColumnSchema extends BaseUISchema { } validate(state, setError) { - let msg = undefined; + let msg; if (!_.isUndefined(state.cltype) && !isEmptyString(state.attlen)) { // Validation for Length field diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py index 68338c086..fd62afa24 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py @@ -527,7 +527,7 @@ def parse_rule_definition(res): condition_part = condition_part_match.group(1) condition_match = re.search( - r"(?:WHERE)\s+(\([\s\S]*\))\s+(?:DO)", condition_part) + r"(?:WHERE)?\s+(\([\s\S]*\))\s+(?:DO)?", condition_part) if condition_match is not None: condition = condition_match.group(1) @@ -537,7 +537,7 @@ def parse_rule_definition(res): # Parse data for statements statement_match = re.search( - r"(?:DO\s+)(?:INSTEAD\s+)?([\s\S]*)(?:;)", data_def) + r"(?:DO\s+)?(?:INSTEAD\s+)?([\s\S]*)(?:;)?", data_def) statement = '' if statement_match is not None: diff --git a/web/pgadmin/dashboard/static/js/SystemStats/Storage.jsx b/web/pgadmin/dashboard/static/js/SystemStats/Storage.jsx index b5f529753..a26373eb0 100644 --- a/web/pgadmin/dashboard/static/js/SystemStats/Storage.jsx +++ b/web/pgadmin/dashboard/static/js/SystemStats/Storage.jsx @@ -106,14 +106,14 @@ const DiskStatsTable = (props) => { - {tableHeader.map((item, index) => ( - + {tableHeader.map((item) => ( + ))} - {data.map((item, index) => ( - + {data.map((item) => ( + {tableHeader.map((header, id) => ( ))} diff --git a/web/pgadmin/dashboard/static/js/SystemStats/Summary.jsx b/web/pgadmin/dashboard/static/js/SystemStats/Summary.jsx index 27a984600..7635cd506 100644 --- a/web/pgadmin/dashboard/static/js/SystemStats/Summary.jsx +++ b/web/pgadmin/dashboard/static/js/SystemStats/Summary.jsx @@ -54,8 +54,8 @@ const SummaryTable = (props) => { - {data.map((item, index) => ( - + {data.map((item) => ( + diff --git a/web/pgadmin/misc/cloud/static/js/aws.js b/web/pgadmin/misc/cloud/static/js/aws.js index 5294a8594..1907d7b7e 100644 --- a/web/pgadmin/misc/cloud/static/js/aws.js +++ b/web/pgadmin/misc/cloud/static/js/aws.js @@ -248,8 +248,7 @@ export function getAWSSummary(cloud, cloudInstanceDetails, cloudDBDetails) { } const getStorageType = (cloudInstanceDetails) => { - let _storage_type = 'General Purpose SSD (gp2)', - _io1 = undefined; + let _storage_type = 'General Purpose SSD (gp2)', _io1; if(cloudInstanceDetails.storage_type == 'gp2'){ _storage_type = 'General Purpose SSD (gp2)';} else if (cloudInstanceDetails.storage_type == 'gp3'){ _storage_type = 'General Purpose SSD (gp3)';} diff --git a/web/pgadmin/misc/cloud/static/js/azure.js b/web/pgadmin/misc/cloud/static/js/azure.js index c2b2d4bb6..a5494b799 100644 --- a/web/pgadmin/misc/cloud/static/js/azure.js +++ b/web/pgadmin/misc/cloud/static/js/azure.js @@ -273,7 +273,7 @@ export function checkClusternameAvailbility(clusterName){ resolve(res.data); } }).catch((error) => { - reject(gettext(`Error while checking server name availability with Microsoft Azure: ${error.response.data.errormsg}`)); + reject(new Error(gettext(`Error while checking server name availability with Microsoft Azure: ${error.response.data.errormsg}`))); }); }); } diff --git a/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js b/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js index 770beb35b..e97977784 100644 --- a/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js +++ b/web/pgadmin/misc/cloud/static/js/azure_schema.ui.js @@ -717,7 +717,7 @@ class AzureClusterSchema extends BaseUISchema { } validate(data, setErr) { - if ( !isEmptyString(data.name) && (!/^[a-z0-9\-]*$/.test(data.name) || data.name.length < 3)) { + if ( !isEmptyString(data.name) && (!/^[a-z0-9-]*$/.test(data.name) || data.name.length < 3)) { setErr('name',gettext('Name must be more than 2 characters and must only contain lowercase letters, numbers, and hyphens')); return true; } diff --git a/web/pgadmin/misc/cloud/static/js/cloud_components.jsx b/web/pgadmin/misc/cloud/static/js/cloud_components.jsx index 461386a2e..83c914cf9 100644 --- a/web/pgadmin/misc/cloud/static/js/cloud_components.jsx +++ b/web/pgadmin/misc/cloud/static/js/cloud_components.jsx @@ -8,14 +8,13 @@ ////////////////////////////////////////////////////////////// import React from 'react'; -import { ToggleButton, ToggleButtonGroup } from '@mui/material'; +import { ToggleButton, ToggleButtonGroup, TableBody, TableCell, TableHead, TableRow } from '@mui/material'; import CheckRoundedIcon from '@mui/icons-material/CheckRounded'; import { DefaultButton, PrimaryButton } from '../../../../static/js/components/Buttons'; import PropTypes from 'prop-types'; import { getAWSSummary } from './aws'; import {getAzureSummary} from './azure'; import { getBigAnimalSummary } from './biganimal'; -import { TableBody, TableCell, TableHead, TableRow } from '@mui/material'; import gettext from 'sources/gettext'; import { getGoogleSummary } from './google'; import { CLOUD_PROVIDERS_LABELS } from './cloud_constants'; diff --git a/web/pgadmin/static/js/Explain/Graphical.jsx b/web/pgadmin/static/js/Explain/Graphical.jsx index db805b913..60a4243df 100644 --- a/web/pgadmin/static/js/Explain/Graphical.jsx +++ b/web/pgadmin/static/js/Explain/Graphical.jsx @@ -158,9 +158,9 @@ function Multitext({currentXpos, currentYpos, label, maxWidth}) { return res; }; - for (let i = 0; i < words.length; i++) { + for (let word in words) { let tmpArr = splitTextInMultiLine( - currLine, widthSoFar, words[i] + currLine, widthSoFar, word ); if (currLine) { diff --git a/web/pgadmin/static/js/SchemaView/DataGridView.jsx b/web/pgadmin/static/js/SchemaView/DataGridView.jsx index fe8c4798b..2c704c218 100644 --- a/web/pgadmin/static/js/SchemaView/DataGridView.jsx +++ b/web/pgadmin/static/js/SchemaView/DataGridView.jsx @@ -601,7 +601,7 @@ export default function DataGridView({ {rows.map((row, i) => { return - diff --git a/web/pgadmin/static/js/SchemaView/index.jsx b/web/pgadmin/static/js/SchemaView/index.jsx index 1e93c1c46..a5bd98401 100644 --- a/web/pgadmin/static/js/SchemaView/index.jsx +++ b/web/pgadmin/static/js/SchemaView/index.jsx @@ -103,14 +103,11 @@ function isValueEqual(val1, val2) { /* If the orig value was null and new one is empty string, then its a "no change" */ /* If the orig value and new value are of different datatype but of same value(numeric) "no change" */ /* If the orig value is undefined or null and new value is boolean false "no change" */ - if (_.isEqual(val1, val2) + return (_.isEqual(val1, val2) || ((val1 === null || _.isUndefined(val1)) && val2 === '') || ((val1 === null || _.isUndefined(val1)) && typeof(val2) === 'boolean' && !val2) || (attrDefined ? (!_.isObject(val1) && _.isEqual(val1.toString(), val2.toString())) : false) - ) { - return true; - } - return false; + ); } /* Compare two objects */ @@ -144,7 +141,7 @@ function getChangedData(topSchema, viewHelperProps, sessData, stringify=false, i if(_.isNull(change) && parseChanges.depth === 0) { change = ''; } - return levelChanges[id] = change; + levelChanges[id] = change; } }; diff --git a/web/pgadmin/static/js/components/PgReactTableStyled.jsx b/web/pgadmin/static/js/components/PgReactTableStyled.jsx index 086f491be..b627eb024 100644 --- a/web/pgadmin/static/js/components/PgReactTableStyled.jsx +++ b/web/pgadmin/static/js/components/PgReactTableStyled.jsx @@ -171,7 +171,7 @@ export const PgReactTableCell = forwardRef(({row, cell, children, className}, re flex: `var(--col-${cell.column.id.replace(/\W/g, '_')}-size) 0 auto`, width: `calc(var(--col-${cell.column.id.replace(/\W/g, '_')}-size)*1px)`, ...(cell.column.columnDef.maxSize ? { maxWidth: `${cell.column.columnDef.maxSize}px` } : {}) - }} role='cell' + }} className={classNames.join(' ')} title={String(cell.getValue() ?? '')}>
    {children}
    @@ -189,7 +189,7 @@ PgReactTableCell.propTypes = { export const PgReactTableRow = forwardRef(({ children, className, ...props }, ref)=>{ return ( -
    +
    {children}
    ); @@ -232,8 +232,8 @@ PgReactTableRowExpandContent.propTypes = { export function PgReactTableHeader({table}) { return (
    - {table.getHeaderGroups().map((headerGroup, idx) => ( -
    + {table.getHeaderGroups().map((headerGroup) => ( +
    {headerGroup.headers.map((header) => (
    { return opener.opener?.pgAdmin ? getWindowOpener(opener.opener) : opener; }; -let pgWindow = function() { +const pgWindow = function() { let localPgWindow = null; try { if(window.opener?.pgAdmin) { diff --git a/web/pgadmin/tools/backup/__init__.py b/web/pgadmin/tools/backup/__init__.py index fbec8396a..6599a45df 100644 --- a/web/pgadmin/tools/backup/__init__.py +++ b/web/pgadmin/tools/backup/__init__.py @@ -103,7 +103,7 @@ class BackupMessage(IProcessDesc): return '' for arg in _args: - if arg and len(arg) >= 2 and arg[:2] == '--': + if arg and len(arg) >= 2 and arg.startswith('--'): self.cmd += ' ' + arg else: self.cmd += cmd_arg(arg) diff --git a/web/pgadmin/tools/debugger/static/js/DebuggerModule.js b/web/pgadmin/tools/debugger/static/js/DebuggerModule.js index 644ede1a2..bfcfb1f68 100644 --- a/web/pgadmin/tools/debugger/static/js/DebuggerModule.js +++ b/web/pgadmin/tools/debugger/static/js/DebuggerModule.js @@ -269,7 +269,7 @@ export default class DebuggerModule { } getUrl(_d, newTreeInfo, trans_id) { - let baseUrl = undefined; + let baseUrl; if (_d._type == 'function' || _d._type == 'edbfunc') { baseUrl = url_for( 'debugger.initialize_target_for_function', { diff --git a/web/pgadmin/tools/erd/static/js/erd_tool/dialogs/TableDialog.js b/web/pgadmin/tools/erd/static/js/erd_tool/dialogs/TableDialog.js index 7490e0605..1e917a7be 100644 --- a/web/pgadmin/tools/erd/static/js/erd_tool/dialogs/TableDialog.js +++ b/web/pgadmin/tools/erd/static/js/erd_tool/dialogs/TableDialog.js @@ -24,7 +24,7 @@ class EmptySchema extends BaseUISchema { } export function getTableDialogSchema(attributes, isNew, tableNodesDict, colTypes, schemas) { - let treeNodeInfo = undefined; + let treeNodeInfo; let columnSchema = new ColumnSchema( ()=>{/*This is intentional (SonarQube)*/}, diff --git a/web/pgadmin/tools/import_export/__init__.py b/web/pgadmin/tools/import_export/__init__.py index 4c3059377..224f8945b 100644 --- a/web/pgadmin/tools/import_export/__init__.py +++ b/web/pgadmin/tools/import_export/__init__.py @@ -80,7 +80,7 @@ class IEMessage(IProcessDesc): replace_next = False for arg in _args: - if arg and len(arg) >= 2 and arg[:2] == '--': + if arg and len(arg) >= 2 and arg.startswith('--'): if arg == '--command': replace_next = True self._cmd += ' ' + arg diff --git a/web/pgadmin/tools/restore/__init__.py b/web/pgadmin/tools/restore/__init__.py index cb5683648..e3c0fda62 100644 --- a/web/pgadmin/tools/restore/__init__.py +++ b/web/pgadmin/tools/restore/__init__.py @@ -72,7 +72,7 @@ class RestoreMessage(IProcessDesc): return '' for arg in _args: - if arg and len(arg) >= 2 and arg[:2] == '--': + if arg and len(arg) >= 2 and arg.startswith('--'): self.cmd += ' ' + arg else: self.cmd += cmd_arg(arg) diff --git a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx index 884561999..814a0ecd7 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/QueryToolComponent.jsx @@ -758,7 +758,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN ); }); if(existIdx > -1) { - reject(gettext('Connection with this configuration already present.')); + reject(new Error(gettext('Connection with this configuration already present.'))); return; } updateQueryToolConnection(connectionData, true) diff --git a/web/pgadmin/tools/sqleditor/static/js/components/dialogs/MacrosDialog.jsx b/web/pgadmin/tools/sqleditor/static/js/components/dialogs/MacrosDialog.jsx index 0f8fbabc1..97ff4bbd2 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/dialogs/MacrosDialog.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/dialogs/MacrosDialog.jsx @@ -189,7 +189,7 @@ export default function MacrosDialog({onClose, onSave}) { formType={'dialog'} getInitData={()=>{ if(macrosErr) { - return Promise.reject(macrosErr); + return Promise.reject(new Error(macrosErr)); } return Promise.resolve({macro: userMacrosData.filter((m)=>Boolean(m.name))}); }} diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/GraphVisualiser.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/GraphVisualiser.jsx index 0252ed99b..f3f3d3086 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/GraphVisualiser.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/GraphVisualiser.jsx @@ -14,7 +14,7 @@ import gettext from 'sources/gettext'; import PropTypes from 'prop-types'; import url_for from 'sources/url_for'; import Loader from 'sources/components/Loader'; -import { Box } from '@mui/material'; +import { Box, useTheme } from '@mui/material'; import ShowChartRoundedIcon from '@mui/icons-material/ShowChartRounded'; import ZoomOutMapIcon from '@mui/icons-material/ZoomOutMap'; import SaveAltIcon from '@mui/icons-material/SaveAlt'; @@ -26,7 +26,6 @@ import { LineChart, BarChart, PieChart, DATA_POINT_STYLE, DATA_POINT_SIZE, LightenDarkenColor} from 'sources/chartjs'; import { QueryToolEventsContext, QueryToolContext } from '../QueryToolComponent'; import { QUERY_TOOL_EVENTS, PANELS } from '../QueryToolConstants'; -import { useTheme } from '@mui/material'; import { getChartColor } from '../../../../../../static/js/utils'; const StyledBox = styled(Box)(({theme}) => ({ diff --git a/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx b/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx index c70bf5624..5494bd004 100644 --- a/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx +++ b/web/pgadmin/tools/user_management/static/js/UserManagementDialog.jsx @@ -166,10 +166,10 @@ class UserManagementCollection extends BaseUISchema { if (state.auth_source != AUTH_METHODS['INTERNAL']) { if (obj.isNew(state) && obj.top?._sessData?.userManagement) { - for (let i=0; i < obj.top._sessData.userManagement.length; i++) { - if (obj.top._sessData.userManagement[i]?.id && - obj.top._sessData.userManagement[i].username.toLowerCase() == state.username.toLowerCase() && - obj.top._sessData.userManagement[i].auth_source == state.auth_source) { + for (let user in obj.top._sessData.userManagement) { + if (user?.id && + user.username.toLowerCase() == state.username.toLowerCase() && + user.auth_source == state.auth_source) { msg = gettext('User name \'%s\' already exists', state.username); setError('username', msg); return true; @@ -179,7 +179,7 @@ class UserManagementCollection extends BaseUISchema { } if (state.auth_source == AUTH_METHODS['INTERNAL']) { - let email_filter = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; + let email_filter = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; if (isEmptyString(state.email)) { msg = gettext('Email cannot be empty'); setError('email', msg); @@ -193,9 +193,9 @@ class UserManagementCollection extends BaseUISchema { } if (obj.isNew(state) && obj.top?._sessData?.userManagement) { - for (let i=0; i < obj.top._sessData.userManagement.length; i++) { - if (obj.top._sessData.userManagement[i]?.id && - obj.top._sessData.userManagement[i].email?.toLowerCase() == state.email?.toLowerCase()) { + for (let user in obj.top._sessData.userManagement) { + if (user?.id && + user.email?.toLowerCase() == state.email?.toLowerCase()) { msg = gettext('Email address \'%s\' already exists', state.email); setError('email', msg); return true; diff --git a/web/pgadmin/utils/driver/psycopg3/__init__.py b/web/pgadmin/utils/driver/psycopg3/__init__.py index ab0eb5e65..534ce0cc5 100644 --- a/web/pgadmin/utils/driver/psycopg3/__init__.py +++ b/web/pgadmin/utils/driver/psycopg3/__init__.py @@ -336,7 +336,7 @@ class Driver(BaseDriver): return True # certain types should not be quoted even though it contains a space. # Evilness. - elif for_types and value[-2:] == "[]": + elif for_types and value.endswith('[]'): val_noarray = value[:-2] if for_types and val_noarray.lower() in [ diff --git a/web/regression/javascript/fake_browser/browser.js b/web/regression/javascript/fake_browser/browser.js index 8ba76e382..e2ec70a09 100644 --- a/web/regression/javascript/fake_browser/browser.js +++ b/web/regression/javascript/fake_browser/browser.js @@ -7,6 +7,6 @@ // ////////////////////////////////////////////////////////////////////////// -let treeMenu = null; +const treeMenu = null; export {treeMenu}; diff --git a/web/regression/javascript/genericFunctions.jsx b/web/regression/javascript/genericFunctions.jsx index 0dfd60bfd..6bedcd854 100644 --- a/web/regression/javascript/genericFunctions.jsx +++ b/web/regression/javascript/genericFunctions.jsx @@ -95,6 +95,6 @@ export const addNewDatagridRow = async (user, ctrl)=>{ await user.click(ctrl.container.querySelector('[data-test="add-row"] button')); }; -export let genericBeforeEach = ()=> { +export const genericBeforeEach = ()=> { pgWindow.pgAdmin = pgAdmin; };
    {item.header}{item.header}
    {item[header.accessorKey]}
    {item.name} {item.value}