From 1a89c1f85f61c240e49594b3c7cf1533bddba57c Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Fri, 28 Jan 2022 17:20:34 +0530 Subject: [PATCH] Fixed code smell 'Update this function so that its implementation is not identical' reported by SonarQube. --- .../misc/file_manager/static/js/utility.js | 22 +- .../tools/debugger/static/js/debugger_ui.js | 22 +- .../tools/debugger/static/js/direct.js | 70 ++--- .../static/js/user_management.js | 18 +- .../javascript/SchemaView/SchemaView.spec.js | 34 +-- .../components/FormComponents.spec.js | 26 +- .../javascript/components/Privilege.spec.js | 47 ++-- .../javascript/genericFunctions.jsx | 74 ++++++ .../schema_ui_files/aggregate.ui.spec.js | 59 +---- .../schema_ui_files/cast.ui.spec.js | 58 +---- .../schema_ui_files/catalog.ui.spec.js | 59 +---- .../schema_ui_files/catalog_object.ui.spec.js | 23 +- .../catalog_object_column.ui.spec.js | 39 +-- .../check_constraint.ui.spec.js | 76 +----- .../schema_ui_files/collation.ui.spec.js | 59 +---- .../schema_ui_files/column.ui.spec.js | 75 +----- .../compound_trigger.ui.spec.js | 56 +--- .../schema_ui_files/database.ui.spec.js | 59 +---- .../schema_ui_files/domain.ui.spec.js | 110 +------- .../domain_constraint.ui.spec.js | 58 +---- .../schema_ui_files/edbfunc.ui.spec.js | 59 +---- .../schema_ui_files/edbvar.ui.spec.js | 59 +---- .../schema_ui_files/event_trigger.ui.spec.js | 59 +---- .../exclusion_constraint.ui.spec.js | 76 +----- .../schema_ui_files/extension.ui.spec.js | 59 +---- .../foreign_data_wrapper.ui.spec.js | 58 +---- .../schema_ui_files/foreign_key.ui.spec.js | 76 +----- .../schema_ui_files/foreign_server.ui.spec.js | 58 +---- .../schema_ui_files/foreign_table.ui.spec.js | 176 ++----------- .../fts_configuration.ui.spec.js | 58 +---- .../schema_ui_files/fts_dictionary.ui.spec.js | 58 +---- .../schema_ui_files/fts_parser.ui.spec.js | 59 +---- .../schema_ui_files/fts_template.ui.spec.js | 59 +---- .../schema_ui_files/functions.ui.spec.js | 157 +----------- .../schema_ui_files/grant_wizard.ui.spec.js | 11 +- .../schema_ui_files/import_export.ui.spec.js | 19 +- .../import_export_servers.ui.spec.js | 10 +- .../schema_ui_files/index.ui.spec.js | 94 +------ .../schema_ui_files/language.ui.spec.js | 58 +---- .../schema_ui_files/maintenance.ui.spec.js | 20 +- .../schema_ui_files/membership.ui.spec.js | 76 +----- .../schema_ui_files/mview.ui.spec.js | 59 +---- .../schema_ui_files/operator.ui.spec.js | 59 +---- .../schema_ui_files/packages.ui.spec.js | 59 +---- .../schema_ui_files/partition.ui.spec.js | 58 +---- .../partition.utils.ui.spec.js | 127 +-------- .../schema_ui_files/pga_job.ui.spec.js | 56 +--- .../schema_ui_files/pga_jobstep.ui.spec.js | 56 +--- .../schema_ui_files/pga_schedule.ui.spec.js | 106 +------- .../schema_ui_files/primary_key.ui.spec.js | 76 +----- .../schema_ui_files/privilege.ui.spec.js | 76 +----- .../schema_ui_files/publication.ui.spec.js | 60 +---- .../schema_ui_files/resource_group.ui.spec.js | 58 +---- .../schema_ui_files/restore.ui.spec.js | 19 +- .../schema_ui_files/role.ui.spec.js | 57 +---- .../row_security_policy.ui.spec.js | 57 +---- .../schema_ui_files/rule.ui.spec.js | 57 +---- .../schema_ui_files/schema.ui.spec.js | 59 +---- .../schema_ui_files/sequence.ui.spec.js | 58 +---- .../schema_ui_files/server.ui.spec.js | 57 +---- .../schema_ui_files/server_group.ui.spec.js | 57 +---- .../schema_ui_files/subscription.ui.spec.js | 56 +--- .../schema_ui_files/synonym.ui.spec.js | 58 +---- .../schema_ui_files/table.ui.spec.js | 122 +++------ .../schema_ui_files/tablespace.ui.spec.js | 58 +---- .../schema_ui_files/trigger.ui.spec.js | 167 +----------- .../trigger_function.ui.spec.js | 57 +---- .../schema_ui_files/type.ui.spec.js | 241 ++---------------- .../unique_constraint.ui.spec.js | 76 +----- .../schema_ui_files/user_mapping.ui.spec.js | 58 +---- .../schema_ui_files/variable.ui.spec.js | 79 +----- .../schema_ui_files/view.ui.spec.js | 59 +---- 72 files changed, 579 insertions(+), 4126 deletions(-) create mode 100644 web/regression/javascript/genericFunctions.jsx diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js index a59f2e1ae..47bd36f8c 100644 --- a/web/pgadmin/misc/file_manager/static/js/utility.js +++ b/web/pgadmin/misc/file_manager/static/js/utility.js @@ -467,6 +467,16 @@ define([ return `
${lg.could_not_retrieve_folder}
`; }; + var getCapClasses = function(item_data, capabilities) { + let capClasses = ''; + capClasses = Object.keys(capabilities).map(function(cap) { + if (has_capability(item_data, capabilities[cap])) { + return 'cap_' + capabilities[cap]; + } + }).join(' '); + return capClasses; + }; + var getGridView = function(data, capabilities) { let ret_ele = '