Skip to content

Commit

Permalink
Correct zero length check expressions (#16463)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Jul 22, 2024
1 parent debf7d6 commit 602fa16
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private async Task<IEnumerable<ContentTypeDefinition>> GetContainedContentTypesA
{
var settings = (await _contentDefinitionManager.GetTypeDefinitionAsync(contentType))?.Parts.SingleOrDefault(x => x.Name == partName)?.GetSettings<FlowPartSettings>();

if (settings?.ContainedContentTypes?.Length == 0)
if (settings?.ContainedContentTypes == null || settings.ContainedContentTypes.Length == 0)
{
return (await _contentDefinitionManager.ListTypeDefinitionsAsync()).Where(t => t.StereotypeEquals("Widget"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private async Task<IEnumerable<ContentTypeDefinition>> GetContainedContentTypesA
{
var settings = typePartDefinition.GetSettings<FlowPartSettings>();

if (settings?.ContainedContentTypes?.Length == 0)
if (settings?.ContainedContentTypes == null || settings.ContainedContentTypes.Length == 0)
{
return (await _contentDefinitionManager.ListTypeDefinitionsAsync())
.Where(t => t.StereotypeEquals("Widget"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefiniti
model.Multiple = settings.Multiple;
model.AllowMediaText = settings.AllowMediaText;
model.AllowAnchors = settings.AllowAnchors;
model.AllowAllDefaultMediaTypes = settings.AllowedExtensions?.Length == 0;
model.AllowAllDefaultMediaTypes = settings.AllowedExtensions == null || settings.AllowedExtensions.Length == 0;

var items = new List<MediaTypeViewModel>();
foreach (var extension in _mediaOptions.AllowedFileExtensions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
return;
}

@if (Model.SearchIndexes == null || Model.SearchIndexes?.Count == 0)
@if (Model.SearchIndexes == null || Model.SearchIndexes.Count == 0)
{
<div class="alert alert-warning" role="alert">
@T["No indices exist! Please create at least one index to configure Azure AI Search service."]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public async Task<IEnumerable<ContentItem>> GetAsync(IEnumerable<string> content
.Distinct()
.ToArray();

if (ids?.Length == 0)
if (ids == null || ids.Length == 0)
{
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public async Task UpdateAsync(Query query, JsonNode data = null)

public async Task SaveAsync(params Query[] queries)
{
if (queries?.Length == 0)
if (queries == null || queries.Length == 0)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class AzureAISearchIndexSettingsStep : IRecipeStepHandler
private readonly AzureAIIndexDocumentManager _azureAIIndexDocumentManager;
private readonly AzureAISearchIndexSettingsService _azureAISearchIndexSettingsService;

internal readonly IStringLocalizer S;
internal IStringLocalizer S;

public AzureAISearchIndexSettingsStep(
AzureAISearchIndexManager indexManager,
Expand Down Expand Up @@ -68,7 +68,7 @@ public async Task ExecuteAsync(RecipeExecutionContext context)
continue;
}

if (indexInfo.IndexedContentTypes?.Length == 0)
if (indexInfo.IndexedContentTypes == null || indexInfo.IndexedContentTypes.Length == 0)
{
context.Errors.Add(S["No {0} were provided in the recipe step. IndexName: {1}.", nameof(indexInfo.IndexedContentTypes), indexInfo.IndexName]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private bool HasConnectionInfo(ElasticConnectionOptions elasticConnectionOptions
optionsAreValid = false;
}

if (elasticConnectionOptions.Ports?.Length == 0)
if (elasticConnectionOptions.Ports == null || elasticConnectionOptions.Ports.Length == 0)
{
_logger.LogError("Elasticsearch is enabled but not active because a port is missing in application configuration.");
optionsAreValid = false;
Expand Down

0 comments on commit 602fa16

Please sign in to comment.