Skip to content

Commit 2a09374

Browse files
authored
chore: Remove Sonar findings (#1450)
1 parent a668d34 commit 2a09374

44 files changed

Lines changed: 233 additions & 47 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/Parameters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static BuildParameters Instance(ICakeContext context)
5252
IsReleaseBuild = !buildInformation.IsLocalBuild && buildInformation.IsReleaseBuild,
5353
IsPullRequest = buildInformation.IsPullRequest,
5454
ShouldPublish = !buildInformation.IsLocalBuild && buildInformation.ShouldPublish,
55-
Verbosity = DotNetVerbosity.Quiet,
55+
Verbosity = DotNetVerbosity.Minimal,
5656
CodeSigningCertificateCredentials = BuildCredentials.GetCodeSigningCertificateCredentials(context),
5757
SonarQubeCredentials = SonarQubeCredentials.GetSonarQubeCredentials(context),
5858
NuGetCredentials = NuGetCredentials.GetNuGetCredentials(context),

src/Testcontainers/Containers/ExecFailedException.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DotNet.Testcontainers.Containers
1+
namespace DotNet.Testcontainers.Containers
22
{
33
using System;
44
using System.Linq;
@@ -17,15 +17,15 @@ public sealed class ExecFailedException : Exception
1717
/// <summary>
1818
/// Initializes a new instance of the <see cref="ExecFailedException" /> class.
1919
/// </summary>
20-
/// <param name="execResult">The result of the failed command execution.</param>
20+
/// <param name="execResult">The result of the failed command.</param>
2121
public ExecFailedException(ExecResult execResult)
2222
: base(CreateMessage(execResult))
2323
{
2424
ExecResult = execResult;
2525
}
2626

2727
/// <summary>
28-
/// Gets the result of the failed command execution inside the container.
28+
/// Gets the result of the failed command.
2929
/// </summary>
3030
public ExecResult ExecResult { get; }
3131

src/Testcontainers/Containers/ExecResultExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DotNet.Testcontainers.Containers
1+
namespace DotNet.Testcontainers.Containers
22
{
33
using System;
44
using System.Threading.Tasks;

tests/Testcontainers.ActiveMq.Tests/ArtemisContainerTest.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ await _artemisContainer.StartAsync()
2222
.ConfigureAwait(false);
2323
}
2424

25-
public ValueTask DisposeAsync()
25+
public async ValueTask DisposeAsync()
2626
{
27-
return _artemisContainer.DisposeAsync();
27+
await DisposeAsyncCore()
28+
.ConfigureAwait(false);
29+
30+
GC.SuppressFinalize(this);
2831
}
2932
// # --8<-- [end:UseArtemisContainer]
3033

@@ -73,6 +76,11 @@ await producer.SendAsync(producedMessage)
7376
}
7477
// # --8<-- [end:ArtemisContainerEstablishesConnection]
7578

79+
protected virtual ValueTask DisposeAsyncCore()
80+
{
81+
return _artemisContainer.DisposeAsync();
82+
}
83+
7684
// # --8<-- [start:UseArtemisContainerDefaultAuth]
7785
[UsedImplicitly]
7886
public sealed class DefaultCredentialsConfiguration : ArtemisContainerTest

tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ await _azuriteContainer.StartAsync()
1515
.ConfigureAwait(false);
1616
}
1717

18-
public ValueTask DisposeAsync()
18+
public async ValueTask DisposeAsync()
1919
{
20-
return _azuriteContainer.DisposeAsync();
20+
await DisposeAsyncCore()
21+
.ConfigureAwait(false);
22+
23+
GC.SuppressFinalize(this);
2124
}
2225

2326
[Fact]
@@ -65,6 +68,11 @@ public async Task EstablishesTableServiceConnection()
6568
Assert.False(HasError(properties));
6669
}
6770

71+
protected virtual ValueTask DisposeAsyncCore()
72+
{
73+
return _azuriteContainer.DisposeAsync();
74+
}
75+
6876
private static bool HasError<TResponseEntity>(NullableResponse<TResponseEntity> response)
6977
{
7078
using (var rawResponse = response.GetRawResponse())
@@ -104,6 +112,7 @@ public AzuriteMemoryLimitConfiguration()
104112
}
105113

106114
[Fact]
115+
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
107116
public async Task MemoryLimitIsConfigured()
108117
{
109118
// Given

tests/Testcontainers.Commons/DockerCli.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public enum DockerResource
4444
public static bool PlatformIsEnabled(DockerPlatform platform)
4545
{
4646
var commandResult = new Command("version", "--format {{.Server.Os}}").Execute();
47-
return 0.Equals(commandResult.ExitCode) && commandResult.Stdout.Contains(platform.ToString().ToLowerInvariant());
47+
return 0.Equals(commandResult.ExitCode) && commandResult.Stdout.Contains(platform.ToString(), StringComparison.OrdinalIgnoreCase);
4848
}
4949

5050
public static bool ResourceExists(DockerResource resource, string id)

tests/Testcontainers.Db2.Tests/DeclineLicenseAgreementTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ public sealed partial class DeclineLicenseAgreementTest
66
private static partial Regex LicenseAgreementNotAccepted();
77

88
[Fact]
9+
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
910
public void WithoutAcceptingLicenseAgreementThrowsArgumentException()
1011
{
1112
var exception = Assert.Throws<ArgumentException>(() => new Db2Builder().Build());
1213
Assert.Matches(LicenseAgreementNotAccepted(), exception.Message);
1314
}
1415

1516
[Fact]
17+
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
1618
public void WithLicenseAgreementDeclinedThrowsArgumentException()
1719
{
1820
var exception = Assert.Throws<ArgumentException>(() => new Db2Builder().WithAcceptLicenseAgreement(false).Build());

tests/Testcontainers.EventHubs.Tests/EventHubsContainerTest.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ await _eventHubsContainer.StartAsync()
2020
.ConfigureAwait(false);
2121
}
2222

23-
public ValueTask DisposeAsync()
23+
public async ValueTask DisposeAsync()
2424
{
25-
return _eventHubsContainer.DisposeAsync();
25+
await DisposeAsyncCore()
26+
.ConfigureAwait(false);
27+
28+
GC.SuppressFinalize(this);
2629
}
2730

2831
private static EventHubsServiceConfiguration GetServiceConfiguration()
@@ -63,6 +66,11 @@ await producer.SendAsync(eventDataBatch, TestContext.Current.CancellationToken)
6366
}
6467
// # --8<-- [end:UseEventHubsContainer]
6568

69+
protected virtual ValueTask DisposeAsyncCore()
70+
{
71+
return _eventHubsContainer.DisposeAsync();
72+
}
73+
6674
// # --8<-- [start:CreateEventHubsContainer]
6775
[UsedImplicitly]
6876
public sealed class EventHubsDefaultAzuriteConfiguration : EventHubsContainerTest

tests/Testcontainers.Kafka.Tests/KafkaContainerNetworkTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ await _network.DisposeAsync()
5555
}
5656

5757
[Fact]
58+
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
5859
public async Task ConsumesProducedKafkaMessage()
5960
{
6061
_ = await _kCatContainer.ExecAsync(new[] { "kafkacat", "-b", Listener, "-t", "msgs", "-P", "-l", DataFilePath }, TestContext.Current.CancellationToken)

tests/Testcontainers.Kafka.Tests/KafkaContainerRegistryTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ await _network.DisposeAsync()
7777
}
7878

7979
[Fact]
80+
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
8081
public async Task ConsumerReturnsProducerMessage()
8182
{
8283
// Given

0 commit comments

Comments
 (0)