From 2e2c79857ab3e00cb5f06981370e8863014cc939 Mon Sep 17 00:00:00 2001 From: Andrey Kozlov Date: Fri, 29 May 2020 10:40:58 +0500 Subject: [PATCH] VP-2649: Fix Sonar cube critical bugs that prevent build on CI --- .../Common/Money/Currency.cs | 4 ++-- .../Domain/Catalog/CatalogConverter.cs | 7 ++----- .../Domain/Marketing/MarketingConverter.cs | 12 ++++++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/VirtoCommerce.Storefront.Model/Common/Money/Currency.cs b/VirtoCommerce.Storefront.Model/Common/Money/Currency.cs index 7e51f6967..379d914cb 100644 --- a/VirtoCommerce.Storefront.Model/Common/Money/Currency.cs +++ b/VirtoCommerce.Storefront.Model/Common/Money/Currency.cs @@ -1,8 +1,7 @@ -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Globalization; -using System.Runtime.Serialization; +using Newtonsoft.Json; namespace VirtoCommerce.Storefront.Model.Common { @@ -23,6 +22,7 @@ static Currency() } catch (Exception) { + // No actions needed } } } diff --git a/VirtoCommerce.Storefront/Domain/Catalog/CatalogConverter.cs b/VirtoCommerce.Storefront/Domain/Catalog/CatalogConverter.cs index 53ac0c8ad..49d8f442d 100644 --- a/VirtoCommerce.Storefront/Domain/Catalog/CatalogConverter.cs +++ b/VirtoCommerce.Storefront/Domain/Catalog/CatalogConverter.cs @@ -113,12 +113,9 @@ public static CatalogProperty ToProperty(this catalogDto.Property propertyDto, L } //For multilingual properties need populate LocalizedValues collection and set value for requested language - if (propertyDto.Multilanguage ?? false) + if ((propertyDto.Multilanguage ?? false) && propertyDto.Values != null) { - if (propertyDto.Values != null) - { - result.LocalizedValues = propertyDto.Values.Where(x => x.Value != null).Select(x => new LocalizedString(new Language(x.LanguageCode), x.Value.ToString())).ToList(); - } + result.LocalizedValues = propertyDto.Values.Where(x => x.Value != null).Select(x => new LocalizedString(new Language(x.LanguageCode), x.Value.ToString())).ToList(); } //Set property value diff --git a/VirtoCommerce.Storefront/Domain/Marketing/MarketingConverter.cs b/VirtoCommerce.Storefront/Domain/Marketing/MarketingConverter.cs index 84904c1d3..2fd09fc86 100644 --- a/VirtoCommerce.Storefront/Domain/Marketing/MarketingConverter.cs +++ b/VirtoCommerce.Storefront/Domain/Marketing/MarketingConverter.cs @@ -5,8 +5,8 @@ using VirtoCommerce.Storefront.Model.Catalog; using VirtoCommerce.Storefront.Model.Common; using VirtoCommerce.Storefront.Model.Marketing; -using platformDto = VirtoCommerce.Storefront.AutoRestClients.PlatformModuleApi.Models; using marketingDto = VirtoCommerce.Storefront.AutoRestClients.MarketingModuleApi.Models; +using platformDto = VirtoCommerce.Storefront.AutoRestClients.PlatformModuleApi.Models; namespace VirtoCommerce.Storefront.Domain { @@ -114,11 +114,11 @@ public static marketingDto.DynamicContentEvaluationContext ToDynamicContentEvalu var result = new marketingDto.DynamicContentEvaluationContext { UserGroups = dynamicContentEvalContext?.User?.Contact?.UserGroups, - Language = dynamicContentEvalContext.Language != null ? dynamicContentEvalContext.Language.CultureName : null, - StoreId = dynamicContentEvalContext.StoreId, - Tags = dynamicContentEvalContext.Tags, - ToDate = dynamicContentEvalContext.ToDate, - PlaceName = dynamicContentEvalContext.PlaceName + Language = dynamicContentEvalContext?.Language != null ? dynamicContentEvalContext.Language.CultureName : null, + StoreId = dynamicContentEvalContext?.StoreId, + Tags = dynamicContentEvalContext?.Tags, + ToDate = dynamicContentEvalContext?.ToDate, + PlaceName = dynamicContentEvalContext?.PlaceName }; return result; }