Skip to content

Commit

Permalink
Define formatting rules (#16567)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Alhayek <mike@crestapps.com>
  • Loading branch information
sebastienros and MikeAlhayek authored Aug 15, 2024
1 parent 01725b2 commit 657342d
Show file tree
Hide file tree
Showing 111 changed files with 211 additions and 205 deletions.
63 changes: 60 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Define rule severity for each diagnostic rule ID which should be displayed or hidden in the Error List window
# dotnet_diagnostic.<rule ID>.severity = <severity>

# Severity levels: (https://learn.microsoft.com/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2019#rule-severity)
# suggestion, error, and warning show up in the editor and Error List.
# silent shows up only in the editor as a light bulb code-refactoring action.
# none shows up in neither.

root = true

[*]
Expand All @@ -22,14 +30,63 @@ csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true

dotnet_diagnostic.IDE0290.severity = none
dotnet_diagnostic.IDE0305.severity = none
dotnet_diagnostic.IDE0290.severity = none # Use primary constructor
csharp_style_prefer_primary_constructors = false

dotnet_diagnostic.IDE0305.severity = none # Use collection expression for fluent
dotnet_style_prefer_collection_expression = when_types_exactly_match

# Block bodies
dotnet_diagnostic.IDE0021.severity = none # Use block body for constructor
csharp_style_expression_bodied_constructors = false
dotnet_diagnostic.IDE0022.severity = none # Use block body for method
dotnet_diagnostic.IDE0023.severity = none # Use block body for conversion operator
csharp_style_expression_bodied_operators = when_on_single_line
dotnet_diagnostic.IDE0025.severity = silent # Use expression body for property
csharp_style_expression_bodied_properties = when_on_single_line
dotnet_diagnostic.IDE0026.severity = none # Use expression body for indexers
csharp_style_expression_bodied_indexers = when_on_single_line
dotnet_diagnostic.IDE0027.severity = none # Use block body for accessors
csharp_style_expression_bodied_accessors = when_on_single_line
dotnet_diagnostic.IDE0028.severity = silent # Collection initialization can be simplified
dotnet_diagnostic.IDE0061.severity = silent # Use body for local function

dotnet_diagnostic.IDE0032.severity = silent # Use auto property
dotnet_diagnostic.IDE0040.severity = warning # Accessibility modifiers required
dotnet_diagnostic.IDE0041.severity = silent # Null check can be simplified
dotnet_diagnostic.IDE0051.severity = warning # Make field readonly
dotnet_diagnostic.IDE0074.severity = silent # Use compound assignment
dotnet_diagnostic.IDE0090.severity = silent # New expression can be simplified
dotnet_diagnostic.IDE1006.severity = silent # Name rule violation: missing prefix

dotnet_diagnostic.IDE0011.severity = warning # If statement can be simplified
dotnet_diagnostic.IDE0045.severity = silent # If statement can be simplified
dotnet_diagnostic.IDE0046.severity = silent # If statement can be simplified
dotnet_diagnostic.IDE0047.severity = silent # Parentheses can be removed
dotnet_diagnostic.IDE0060.severity = warning # Use Remove unused parameter if not part of a shipped public API
dotnet_diagnostic.IDE0051.severity = warning # Private member is unused
dotnet_diagnostic.IDE0052.severity = warning # Private member can be removed as the value assigned to it is never read
dotnet_diagnostic.IDE0065.severity = warning # Using directives must be placed outside of a namespace declaration
csharp_using_directive_placement 4 = outside_namespace

dotnet_diagnostic.IDE0100.severity = silent # Use block body for constructor
dotnet_diagnostic.IDE0200.severity = silent # Lambda expression can be removed
dotnet_diagnostic.IDE0300.severity = silent # Collection expression can be simplified
dotnet_diagnostic.IDE0301.severity = silent # Collection initialization can be simplified
dotnet_diagnostic.IDE0302.severity = silent # Collection initialization can be simplified
dotnet_diagnostic.IDE0303.severity = silent # Collection initialization can be simplified

dotnet_diagnostic.IDE0078.severity = silent # Use pattern matching

dotnet_style_prefer_conditional_expression_over_assignment = silent # Remove redundant equality, e.g. Disabled == false

dotnet_diagnostic.CA2263.severity = warning # Prefer generic overload when type is known

# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true

# Code-block preferences
csharp_prefer_braces = true
csharp_prefer_braces = true
csharp_prefer_simple_using_statement = true
csharp_style_namespace_declarations = file_scoped:warning
# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using OrchardCore.AdminDashboard.ViewModels;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;

namespace OrchardCore.AdminDashboard.Drivers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ public class GraphQLNamedQueryRequestJsonConverter : JsonConverter<GraphQLNamedQ

/// <summary>
/// Name for the operation name parameter.
/// See https://github.com/graphql/graphql-over-http/blob/master/spec/GraphQLOverHTTP.md#request-parameters
/// See https://github.com/graphql/graphql-over-http/blob/master/spec/GraphQLOverHTTP.md#request-parameters.
/// </summary>
private const string _operationNameKey = "operationName";

/// <summary>
/// Name for the query parameter.
/// See https://github.com/graphql/graphql-over-http/blob/master/spec/GraphQLOverHTTP.md#request-parameters
/// See https://github.com/graphql/graphql-over-http/blob/master/spec/GraphQLOverHTTP.md#request-parameters.
/// </summary>
private const string _queryKey = "query";

/// <summary>
/// Name for the variables parameter.
/// See https://github.com/graphql/graphql-over-http/blob/master/spec/GraphQLOverHTTP.md#request-parameters
/// See https://github.com/graphql/graphql-over-http/blob/master/spec/GraphQLOverHTTP.md#request-parameters.
/// </summary>
private const string _variablesKey = "variables";

/// <summary>
/// Name for the extensions parameter.
/// See https://github.com/graphql/graphql-over-http/blob/master/spec/GraphQLOverHTTP.md#request-parameters
/// See https://github.com/graphql/graphql-over-http/blob/master/spec/GraphQLOverHTTP.md#request-parameters.
/// </summary>
private const string _extensionsKey = "extensions";

Expand Down Expand Up @@ -99,7 +99,9 @@ public override GraphQLNamedQueryRequest Read(ref Utf8JsonReader reader, Type ty

// Unexpected end of data.
if (!reader.Read())
{
throw new JsonException();
}

switch (key)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public async ValueTask<INodeVisitor> ValidateAsync(ValidationContext validationC
var fieldDef = validationContext.TypeInfo.GetFieldDef();

if (fieldDef == null)
{
return;
}

// check target field
await AuthorizeNodePermissionAsync(fieldAst, fieldDef, validationContext, userContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.Contents;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Modules;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Routing;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Mvc.ModelBinding;
using OrchardCore.Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using OrchardCore.ContentFields.ViewModels;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;

namespace OrchardCore.ContentFields.Drivers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.Contents;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Liquid;
using OrchardCore.Localization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Mvc.ModelBinding;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Modules;
using OrchardCore.Mvc.ModelBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Infrastructure.Html;
using OrchardCore.Liquid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Infrastructure.Html;
using OrchardCore.Mvc.ModelBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Modules;
using OrchardCore.Mvc.ModelBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Mvc.ModelBinding;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Localization;
using Microsoft.Win32.SafeHandles;
using OrchardCore.ContentFields.Fields;
using OrchardCore.ContentFields.Settings;
using OrchardCore.ContentFields.ViewModels;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Mvc.ModelBinding;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Mvc.ModelBinding;
using OrchardCore.Users.Indexes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.ContentManagement.Metadata.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Mvc.ModelBinding;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Entities;
using OrchardCore.Localization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public Task BuildTypeEditorAsync(ContentTypeDefinition model, BuildEditorContext
{
var result = await contentDisplay.BuildEditorAsync(model, context);
if (result != null)
{
await result.ApplyAsync(context);
}
}, model, context, _logger);
}

Expand All @@ -45,7 +47,9 @@ public Task UpdateTypeEditorAsync(ContentTypeDefinition model, UpdateTypeEditorC
{
var result = await contentDisplay.UpdateEditorAsync(model, context);
if (result != null)
{
await result.ApplyAsync(context);
}
}, model, context, _logger);
}

Expand All @@ -55,7 +59,9 @@ public Task BuildTypePartEditorAsync(ContentTypePartDefinition model, BuildEdito
{
var result = await contentDisplay.BuildEditorAsync(model, context);
if (result != null)
{
await result.ApplyAsync(context);
}
}, model, context, _logger);
}

Expand All @@ -65,7 +71,9 @@ public Task UpdateTypePartEditorAsync(ContentTypePartDefinition model, UpdateTyp
{
var result = await contentDisplay.UpdateEditorAsync(model, context);
if (result != null)
{
await result.ApplyAsync(context);
}
}, model, context, _logger);
}

Expand All @@ -75,7 +83,9 @@ public Task BuildPartEditorAsync(ContentPartDefinition model, BuildEditorContext
{
var result = await contentDisplay.BuildEditorAsync(model, context);
if (result != null)
{
await result.ApplyAsync(context);
}
}, model, context, _logger);
}

Expand All @@ -85,7 +95,9 @@ public Task UpdatePartEditorAsync(ContentPartDefinition model, UpdatePartEditorC
{
var result = await contentDisplay.UpdateEditorAsync(model, context);
if (result != null)
{
await result.ApplyAsync(context);
}
}, model, context, _logger);
}

Expand All @@ -95,7 +107,9 @@ await _partFieldDisplayDrivers.InvokeAsync(async (contentDisplay, model, context
{
var result = await contentDisplay.BuildEditorAsync(model, context);
if (result != null)
{
await result.ApplyAsync(context);
}
}, model, context, _logger);
}

Expand All @@ -105,7 +119,9 @@ await _partFieldDisplayDrivers.InvokeAsync(async (contentDisplay, model, context
{
var result = await contentDisplay.UpdateEditorAsync(model, context);
if (result != null)
{
await result.ApplyAsync(context);
}
}, model, context, _logger);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using OrchardCore.Contents.AuditTrail.Models;
using OrchardCore.Contents.AuditTrail.Settings;
using OrchardCore.Contents.AuditTrail.ViewModels;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;

namespace OrchardCore.Contents.AuditTrail.Drivers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public async Task<IActionResult> Display(string contentItemId)
}

[Admin("Contents/ContentItems/{contentItemId}/Edit", "EditContentItem")]
public async Task<IActionResult> Edit(string contentItemId, string returnUrl = null)
public async Task<IActionResult> Edit(string contentItemId)
{
var contentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.Latest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.Contents.Models;
using OrchardCore.Contents.ViewModels;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Modules;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.Demo.Models;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;

namespace OrchardCore.Demo.ContentElementDisplays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display;
using OrchardCore.ContentManagement.Records;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.Modules;
using YesSql;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using OrchardCore.Email.Services;
using OrchardCore.Entities;
using OrchardCore.Environment.Shell;
using OrchardCore.Modules;
using OrchardCore.Mvc.ModelBinding;
using OrchardCore.Settings;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Threading.Tasks;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentManagement.Display.Models;
using OrchardCore.DisplayManagement.ModelBinding;
using OrchardCore.DisplayManagement.Views;
using OrchardCore.Forms.Models;
using OrchardCore.Forms.ViewModels;
Expand Down
Loading

0 comments on commit 657342d

Please sign in to comment.