Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-867: Addressing analyzer warnings #64

Merged
merged 2 commits into from
Jun 11, 2024
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
4 changes: 4 additions & 0 deletions Lombiq.JsonEditor/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public AdminController(
[AdminRoute("Contents/ContentItems/{contentItemId}/Edit/Json")]
public async Task<IActionResult> Edit(string contentItemId)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

if (string.IsNullOrWhiteSpace(contentItemId) ||
await _contentManager.GetAsync(contentItemId, VersionOptions.Latest) is not { } contentItem ||
!await CanEditAsync(contentItem))
Expand Down Expand Up @@ -90,6 +92,8 @@ public async Task<IActionResult> EditPost(
[Bind(Prefix = "submit.Publish")] string submitPublish,
[Bind(Prefix = "submit.Save")] string submitSave)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

if (string.IsNullOrWhiteSpace(contentItemId) ||
string.IsNullOrWhiteSpace(json) ||
JsonConvert.DeserializeObject<ContentItem>(json) is not { } contentItem)
Expand Down
8 changes: 4 additions & 4 deletions Lombiq.JsonEditor/Models/JsonEditorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public JsonEditorMode Mode
set => ModeString = GetModeString(value);
}

public IEnumerable<string> Modes { get; set; } = new[] { "tree", "view", "form", "code", "text", "preview" };
public IEnumerable<string> Modes { get; set; } = ["tree", "view", "form", "code", "text", "preview"];

/// <summary>
/// Gets or sets the JSON Schema to validate against. A JSON schema describes the structure that a JSON object must
Expand Down Expand Up @@ -116,8 +116,8 @@ private static string GetModeString(JsonEditorMode mode) =>
public static JsonEditorOptions GetSample(IHtmlLocalizer localizer) =>
new()
{
Templates = new[]
{
Templates =
[
new JsonEditorTemplate
{
Field = "aTechnicalNameThatHasToBeUnique",
Expand All @@ -127,6 +127,6 @@ public static JsonEditorOptions GetSample(IHtmlLocalizer localizer) =>
.Value,
Value = new { YourObject = "goes here" },
},
},
],
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lombiq.HelpfulLibraries.AspNetCore.Security;
using Lombiq.HelpfulLibraries.AspNetCore.Security;
using Lombiq.JsonEditor.Constants;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -18,7 +18,7 @@ public class JsonEditorContentSecurityPolicyProvider : ResourceManagerContentSec
{
protected override string ResourceType => "script";
protected override string ResourceName => ResourceNames.Library;
protected override IReadOnlyCollection<string> DirectiveNameChain { get; } = new[] { WorkerSrc, ScriptSrc };
protected override IReadOnlyCollection<string> DirectiveNameChain { get; } = [WorkerSrc, ScriptSrc];
protected override string DirectiveValue => $"{Blob} {Data}";

protected override ValueTask ThenUpdateAsync(
Expand Down