mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed the following code smells:
1. Use concise character class syntax
2. Add a "break" statement or remove this "else" clause.
3. Replace this generic exception class with a more specific one.
4. Use a regular expression literal instead of the 'RegExp' constructor.
5. Use the opposite operator ("not in") instead.
This commit is contained in:
committed by
Akshay Joshi
parent
d967d5046d
commit
cbf5886430
@@ -423,8 +423,7 @@ export default function CodeMirror({currEditor, name, value, options, events, re
|
||||
let pref = pgWindow?.pgAdmin?.Browser?.get_preferences_for_module('sqleditor') || {};
|
||||
if (autocomplete && pref.autocomplete_on_key_press) {
|
||||
editor.current.on('keyup', (cm, event)=>{
|
||||
let pattern = new RegExp('^[ -~]{1}$');
|
||||
if (!cm.state.completionActive && (event.key == 'Backspace' || pattern.test(event.key))) {
|
||||
if (!cm.state.completionActive && (event.key == 'Backspace' || /^[ -~]{1}$'/.test(event.key))) {
|
||||
OrigCodeMirror.commands.autocomplete(cm, null, {completeSingle: false});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ define([], function() {
|
||||
pgAdmin.natural_sort = function(a, b, options) {
|
||||
options = options || {};
|
||||
|
||||
let re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
|
||||
let re = /(^-?\d+(\.?\d*)[df]?e?\d?$|^0x[0-9a-f]+$|\d+)/gi,
|
||||
sre = /(^[ ]*|[ ]*$)/g,
|
||||
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
|
||||
hre = /^0x[0-9a-f]+$/i,
|
||||
|
||||
@@ -27,8 +27,7 @@ export function minMaxValidator(label, value, minValue, maxValue) {
|
||||
export function numberValidator(label, value) {
|
||||
if((_.isUndefined(value) || _.isNull(value) || String(value) === ''))
|
||||
return null;
|
||||
let pattern = new RegExp('^-?[0-9]+(\.?[0-9]*)?$');
|
||||
if (!pattern.test(value)) {
|
||||
if (!/^-?[0-9]+(\.?[0-9]*)?$/.test(value)) {
|
||||
return sprintf(pgAdmin.Browser.messages.MUST_BE_NUM, label);
|
||||
}
|
||||
return null;
|
||||
@@ -38,8 +37,7 @@ export function numberValidator(label, value) {
|
||||
export function integerValidator(label, value) {
|
||||
if((_.isUndefined(value) || _.isNull(value) || String(value) === ''))
|
||||
return null;
|
||||
let pattern = new RegExp('^-?[0-9]*$');
|
||||
if (!pattern.test(value)) {
|
||||
if (!/^-?[0-9]*$/.test(value)) {
|
||||
return sprintf(pgAdmin.Browser.messages.MUST_BE_INT, label);
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user