Skip to content

Commit 203b8a8

Browse files
committed
gh-65 address SonarQube issues
Signed-off-by: Victor Chang <[email protected]>
1 parent 0c9b358 commit 203b8a8

File tree

10 files changed

+27
-29
lines changed

10 files changed

+27
-29
lines changed

src/Api/Storage/Payload.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Diagnostics;
7-
using System.Linq;
87
using Ardalis.GuardClauses;
98
using Monai.Deploy.InformaticsGateway.Common;
109
namespace Monai.Deploy.InformaticsGateway.Api.Storage

src/DicomWebClient/API/MimeMappings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static class MimeMappings
2929
{
3030
public const string MultiPartRelated = "multipart/related";
3131

32-
public static readonly Dictionary<MimeType, string> MimeTypeMappings = new()
32+
public static readonly IReadOnlyDictionary<MimeType, string> MimeTypeMappings = new Dictionary<MimeType, string>()
3333
{
3434
{ MimeType.Dicom, "application/dicom" },
3535
{ MimeType.DicomJson, "application/dicom+json" },
@@ -46,7 +46,7 @@ public static class MimeMappings
4646
{ MimeType.VideoMpeg2, "video/mpeg2" },
4747
};
4848

49-
public static readonly Dictionary<DicomUID, MimeType> SupportedMediaTypes = new()
49+
public static readonly IReadOnlyDictionary<DicomUID, MimeType> SupportedMediaTypes = new Dictionary<DicomUID, MimeType>()
5050
{
5151
{ DicomUID.ExplicitVRLittleEndian, MimeType.Dicom },
5252
{ DicomUID.RLELossless, MimeType.Dicom },

src/DicomWebClient/Monai.Deploy.InformaticsGateway.DicomWeb.Client.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SPDX-License-Identifier: Apache License 2.0
3535
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
3636
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
3737
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
38+
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
3839
</ItemGroup>
3940

4041
<ItemGroup>

src/DicomWebClient/Services/WadoService.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.Collections.Generic;
7+
using System.Linq;
78
using System.Net.Http;
89
using System.Threading.Tasks;
910
using Ardalis.GuardClauses;
@@ -100,10 +101,7 @@ public async Task<DicomFile> Retrieve(
100101

101102
try
102103
{
103-
await foreach (var item in response.ToDicomAsyncEnumerable())
104-
{
105-
return item;
106-
}
104+
await response.ToDicomAsyncEnumerable().FirstOrDefaultAsync();
107105
}
108106
catch (Exception ex)
109107
{
@@ -239,10 +237,7 @@ public async Task<T> RetrieveMetadata<T>(
239237

240238
try
241239
{
242-
await foreach (var metadata in GetMetadata<T>(instancMetadataUri))
243-
{
244-
return metadata;
245-
}
240+
await GetMetadata<T>(instancMetadataUri).FirstOrDefaultAsync();
246241
}
247242
catch (Exception ex) when (ex is not UnsupportedReturnTypeException)
248243
{

src/InformaticsGateway/Services/Export/ExportServiceBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private void ReportingActionBlock(ExportRequestDataMessage exportRequestData)
279279
_messagePublisher.Publish(_configuration.Messaging.Topics.ExportComplete, jsonMessage.ToMessage());
280280
});
281281

282-
lock(SyncRoot)
282+
lock (SyncRoot)
283283
{
284284
_exportRequests.Remove(exportRequestData.ExportTaskId);
285285
}

src/InformaticsGateway/Test/Services/Export/ExportServiceBaseTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public async Task DataflowTest_EndToEnd()
205205
{
206206
callback(new MemoryStream(Encoding.UTF8.GetBytes(testData)));
207207
});
208-
var countdownEvent = new CountdownEvent(5 * 3);
208+
var countdownEvent = new CountdownEvent(5 * 3);
209209
var service = new TestExportService(_logger.Object, _configuration, _serviceScopeFactory.Object, _storageInfoProvider.Object);
210210
service.ReportActionCompleted += (sender, e) =>
211211
{

tests/Integration.Test/Drivers/DicomInstanceGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public class StudyGenerationSpecs
4747

4848
private readonly int _instance;
4949
private readonly ISpecFlowOutputHelper _outputHelper;
50-
private DicomDataset _baseDataset;
51-
private Random _random;
50+
private readonly DicomDataset _baseDataset;
51+
private readonly Random _random;
5252

5353
public DicomInstanceGenerator(ISpecFlowOutputHelper outputHelper)
5454
{

tests/Integration.Test/Hooks/RabbitMqHooks.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ namespace Monai.Deploy.InformaticsGateway.Integration.Test.Hooks
2323
public sealed class RabbitMqHooks
2424
{
2525
internal static readonly string ScenarioContextKey = "MESSAAGES";
26-
private readonly string QueueNameWorkflowQueue = "workflow-queue";
27-
private readonly string QueueNameExportQueue = "export-queue";
26+
private readonly string _queueNameWorkflowQueue = "workflow-queue";
27+
private readonly string _queueNameExportQueue = "export-queue";
2828
private readonly ISpecFlowOutputHelper _outputHelper;
2929
private readonly Configurations _configuration;
3030
private readonly ScenarioContext _scenarioContext;
31-
private ConnectionFactory _connectionFactory;
32-
private MessageBrokerConfigurationKeys _configurationKeys;
33-
private IConnection _connection;
34-
private IModel _channel;
31+
private readonly ConnectionFactory _connectionFactory;
32+
private readonly MessageBrokerConfigurationKeys _configurationKeys;
33+
private readonly IConnection _connection;
34+
private readonly IModel _channel;
3535
private string _consumerTag;
3636
public CountdownEvent MessageWaitHandle { get; private set; }
3737

@@ -59,13 +59,13 @@ public RabbitMqHooks(ISpecFlowOutputHelper outputHelper, Configurations configur
5959
[BeforeScenario("@messaging_export_complete")]
6060
public void BeforeMessagingExportComplete()
6161
{
62-
BeforeMessagingSubscribeTo(QueueNameExportQueue, _configurationKeys.ExportComplete);
62+
BeforeMessagingSubscribeTo(_queueNameExportQueue, _configurationKeys.ExportComplete);
6363
}
6464

6565
[BeforeScenario("@messaging_workflow_request")]
6666
public void BeforeMessagingWorkflowRequest()
6767
{
68-
BeforeMessagingSubscribeTo(QueueNameWorkflowQueue, _configurationKeys.WorkflowRequest);
68+
BeforeMessagingSubscribeTo(_queueNameWorkflowQueue, _configurationKeys.WorkflowRequest);
6969
}
7070

7171
private void BeforeMessagingSubscribeTo(string queue, string routingKey)

tests/Integration.Test/Hooks/ScpHooks.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ namespace Monai.Deploy.InformaticsGateway.Integration.Test.Hooks
1818
[Binding]
1919
public sealed class ScpHooks
2020
{
21+
private static IDicomServer s_dicomServer;
22+
2123
internal static readonly string KeyServerData = "SERVER-DATA";
2224
internal static readonly string FeatureScpAeTitle = "TEST-SCP";
2325
internal static readonly int FeatureScpPort = 1105;
24-
private static IDicomServer _dicomServer;
2526

2627
[BeforeFeature("@scp")]
2728
public static void BeforeMessagingExportComplete(ISpecFlowOutputHelper outputHelper, FeatureContext featureContext)
2829
{
2930
try
3031
{
3132
var data = new ServerData { Context = featureContext, OutputHelper = outputHelper };
32-
_dicomServer = DicomServerFactory.Create<CStoreScp>(FeatureScpPort, userState: data);
33+
s_dicomServer = DicomServerFactory.Create<CStoreScp>(FeatureScpPort, userState: data);
3334
featureContext[KeyServerData] = data;
3435
}
3536
catch (Exception ex)
@@ -44,8 +45,8 @@ public static void AfterScenario(ISpecFlowOutputHelper outputHelper, FeatureCont
4445
try
4546
{
4647
featureContext.Remove(KeyServerData);
47-
_dicomServer?.Stop();
48-
_dicomServer?.Dispose();
48+
s_dicomServer?.Stop();
49+
s_dicomServer?.Dispose();
4950
}
5051
catch (Exception ex)
5152
{

tests/Integration.Test/StepDefinitions/AcrApiStepDefinitions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// SPDX-FileCopyrightText: © 2021-2022 MONAI Consortium
2+
// SPDX-FileCopyrightText: © 2019-2021 NVIDIA Corporation
3+
// SPDX-License-Identifier: Apache License 2.0
4+
25
using System.Text;
36
using FellowOakDicom;
47
using FellowOakDicom.Network;
@@ -13,7 +16,6 @@
1316
using Monai.Deploy.InformaticsGateway.Integration.Test.Drivers;
1417
using Monai.Deploy.InformaticsGateway.Integration.Test.Hooks;
1518
using Polly;
16-
using TechTalk.SpecFlow;
1719
using TechTalk.SpecFlow.Infrastructure;
1820

1921
namespace Monai.Deploy.InformaticsGateway.Integration.Test.StepDefinitions

0 commit comments

Comments
 (0)