From 26e4ad38c36eb8e01e3da205c53b4b4aede84070 Mon Sep 17 00:00:00 2001 From: Mathias Ormstrup Bjerregaard <152613120+MWO1024@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:43:36 +0100 Subject: [PATCH] chore: Update ReSharper inspections for Rider/ReSharper 2024.3 (#1364) --- .editorconfig | 12 ++++++++++++ .../Fixture/ArchivedMessagesFixture.cs | 2 ++ .../ExecuteDataRetentionsWhenADayHasPassed.cs | 2 ++ .../Fixtures/IncomingMessagesTestFixture.cs | 2 ++ .../IncomingMessages/GivenIncomingMessagesTests.cs | 4 ++++ .../Behaviours/BehavioursTestBase.cs | 2 ++ .../MigrationsFreeDatabricksSchemaManager.cs | 2 ++ .../Fixtures/IntegrationTestFixture.cs | 2 ++ source/IntegrationTests/TestBase.cs | 2 ++ .../RemoveOldGridAreaOwnersWhenADayHasPassedTests.cs | 2 ++ .../Fixtures/OutgoingMessagesTestFixture.cs | 2 ++ .../OutgoingMessages/WhenAPeekIsRequestedTests.cs | 4 ++++ .../OutgoingMessagesTestBase.cs | 2 ++ .../InitializeWholesaleServicesProcessesHandler.cs | 2 ++ .../Mappers/CalculatedQuantityQualityMapperTests.cs | 3 +++ .../OutgoingMessages/Asserts/AssertEbixDocument.cs | 2 ++ 16 files changed, 47 insertions(+) diff --git a/.editorconfig b/.editorconfig index 4577b009b9..c5d97d69a9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -549,6 +549,18 @@ resharper_csharp_wrap_parameters_style = chop_if_long resharper_trailing_comma_in_multiline_lists = true resharper_wrap_chained_method_calls = chop_if_long resharper_csharp_wrap_before_binary_opsign = true +# Replicating "csharp_prefer_braces = when_multiline:error" from .NET Code Style +# If we do not explicitly set this, ReSharper/Rider will complain about inconsistent braces and de facto enforce brace everywhere +resharper_braces_for_ifelse = not_required_for_both +resharper_braces_for_dowhile = required_for_multiline_statement +resharper_braces_for_fixed = required_for_multiline_statement +resharper_braces_for_for = required_for_multiline_statement +resharper_braces_for_foreach = required_for_multiline_statement +resharper_braces_for_lock = required_for_multiline_statement +resharper_braces_for_using = required_for_multiline_statement +resharper_braces_for_while = required_for_multiline_statement +# We are removing the inherited "error" setting for "redundant braces" +resharper_braces_redundant = false ############################################################## # Overrides default configuration # diff --git a/source/ArchivedMessages.IntegrationTests/Fixture/ArchivedMessagesFixture.cs b/source/ArchivedMessages.IntegrationTests/Fixture/ArchivedMessagesFixture.cs index b8bae68ace..350672fc8d 100644 --- a/source/ArchivedMessages.IntegrationTests/Fixture/ArchivedMessagesFixture.cs +++ b/source/ArchivedMessages.IntegrationTests/Fixture/ArchivedMessagesFixture.cs @@ -60,7 +60,9 @@ public void CleanupFileStorage(bool disposing = false) var containers = blobServiceClient.GetBlobContainers(); foreach (var containerToDelete in containers) + { blobServiceClient.DeleteBlobContainer(containerToDelete.Name); + } if (disposing) { diff --git a/source/B2BApi/DataRetention/ExecuteDataRetentionsWhenADayHasPassed.cs b/source/B2BApi/DataRetention/ExecuteDataRetentionsWhenADayHasPassed.cs index d48454e9a3..a5449aab2a 100644 --- a/source/B2BApi/DataRetention/ExecuteDataRetentionsWhenADayHasPassed.cs +++ b/source/B2BApi/DataRetention/ExecuteDataRetentionsWhenADayHasPassed.cs @@ -82,7 +82,9 @@ public async Task Handle(ADayHasPassed notification, CancellationToken cancellat finally { foreach (var scope in serviceScopes) + { scope.Dispose(); + } } } diff --git a/source/IncomingMessages.IntegrationTests/Fixtures/IncomingMessagesTestFixture.cs b/source/IncomingMessages.IntegrationTests/Fixtures/IncomingMessagesTestFixture.cs index e1a9ec478f..397123015b 100644 --- a/source/IncomingMessages.IntegrationTests/Fixtures/IncomingMessagesTestFixture.cs +++ b/source/IncomingMessages.IntegrationTests/Fixtures/IncomingMessagesTestFixture.cs @@ -66,7 +66,9 @@ public void CleanupFileStorage(bool disposing = false) var containers = blobServiceClient.GetBlobContainers(); foreach (var containerToDelete in containers) + { blobServiceClient.DeleteBlobContainer(containerToDelete.Name); + } if (disposing) { diff --git a/source/IncomingMessages.IntegrationTests/IncomingMessages/GivenIncomingMessagesTests.cs b/source/IncomingMessages.IntegrationTests/IncomingMessages/GivenIncomingMessagesTests.cs index 7407984409..6922f98c6a 100644 --- a/source/IncomingMessages.IntegrationTests/IncomingMessages/GivenIncomingMessagesTests.cs +++ b/source/IncomingMessages.IntegrationTests/IncomingMessages/GivenIncomingMessagesTests.cs @@ -486,13 +486,17 @@ await _incomingMessagesRequest.ReceiveIncomingMarketMessageAsync( var archivedMessageAsDictionary = (IDictionary)archivedMessage; foreach (var assertProperty in assertProperties) + { assertProperty.Value(archivedMessageAsDictionary[assertProperty.Key]); + } assertProperties.Should() .HaveSameCount(archivedMessageAsDictionary, "because all archived message properties should be asserted"); foreach (var dbPropertyName in archivedMessageAsDictionary.Keys) + { assertProperties.Keys.Should().Contain(dbPropertyName); + } } protected override void Dispose(bool disposing) diff --git a/source/IntegrationTests/Behaviours/BehavioursTestBase.cs b/source/IntegrationTests/Behaviours/BehavioursTestBase.cs index 50f5ee75a2..1866fb2e99 100644 --- a/source/IntegrationTests/Behaviours/BehavioursTestBase.cs +++ b/source/IntegrationTests/Behaviours/BehavioursTestBase.cs @@ -195,7 +195,9 @@ protected void ClearDbContextCaches() .Select(s => (DbContext)_serviceProvider.GetService(s.ServiceType)!); foreach (var dbContext in dbContextServices) + { dbContext.ChangeTracker.Clear(); + } } protected virtual void Dispose(bool disposing) diff --git a/source/IntegrationTests/CalculationResults/Fixtures/MigrationsFreeDatabricksSchemaManager.cs b/source/IntegrationTests/CalculationResults/Fixtures/MigrationsFreeDatabricksSchemaManager.cs index 1ef655375f..6b80b306be 100644 --- a/source/IntegrationTests/CalculationResults/Fixtures/MigrationsFreeDatabricksSchemaManager.cs +++ b/source/IntegrationTests/CalculationResults/Fixtures/MigrationsFreeDatabricksSchemaManager.cs @@ -122,7 +122,9 @@ public async Task InsertFromCsvFileAsync( { var row = new string[csvReader.HeaderRecord!.Length]; for (var columnIndex = 0; columnIndex < csvReader.ColumnCount; columnIndex++) + { row[columnIndex] = ParseColumnValue(schemaInformation, csvReader, columnIndex); + } rows.Add(row); } diff --git a/source/IntegrationTests/Fixtures/IntegrationTestFixture.cs b/source/IntegrationTests/Fixtures/IntegrationTestFixture.cs index e04bfcb2c6..daec59844a 100644 --- a/source/IntegrationTests/Fixtures/IntegrationTestFixture.cs +++ b/source/IntegrationTests/Fixtures/IntegrationTestFixture.cs @@ -67,7 +67,9 @@ public void CleanupFileStorage(bool disposing = false) var containers = blobServiceClient.GetBlobContainers(); foreach (var containerToDelete in containers) + { blobServiceClient.DeleteBlobContainer(containerToDelete.Name); + } if (disposing) { diff --git a/source/IntegrationTests/TestBase.cs b/source/IntegrationTests/TestBase.cs index c45105c551..734801d334 100644 --- a/source/IntegrationTests/TestBase.cs +++ b/source/IntegrationTests/TestBase.cs @@ -223,7 +223,9 @@ protected void ClearDbContextCaches() .Select(s => (DbContext)ServiceProvider.GetService(s.ServiceType)!); foreach (var dbContext in dbContextServices) + { dbContext.ChangeTracker.Clear(); + } } protected virtual void Dispose(bool disposing) diff --git a/source/MasterData.IntegrationTests/Tests/RemoveOldGridAreaOwnersWhenADayHasPassedTests.cs b/source/MasterData.IntegrationTests/Tests/RemoveOldGridAreaOwnersWhenADayHasPassedTests.cs index 4027dbbc31..e4ccfb4629 100644 --- a/source/MasterData.IntegrationTests/Tests/RemoveOldGridAreaOwnersWhenADayHasPassedTests.cs +++ b/source/MasterData.IntegrationTests/Tests/RemoveOldGridAreaOwnersWhenADayHasPassedTests.cs @@ -182,7 +182,9 @@ public async Task Given_RetentionCleanUp_When_GridAreaOwnerIsRemoved_Then_AuditL private async Task AddActorsToDatabaseAsync(List gridAreaOwners) { foreach (var gao in gridAreaOwners) + { await _masterDataClient!.UpdateGridAreaOwnershipAsync(gao, CancellationToken.None); + } } private async Task GetGridAreaOwnersForGridArea(string gridAreaCode) diff --git a/source/OutgoingMessages.IntegrationTests/Fixtures/OutgoingMessagesTestFixture.cs b/source/OutgoingMessages.IntegrationTests/Fixtures/OutgoingMessagesTestFixture.cs index 8762bb6aa6..1b32cf731f 100644 --- a/source/OutgoingMessages.IntegrationTests/Fixtures/OutgoingMessagesTestFixture.cs +++ b/source/OutgoingMessages.IntegrationTests/Fixtures/OutgoingMessagesTestFixture.cs @@ -66,7 +66,9 @@ public void CleanupFileStorage(bool disposing = false) var containers = blobServiceClient.GetBlobContainers(); foreach (var containerToDelete in containers) + { blobServiceClient.DeleteBlobContainer(containerToDelete.Name); + } if (disposing) { diff --git a/source/OutgoingMessages.IntegrationTests/OutgoingMessages/WhenAPeekIsRequestedTests.cs b/source/OutgoingMessages.IntegrationTests/OutgoingMessages/WhenAPeekIsRequestedTests.cs index 6a3c1c58f8..f171215c3a 100644 --- a/source/OutgoingMessages.IntegrationTests/OutgoingMessages/WhenAPeekIsRequestedTests.cs +++ b/source/OutgoingMessages.IntegrationTests/OutgoingMessages/WhenAPeekIsRequestedTests.cs @@ -322,12 +322,16 @@ public async Task Given_OutgoingMessage_When_MessageIsPeeked_Then_MessageIsArchi var archivedMessageAsDictionary = (IDictionary)archivedMessage; foreach (var assertProperty in assertProperties) + { assertProperty.Value(archivedMessageAsDictionary[assertProperty.Key]); + } assertProperties.Should().HaveSameCount(archivedMessageAsDictionary, "because all archived message properties should be asserted"); foreach (var dbPropertyName in archivedMessageAsDictionary.Keys) + { assertProperties.Keys.Should().Contain(dbPropertyName); + } } private async Task BundleIsRegistered() diff --git a/source/OutgoingMessages.IntegrationTests/OutgoingMessagesTestBase.cs b/source/OutgoingMessages.IntegrationTests/OutgoingMessagesTestBase.cs index 771e5da155..73eedbbde6 100644 --- a/source/OutgoingMessages.IntegrationTests/OutgoingMessagesTestBase.cs +++ b/source/OutgoingMessages.IntegrationTests/OutgoingMessagesTestBase.cs @@ -167,7 +167,9 @@ protected void ClearDbContextCaches() .Select(s => (DbContext)ServiceProvider.GetService(s.ServiceType)!); foreach (var dbContext in dbContextServices) + { dbContext.ChangeTracker.Clear(); + } } protected virtual void Dispose(bool disposing) diff --git a/source/Process.Application/Transactions/WholesaleServices/InitializeWholesaleServicesProcessesHandler.cs b/source/Process.Application/Transactions/WholesaleServices/InitializeWholesaleServicesProcessesHandler.cs index 4a2ca6bd1c..cdbff38b96 100644 --- a/source/Process.Application/Transactions/WholesaleServices/InitializeWholesaleServicesProcessesHandler.cs +++ b/source/Process.Application/Transactions/WholesaleServices/InitializeWholesaleServicesProcessesHandler.cs @@ -80,7 +80,9 @@ public Task Handle(InitializeWholesaleServicesProcessesCommand request, Ca var processes = CreateWholesaleServicesProcesses(request.InitializeWholesaleServicesProcessDto); foreach (var wholesaleServicesProcess in processes) + { _wholesaleServicesProcessRepository.Add(wholesaleServicesProcess); + } return Task.FromResult(Unit.Value); } diff --git a/source/Tests/Domain/Transactions/Mappers/CalculatedQuantityQualityMapperTests.cs b/source/Tests/Domain/Transactions/Mappers/CalculatedQuantityQualityMapperTests.cs index 7b275a007b..132ce07254 100644 --- a/source/Tests/Domain/Transactions/Mappers/CalculatedQuantityQualityMapperTests.cs +++ b/source/Tests/Domain/Transactions/Mappers/CalculatedQuantityQualityMapperTests.cs @@ -48,7 +48,10 @@ private static T[][] FastPowerSet(IReadOnlyList seq) var source = powerSet[j]; var destination = powerSet[count + j] = new T[source.Length + 1]; for (var q = 0; q < source.Length; q++) + { destination[q] = source[q]; + } + destination[source.Length] = cur; } } diff --git a/source/Tests/Infrastructure/OutgoingMessages/Asserts/AssertEbixDocument.cs b/source/Tests/Infrastructure/OutgoingMessages/Asserts/AssertEbixDocument.cs index 221433cfce..dbcb290590 100644 --- a/source/Tests/Infrastructure/OutgoingMessages/Asserts/AssertEbixDocument.cs +++ b/source/Tests/Infrastructure/OutgoingMessages/Asserts/AssertEbixDocument.cs @@ -89,7 +89,9 @@ public AssertEbixDocument HasValueWithAttributes(string xpath, string expectedVa Assert.Equal(expectedValue, _document.Root?.XPathSelectElement(EnsureXPathHasPrefix(xpath), _xmlNamespaceManager)?.Value); foreach (var (name, value) in attributes) + { Assert.Equal(value, _document.Root?.XPathSelectElement(EnsureXPathHasPrefix(xpath), _xmlNamespaceManager)?.Attribute(name)?.Value); + } return this; }