Skip to content

Commit 2c37ff2

Browse files
Fixing following SonarQube Issues:
1. Ternary operators should not be nested. 2. "Exception" and "BaseException" should not be raised.
1 parent a30a722 commit 2c37ff2

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

web/pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,17 @@ export default class FunctionSchema extends BaseUISchema {
327327
group: gettext('Options'),
328328
disabled: obj.inCatalog() ? true : obj.isLessThan95ORNonSPL,
329329
deps: ['lanname'],
330-
depChange: (state, source) => (
331-
(source[source.length - 1] !== 'lanname') ? undefined : (
332-
obj.isLessThan95ORNonSPL(state)
333-
) ? {
330+
depChange: (state, source) => {
331+
if (source[source.length - 1] === 'lanname' && obj.isLessThan95ORNonSPL(state)) {
332+
return {
334333
provolatile: null,
335334
proisstrict: false,
336335
procost: null,
337336
proleakproof: false,
338337
proparallel: null,
339-
} : (
340-
obj.isLessThan95ORNonSPL(state) ? { proparallel: null } : undefined
341-
)
342-
),
338+
};
339+
}
340+
},
343341
},{
344342
id: 'prosecdef', label: gettext('Security of definer?'),
345343
group: gettext('Options'), type: 'switch',

web/pgadmin/static/js/SchemaView/utils/createFieldControls.jsx

+30-26
Original file line numberDiff line numberDiff line change
@@ -154,33 +154,37 @@ export const createFieldControls = ({
154154
isPropertyMode ? 'Properties-controlRow' : 'FormView-controlRow';
155155
break;
156156
default:
157-
{
158-
control = (
159-
hasView(field.type) ? View(field.type) : (
160-
field.id ? MappedFormControl : StaticMappedFormControl
161-
)
162-
);
163-
164-
if (inlineGroup) {
165-
controlProps['withContainer'] = false;
166-
controlProps['controlGridBasis'] = 3;
167-
}
157+
if (hasView(field.type)) {
158+
control = View(field.type);
159+
} else if (field.id) {
160+
control = MappedFormControl;
161+
} else {
162+
control = StaticMappedFormControl;
163+
}
168164

169-
controlProps['className'] = field.isFullTab ? '' : (
170-
isPropertyMode ? 'Properties-controlRow' : 'FormView-controlRow'
171-
);
172-
173-
if (field.id) {
174-
controlProps['id'] = field.id;
175-
controlProps['onChange'] = (changeValue) => {
176-
// Get the changes on dependent fields as well.
177-
dataDispatch?.({
178-
type: SCHEMA_STATE_ACTIONS.SET_VALUE,
179-
path: controlProps.accessPath,
180-
value: changeValue,
181-
});
182-
};
183-
}
165+
if (inlineGroup) {
166+
controlProps['withContainer'] = false;
167+
controlProps['controlGridBasis'] = 3;
168+
}
169+
170+
if (field.isFullTab) {
171+
controlProps['className'] = '';
172+
} else if (isPropertyMode) {
173+
controlProps['className'] = 'Properties-controlRow';
174+
} else {
175+
controlProps['className'] = 'FormView-controlRow';
176+
}
177+
178+
if (field.id) {
179+
controlProps['id'] = field.id;
180+
controlProps['onChange'] = (changeValue) => {
181+
// Get the changes on dependent fields as well.
182+
dataDispatch?.({
183+
type: SCHEMA_STATE_ACTIONS.SET_VALUE,
184+
path: controlProps.accessPath,
185+
value: changeValue,
186+
});
187+
};
184188
}
185189
break;
186190
}

web/pgadmin/utils/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def get_binary_path_versions(binary_path: str) -> dict:
380380
# if path doesn't exist raise exception
381381
if not os.path.isdir(binary_path):
382382
current_app.logger.warning('Invalid binary path.')
383-
raise Exception()
383+
raise FileNotFoundError()
384384
# Get the output of the '--version' command
385385
cmd = subprocess.run(
386386
[full_path, '--version'],
@@ -390,8 +390,6 @@ def get_binary_path_versions(binary_path: str) -> dict:
390390
)
391391
if cmd.returncode == 0:
392392
ret[utility] = cmd.stdout.split(") ", 1)[1].strip()
393-
else:
394-
raise Exception()
395393
except Exception as _:
396394
continue
397395

0 commit comments

Comments
 (0)