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: 6 additions & 2 deletions src/Umbraco.Infrastructure/Examine/ContentValueSetBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,51 +102,55 @@
{
var isVariant = c.ContentType.VariesByCulture();

var urlValue = _documentUrlService.GetUrlSegment(c.Key, defaultCulture, false); // Always add invariant urlName
var urlValue = _documentUrlService.IsInitialized
? _documentUrlService.GetUrlSegment(c.Key, defaultCulture, false)
: c.GetUrlSegment(_shortStringHelper, _urlSegmentProviders, defaultCulture); // Fallback when DocumentUrlService is not yet initialized (e.g. during upgrade)
var values = new Dictionary<string, IEnumerable<object?>>
{
{ "icon", c.ContentType.Icon?.Yield() ?? Enumerable.Empty<string>() },
{
UmbracoExamineFieldNames.PublishedFieldName, c.Published ? YesValue : NoValue
}, // Always add invariant published value
{ "id", new object[] { c.Id } },
{ UmbracoExamineFieldNames.NodeKeyFieldName, new object[] { c.Key } },
{ "parentID", new object[] { c.Level > 1 ? c.ParentId : -1 } },
{ "level", new object[] { c.Level } },
{ "creatorID", new object[] { c.CreatorId } },
{ "sortOrder", new object[] { c.SortOrder } },
{ "createDate", new object[] { c.CreateDate } }, // Always add invariant createDate
{ "updateDate", new object[] { c.UpdateDate } }, // Always add invariant updateDate
{
UmbracoExamineFieldNames.NodeNameFieldName, (PublishedValuesOnly // Always add invariant nodeName
? c.PublishName?.Yield()
: c.Name?.Yield()) ?? Enumerable.Empty<string>()
},
{ "urlName", urlValue?.Yield() ?? Enumerable.Empty<string>() }, // Always add invariant urlName
{ "path", c.Path.Yield() },
{ "nodeType", c.ContentType.Id.ToString().Yield() },
{
"creatorName",
(creatorIds.TryGetValue(c.CreatorId, out IProfile? creatorProfile) ? creatorProfile.Name! : "??")
.Yield()
},
{
"writerName",
(writerIds.TryGetValue(c.WriterId, out IProfile? writerProfile) ? writerProfile.Name! : "??")
.Yield()
},
{ "writerID", new object[] { c.WriterId } },
{ "templateID", new object[] { c.TemplateId ?? 0 } },
{ UmbracoExamineFieldNames.VariesByCultureFieldName, NoValue },
};

if (isVariant)
{
values[UmbracoExamineFieldNames.VariesByCultureFieldName] = YesValue;

foreach (var culture in c.AvailableCultures)
{
var variantUrl = c.GetUrlSegment(_shortStringHelper, _urlSegmentProviders, culture);
var variantUrl = _documentUrlService.IsInitialized
? _documentUrlService.GetUrlSegment(c.Key, culture, false)
: c.GetUrlSegment(_shortStringHelper, _urlSegmentProviders, culture);

Check warning on line 153 in src/Umbraco.Infrastructure/Examine/ContentValueSetBuilder.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (main)

❌ Getting worse: Complex Method

GetValueSetsEnumerable increases in cyclomatic complexity from 25 to 27, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
var lowerCulture = culture.ToLowerInvariant();
values[$"urlName_{lowerCulture}"] = variantUrl?.Yield() ?? Enumerable.Empty<string>();
values[$"nodeName_{lowerCulture}"] = (PublishedValuesOnly
Expand Down
Loading
Loading