Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Umbraco.Core/Collections/ObservableDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ protected override void InsertItem(int index, TValue item)

if (index != Count)
{
foreach (TKey k in Indecies.Keys.Where(k => Indecies[k] >= index).ToList())
foreach (KeyValuePair<TKey, int> largerOrEqualToIndex in Indecies.Where(kvp => kvp.Value >= index))
{
Indecies[k]++;
Indecies[largerOrEqualToIndex.Key] = largerOrEqualToIndex.Value + 1;
}
}

Expand All @@ -185,9 +185,9 @@ protected override void RemoveItem(int index)

Indecies.Remove(key);

foreach (TKey k in Indecies.Keys.Where(k => Indecies[k] > index).ToList())
foreach (KeyValuePair<TKey, int> largerThanIndex in Indecies.Where(kvp => kvp.Value > index))
{
Indecies[k]--;
Indecies[largerThanIndex.Key] = largerThanIndex.Value - 1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/Models/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public IEnumerable<string>? EditedCultures

/// <inheritdoc />
[IgnoreDataMember]
public IEnumerable<string> PublishedCultures => _publishInfos?.Keys ?? Enumerable.Empty<string>();
public IEnumerable<string> PublishedCultures => _publishInfos?.Keys ?? [];

/// <inheritdoc />
public bool IsCulturePublished(string culture)
Expand Down
6 changes: 0 additions & 6 deletions src/Umbraco.Core/Models/Navigation/NavigationNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public void AddChild(ConcurrentDictionary<Guid, NavigationNode> navigationStruct
child.SortOrder = _children.Count;

_children.Add(childKey);

Comment thread
Henr1k80 marked this conversation as resolved.
// Update the navigation structure
navigationStructure[childKey] = child;
}

public void RemoveChild(ConcurrentDictionary<Guid, NavigationNode> navigationStructure, Guid childKey)
Expand All @@ -53,8 +50,5 @@ public void RemoveChild(ConcurrentDictionary<Guid, NavigationNode> navigationStr

_children.Remove(childKey);
child.Parent = null;

// Update the navigation structure
navigationStructure[childKey] = child;
}
}
5 changes: 1 addition & 4 deletions src/Umbraco.Core/Services/LocalizedTextService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,7 @@
result.TryAdd(dictionaryKey, key.Value);
}

if (!overallResult.ContainsKey(areaAlias))
{
overallResult.Add(areaAlias, result);
}
overallResult.TryAdd(areaAlias, result);

Check notice on line 364 in src/Umbraco.Core/Services/LocalizedTextService.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (contrib)

✅ No longer an issue: Complex Method

GetAreaStoredTranslations is no longer above the threshold for cyclomatic complexity
}

// Merge English Dictionary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,11 @@ private void EnsureExplicitDataTypeForBuiltInProperties(IContentTypeBase memberT
ConventionsHelper.GetStandardPropertyTypeStubs(_shortStringHelper);
foreach (IPropertyType propertyType in memberType.PropertyTypes)
{
if (builtinProperties.ContainsKey(propertyType.Alias))
// this reset's its current data type reference which will be re-assigned based on the property editor assigned on the next line
if (builtinProperties.TryGetValue(propertyType.Alias, out PropertyType? propDefinition))
{
// this reset's its current data type reference which will be re-assigned based on the property editor assigned on the next line
if (builtinProperties.TryGetValue(propertyType.Alias, out PropertyType? propDefinition))
{
propertyType.DataTypeId = propDefinition.DataTypeId;
propertyType.DataTypeKey = propDefinition.DataTypeKey;
}
else
{
propertyType.DataTypeId = 0;
propertyType.DataTypeKey = default;
}
propertyType.DataTypeId = propDefinition.DataTypeId;
propertyType.DataTypeKey = propDefinition.DataTypeKey;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NPoco;
using Umbraco.Cms.Core.DeliveryApi;
using Umbraco.Cms.Core.Media.EmbedProviders;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
Expand Down Expand Up @@ -67,7 +65,7 @@ public async Task<ISet<string>> GetPublishStatusAsync(Guid documentKey, Cancella
List<PublishStatusDto>? databaseRecords = await Database.FetchAsync<PublishStatusDto>(sql);

IDictionary<Guid, ISet<string>> result = Map(databaseRecords);
return result.ContainsKey(documentKey) ? result[documentKey] : new HashSet<string>();
return result.TryGetValue(documentKey, out ISet<string>? value) ? value : new HashSet<string>();
}

public async Task<IDictionary<Guid, ISet<string>>> GetDescendantsOrSelfPublishStatusAsync(Guid rootDocumentKey, CancellationToken cancellationToken)
Expand Down Expand Up @@ -98,7 +96,7 @@ private IDictionary<Guid, ISet<string>> Map(List<PublishStatusDto> databaseRecor
x=> (ISet<string>) x.Where(x=> IsPublished(x)).Select(y=>y.IsoCode).ToHashSet());
}

private bool IsPublished(PublishStatusDto publishStatusDto)
private static bool IsPublished(PublishStatusDto publishStatusDto)
{
switch ((ContentVariation)publishStatusDto.ContentTypeVariation)
{
Expand All @@ -112,7 +110,7 @@ private bool IsPublished(PublishStatusDto publishStatusDto)
}
}

private class PublishStatusDto
private sealed class PublishStatusDto
{

public const string DocumentVariantPublishStatusColumnName = "variantPublished";
Expand All @@ -133,5 +131,4 @@ private class PublishStatusDto
[Column(DocumentVariantPublishStatusColumnName)]
public bool DocumentVariantPublishStatus { get; set; }
}

}
9 changes: 5 additions & 4 deletions src/Umbraco.Web.Common/Helpers/OAuthOptionsHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Extensions;

Expand All @@ -14,7 +15,7 @@ public class OAuthOptionsHelper
{
// https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1
// we omit "state" and "error_uri" here as it hold no value in determining the message to display to the user
private static readonly IReadOnlyCollection<string> _oathCallbackErrorParams = new string[] { "error", "error_description" };
private static readonly string[] _oathCallbackErrorParams = ["error", "error_description"];

private readonly IOptions<SecuritySettings> _securitySettings;

Expand Down Expand Up @@ -43,7 +44,7 @@ private Task HandleResponseWithDefaultUmbracoRedirect(HandleRequestContext<Remot
SetUmbracoRedirectWithFilteredParams(context, providerFriendlyName, eventName)
.HandleResponse();

return Task.FromResult(0);
return Task.CompletedTask;
}

/// <summary>
Expand All @@ -60,9 +61,9 @@ public T SetUmbracoRedirectWithFilteredParams<T>(T context, string providerFrien

foreach (var oathCallbackErrorParam in _oathCallbackErrorParams)
{
if (context.Request.Query.ContainsKey(oathCallbackErrorParam))
if (context.Request.Query.TryGetValue(oathCallbackErrorParam, out StringValues paramValue))
{
callbackPath = callbackPath.AppendQueryStringToUrl($"{oathCallbackErrorParam}={context.Request.Query[oathCallbackErrorParam]}");
callbackPath = callbackPath.AppendQueryStringToUrl($"{oathCallbackErrorParam}={paramValue}");
}
}

Expand Down