From 207cdd79b8a151ac8036d7610a51ac4c3cc97dc1 Mon Sep 17 00:00:00 2001 From: Ugo Bechameil Date: Fri, 12 Jul 2024 13:01:47 +0200 Subject: [PATCH] HCK-7052 - Fix sonar reports (#136) * Fix sonar reports * Update typeHelper.js --------- Co-authored-by: chulanovskyi-bs <56116665+chulanovskyi-bs@users.noreply.github.com> --- .../helpers/alterScriptFromDeltaHelper.js | 4 ++-- forward_engineering/helpers/typeHelper.js | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/forward_engineering/helpers/alterScriptFromDeltaHelper.js b/forward_engineering/helpers/alterScriptFromDeltaHelper.js index 7955dcb..f55a7d3 100644 --- a/forward_engineering/helpers/alterScriptFromDeltaHelper.js +++ b/forward_engineering/helpers/alterScriptFromDeltaHelper.js @@ -142,13 +142,13 @@ const getPropertiesForUpdateTable = (properties = []) => { } const newField = value.compMod?.newField || {}; const oldField = value.compMod?.oldField || {}; - Object.entries(newField).map(([keyNewField, valueNewField]) => { + Object.entries(newField).forEach(([keyNewField, valueNewField]) => { if (oldField[keyNewField] !== valueNewField) { value[keyNewField] = valueNewField; } if (keyNewField === 'name' && oldField[keyNewField] !== valueNewField) { name = valueNewField; - } + } }); return [name, value]; }); diff --git a/forward_engineering/helpers/typeHelper.js b/forward_engineering/helpers/typeHelper.js index fb51f9e..be5f7ea 100644 --- a/forward_engineering/helpers/typeHelper.js +++ b/forward_engineering/helpers/typeHelper.js @@ -21,7 +21,7 @@ const ifType = type => { const getModeType = (type, defaultType, udtTypeMap) => { if (type) { const mode = getFieldConfig(type, 'mode'); - const definedType = mode && mode.options ? mode.options[0] : type; + const definedType = mode?.options ? mode.options[0] : type; return getHandlerByType( type, @@ -91,7 +91,7 @@ const getStructuralTypeHandler = (type, isNeedToBeFrozen, udtTypeMap) => { const typeConfig = getTypeConfig(arraySchema.type); if (typeConfig.subtypes && arraySchema.subtype) { const subTypeConfig = typeConfig.subtypes[arraySchema.subtype]; - if (subTypeConfig && subTypeConfig.childValueType) { + if (subTypeConfig?.childValueType) { return getModeType(subTypeConfig.childValueType, defaultType, udtTypeMap); } } @@ -113,7 +113,7 @@ const getStructuralTypeHandler = (type, isNeedToBeFrozen, udtTypeMap) => { const typeConfig = getTypeConfig(objectSchema.type); if (typeConfig.subtypes && objectSchema.subtype) { const subTypeConfig = typeConfig.subtypes[objectSchema.subtype]; - if (subTypeConfig && subTypeConfig.childValueType) { + if (subTypeConfig?.childValueType) { return getModeType(subTypeConfig.childValueType, defaultType, udtTypeMap); } } @@ -133,8 +133,6 @@ const getStructuralTypeHandler = (type, isNeedToBeFrozen, udtTypeMap) => { if (nestedType !== undefined) { return nestedType; - } else { - (''); } } else { return 'text'; @@ -157,7 +155,7 @@ const getStructuralTypeHandler = (type, isNeedToBeFrozen, udtTypeMap) => { const keyType = canTypeHaveSubtype(propertyData.keyType, propertyData.keySubtype) ? propertyData.keySubtype : getModeType(propertyData.keyType, 'text', udtTypeMap); - const valueType = getValueTypeFromObject(propertyData, 'text', udtTypeMap, propertyName); + const valueType = getValueTypeFromObject(propertyData, 'text', udtTypeMap); return `map<${keyType}, ${valueType}>`; };