From 29c75eabdd2af4186fe9575ad6d938421fbd79a8 Mon Sep 17 00:00:00 2001 From: Angela Kim Date: Tue, 24 Sep 2024 17:49:19 -0400 Subject: [PATCH] committing SonarCloud Fix refactoring code from P1 --- public/src/admin/extend/widgets.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/public/src/admin/extend/widgets.js b/public/src/admin/extend/widgets.js index 1238ee772b..70d0fc49eb 100644 --- a/public/src/admin/extend/widgets.js +++ b/public/src/admin/extend/widgets.js @@ -119,18 +119,16 @@ define('admin/extend/widgets', [ const data = $(this).find('form').serializeArray(); for (const d in data) { - if (data.hasOwnProperty(d)) { - if (data[d].name) { - if (widgetData[data[d].name]) { - if (!Array.isArray(widgetData[data[d].name])) { - widgetData[data[d].name] = [ - widgetData[data[d].name], - ]; - } - widgetData[data[d].name].push(data[d].value); - } else { - widgetData[data[d].name] = data[d].value; + if (data.hasOwnProperty(d) && data[d].name) { + const name = data[d].name; + const value = data[d].value; + if (widgetData[name]) { + if (!Array.isArray(widgetData[name])) { + widgetData[name] = [widgetData[name]]; } + widgetData[name].push(value); + } else { + widgetData[name] = value; } } }