From eef3cb5ff10dddb3c19c3aae0b90081bb383c818 Mon Sep 17 00:00:00 2001 From: Jim Washbrook Date: Tue, 1 Oct 2024 13:01:40 +0100 Subject: [PATCH] chore: Sonarcloud complaints --- .../Models/Mapped/RichTextContentItem.cs | 2 +- .../Models/Mapped/Standard/EmbeddedEntry.cs | 4 ++-- .../Views/Shared/RichText/_HyperLink.cshtml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Dfe.ContentSupport.Web/Models/Mapped/RichTextContentItem.cs b/src/Dfe.ContentSupport.Web/Models/Mapped/RichTextContentItem.cs index c586618..f13b962 100644 --- a/src/Dfe.ContentSupport.Web/Models/Mapped/RichTextContentItem.cs +++ b/src/Dfe.ContentSupport.Web/Models/Mapped/RichTextContentItem.cs @@ -11,6 +11,6 @@ public class RichTextContentItem : CsContentItem public string? Value { get; set; } = null; public List Tags { get; set; } = []; - public virtual bool HaveNoContent => Content.Count == 0 || Content.All(content => content.IsEmptyContent); + public virtual bool HaveNoContent => Content.Count == 0 || Content.TrueForAll(content => content.IsEmptyContent); public virtual bool IsEmptyContent => HaveNoContent && string.IsNullOrEmpty(Value); } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Models/Mapped/Standard/EmbeddedEntry.cs b/src/Dfe.ContentSupport.Web/Models/Mapped/Standard/EmbeddedEntry.cs index d82e6a8..83895a0 100644 --- a/src/Dfe.ContentSupport.Web/Models/Mapped/Standard/EmbeddedEntry.cs +++ b/src/Dfe.ContentSupport.Web/Models/Mapped/Standard/EmbeddedEntry.cs @@ -16,6 +16,6 @@ public EmbeddedEntry() public RichTextContentItem? RichText { get; set; } public CustomComponent? CustomComponent { get; set; } - public override bool HaveNoContent => Content.Count == 0 || Content.All(content => content.IsEmptyContent); - public override bool IsEmptyContent => base.IsEmptyContent && (RichText == null || (RichText != null && RichText.IsEmptyContent)); + public override bool HaveNoContent => Content.Count == 0 || Content.TrueForAll(content => content.IsEmptyContent); + public override bool IsEmptyContent => base.IsEmptyContent && (RichText == null || RichText.IsEmptyContent); } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_HyperLink.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_HyperLink.cshtml index 6d21a81..0c4382e 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_HyperLink.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_HyperLink.cshtml @@ -6,10 +6,10 @@ } else { - var textContainsOpenInNewTab = @Model.Content[0].Value.ToLower().Contains("(opens in new tab)"); + var textContainsOpenInNewTab = Model.Content[0].Value?.ToLower().Contains("(opens in new tab)") ?? false; var linkClass = textContainsOpenInNewTab ? "opens-in-new-tab" : ""; if(textContainsOpenInNewTab){ - Model.Content[0].Value = @Model.Content[0].Value.Replace(" (opens in new tab)", ""); + Model.Content[0].Value = Model.Content[0].Value?.Replace(" (opens in new tab)", "") ?? ""; } @Model.Content[0].Value