Fixed following code smells reported by SonarQube:

1) Remove this redundant jump.
 2) Remove this commented out code.
 3) Variables should not be shadowed.
This commit is contained in:
Akshay Joshi
2022-01-21 18:53:48 +05:30
parent 12d6271b13
commit 343c3ee49c
50 changed files with 130 additions and 161 deletions

View File

@@ -355,7 +355,7 @@ export default function DataGridView({
disableResizing: false,
sortable: true,
...widthParms,
Cell: ({value, row, ...other}) => {
Cell: ({cellValue, row, ...other}) => {
/* Make sure to take the latest field info from schema */
field = _.find(schemaRef.current.fields, (f)=>f.id==field.id) || field;
@@ -365,16 +365,16 @@ export default function DataGridView({
console.error('cell is required ', field);
}
return <MappedCellControl rowIndex={row.index} value={value}
return <MappedCellControl rowIndex={row.index} value={cellValue}
row={row.original} {...field}
readonly={!editable}
disabled={false}
visible={true}
onCellChange={(value)=>{
onCellChange={(changeValue)=>{
dataDispatch({
type: SCHEMA_STATE_ACTIONS.SET_VALUE,
path: accessPath.concat([row.index, field.id]),
value: value,
value: changeValue,
});
}}
reRenderRow={other.reRenderRow}
@@ -385,6 +385,7 @@ export default function DataGridView({
colInfo.Cell.propTypes = {
row: PropTypes.object.isRequired,
value: PropTypes.any,
cellValue: PropTypes.any,
onCellChange: PropTypes.func,
};
return colInfo;

View File

@@ -69,12 +69,12 @@ export default function FieldSetView({
readonly={readonly}
disabled={disabled}
visible={visible}
onChange={(value)=>{
onChange={(changeValue)=>{
/* Get the changes on dependent fields as well */
dataDispatch({
type: SCHEMA_STATE_ACTIONS.SET_VALUE,
path: accessPath.concat(field.id),
value: value,
value: changeValue,
});
}}
hasError={hasError}

View File

@@ -303,12 +303,12 @@ export default function FormView({
readonly={readonly}
disabled={disabled}
visible={visible}
onChange={(value)=>{
onChange={(changeValue)=>{
/* Get the changes on dependent fields as well */
dataDispatch({
type: SCHEMA_STATE_ACTIONS.SET_VALUE,
path: accessPath.concat(id),
value: value,
value: changeValue,
});
}}
hasError={hasError}

View File

@@ -23,15 +23,15 @@ import { SelectRefresh} from '../components/SelectRefresh';
function MappedFormControlBase({type, value, id, onChange, className, visible, inputRef, noLabel, ...props}) {
const name = id;
const onTextChange = useCallback((e) => {
let value = e;
let val = e;
if(e && e.target) {
value = e.target.value;
val = e.target.value;
}
onChange && onChange(value);
onChange && onChange(val);
}, []);
const onSqlChange = useCallback((value) => {
onChange && onChange(value);
const onSqlChange = useCallback((changedValue) => {
onChange && onChange(changedValue);
}, []);
if(!visible) {
@@ -103,12 +103,12 @@ MappedFormControlBase.propTypes = {
function MappedCellControlBase({cell, value, id, optionsLoaded, onCellChange, visible, reRenderRow,...props}) {
const name = id;
const onTextChange = useCallback((e) => {
let value = e;
let val = e;
if(e && e.target) {
value = e.target.value;
val = e.target.value;
}
onCellChange && onCellChange(value);
onCellChange && onCellChange(val);
}, []);
/* Some grid cells are based on options selected in other cells.

View File

@@ -51,8 +51,8 @@ export default function CheckBoxTree({treeData, ...props}) {
nodes={treeData}
checked={checked}
expanded={expanded}
onCheck={checked => setChecked(checked)}
onExpand={expanded => setExpanded(expanded)}
onCheck={checkedVal => setChecked(checkedVal)}
onExpand={expandedVal => setExpanded(expandedVal)}
showNodeIcon={false}
icons={{
check: <CheckBoxIcon className={classes.checked}/>,

View File

@@ -171,9 +171,9 @@ export default function PgTable({ columns, data, isSelectRow, ...props }) {
return [...CLOUMNS];
}
});
hooks.useInstanceBeforeDimensions.push(({ headerGroups }) => {
hooks.useInstanceBeforeDimensions.push(({ tmpHeaderGroups }) => {
// fix the parent group of the selection button to not be resizable
const selectionGroupHeader = headerGroups[0].headers[0];
const selectionGroupHeader = tmpHeaderGroups[0].headers[0];
selectionGroupHeader.resizable = false;
});
}

View File

@@ -864,7 +864,6 @@ import Notify from '../../../static/js/helpers/Notifier';
};
this.isValueChanged = function() {
// var select_value = this.serializeValue();
var select_value = $select.data('checked');
return (!(select_value === 2 && (defaultValue == null || defaultValue == undefined))) &&
(select_value !== defaultValue);

View File

@@ -209,7 +209,6 @@ let FilterDialog = {
e.cancel = true;
pgAdmin.Browser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
null, null);
return;
} else if (e.button['data-btn-name'] === 'ok') {
e.cancel = true; // Do not close dialog

View File

@@ -251,7 +251,6 @@ let MacroDialog = {
e.cancel = true;
pgAdmin.Browser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
null, null);
return;
} else if (e.button['data-btn-name'] === 'ok') {
e.cancel = true; // Do not close dialog

View File

@@ -192,7 +192,7 @@ let NewConnectionDialog = {
self.showNewConnectionProgress[0]
).addClass('d-none');
},
get_title: function(qt_title_placeholder, selected_database_name, newConnCollectionModel, response) {
get_title: function(qt_title_placeholder, selected_database_name, newConnCollectionModel, tmpResponse) {
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%DATABASE%'), selected_database_name);
if(newConnCollectionModel['role']) {
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%USERNAME%'), newConnCollectionModel['role']);
@@ -200,7 +200,7 @@ let NewConnectionDialog = {
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%USERNAME%'), newConnCollectionModel['user']);
}
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%SERVER%'), response.server_name);
qt_title_placeholder = qt_title_placeholder.replace(new RegExp('%SERVER%'), tmpResponse.server_name);
return qt_title_placeholder;
},
callback: function(e) {
@@ -209,7 +209,6 @@ let NewConnectionDialog = {
e.cancel = true;
pgAdmin.Browser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
null, null);
return;
} else if (e.button['data-btn-name'] === 'ok') {
e.cancel = true; // Do not close dialog
let newConnCollectionModel = this.newConnCollectionModel.toJSON();

View File

@@ -65,7 +65,6 @@ let queryToolActions = {
},
explain: function (sqlEditorController) {
/* let explainQuery = `EXPLAIN (FORMAT JSON, ANALYZE OFF, VERBOSE ${verbose}, COSTS ${costEnabled}, BUFFERS OFF, TIMING OFF) `; */
const explainObject = {
format: 'json',
analyze: false,