Skip to content

Commit d447203

Browse files
Merge pull request #605 from TransactionProcessing/codacy/high_fixes
fix some more isssues
2 parents 16f05ff + d220040 commit d447203

File tree

6 files changed

+11
-31
lines changed

6 files changed

+11
-31
lines changed

FileProcessor.BusinessLogic/EventHandling/FileDomainEventHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ public async Task<Result> Handle(IDomainEvent domainEvent,
6565
return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
6666
}
6767

68-
//private static Int32 TransactionNumber = 0;
69-
7068
/// <summary>
7169
/// Handles the specific domain event.
7270
/// </summary>

FileProcessor.BusinessLogic/Services/FileProcessorDomainService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public async Task<Result> ProcessTransactionForFileLine(FileCommands.ProcessTran
310310
// need to now parse the line (based on the file format), this builds the metadata
311311
Dictionary<String, String> transactionMetadata = this.ParseFileLine(fileLine.LineData, fileProfile.FileFormatHandler);
312312

313-
if (transactionMetadata == null)
313+
if (transactionMetadata.Any() == false)
314314
{
315315
// Line failed to parse so record this
316316
fileAggregate.RecordFileLineAsRejected(fileLine.LineNumber, "Invalid Format");
@@ -566,7 +566,7 @@ private Dictionary<String, String> ParseFileLine(String domainEventFileLine,
566566
catch (InvalidDataException iex)
567567
{
568568
Logger.LogWarning(iex.Message);
569-
return null;
569+
return new Dictionary<String, String>();
570570
}
571571
}
572572

FileProcessor.Client/FileProcessorClient.cs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ public async Task<Result<FileDetails>> GetFile(String accessToken,
5959
Guid estateId,
6060
Guid fileId,
6161
CancellationToken cancellationToken) {
62-
FileDetails response = null;
63-
6462
String requestUri = this.BuildRequestUrl($"/api/files/{fileId}?estateId={estateId}");
6563

6664
try {
@@ -81,16 +79,14 @@ public async Task<Result<FileDetails>> GetFile(String accessToken,
8179
HandleResponseContent<FileDetails>(result.Data);
8280

8381
// call was successful so now deserialise the body to the response object
84-
response = responseData.Data;
82+
return Result.Success(responseData.Data);
8583
}
8684
catch (Exception ex) {
8785
// An exception has occurred, add some additional information to the message
8886
Exception exception = new Exception($"Error getting file with Id {fileId}.", ex);
8987

9088
throw exception;
9189
}
92-
93-
return Result.Success(response);
9490
}
9591

9692
/// <summary>
@@ -107,8 +103,6 @@ public async Task<Result<FileImportLog>> GetFileImportLog(String accessToken,
107103
Guid estateId,
108104
Guid? merchantId,
109105
CancellationToken cancellationToken) {
110-
FileImportLog response = null;
111-
112106
String requestUri = this.BuildRequestUrl($"/api/fileImportLogs/{fileImportLogId}?estateId={estateId}");
113107

114108
if (merchantId.HasValue) {
@@ -133,16 +127,14 @@ public async Task<Result<FileImportLog>> GetFileImportLog(String accessToken,
133127
HandleResponseContent<FileImportLog>(result.Data);
134128

135129
// call was successful so now deserialise the body to the response object
136-
response = responseData.Data;
130+
return Result.Success(responseData.Data);
137131
}
138132
catch (Exception ex) {
139133
// An exception has occurred, add some additional information to the message
140134
Exception exception = new Exception("Error getting file import log.", ex);
141135

142136
throw exception;
143137
}
144-
145-
return Result.Success(response);
146138
}
147139

148140
/// <summary>
@@ -161,8 +153,6 @@ public async Task<Result<FileImportLogList>> GetFileImportLogs(String accessToke
161153
DateTime endDateTime,
162154
Guid? merchantId,
163155
CancellationToken cancellationToken) {
164-
FileImportLogList response = null;
165-
166156
String requestUri =
167157
this.BuildRequestUrl(
168158
$"/api/fileImportLogs?estateId={estateId}&startDateTime={startDateTime.Date:yyyy-MM-dd}&endDateTime={endDateTime.Date:yyyy-MM-dd}");
@@ -188,16 +178,14 @@ public async Task<Result<FileImportLogList>> GetFileImportLogs(String accessToke
188178
HandleResponseContent<FileImportLogList>(result.Data);
189179

190180
// call was successful so now deserialise the body to the response object
191-
response = responseData.Data;
181+
return Result.Success(responseData.Data);
192182
}
193183
catch (Exception ex) {
194184
// An exception has occurred, add some additional information to the message
195185
Exception exception = new Exception("Error getting list of file import logs.", ex);
196186

197187
throw exception;
198188
}
199-
200-
return Result.Success(response);
201189
}
202190

203191
/// <summary>
@@ -214,7 +202,6 @@ public async Task<Result<Guid>> UploadFile(String accessToken,
214202
Byte[] fileData,
215203
UploadFileRequest uploadFileRequest,
216204
CancellationToken cancellationToken) {
217-
Guid response = Guid.Empty;
218205
try {
219206
String requestUri = this.BuildRequestUrl("/api/files");
220207

@@ -246,16 +233,14 @@ public async Task<Result<Guid>> UploadFile(String accessToken,
246233
HandleResponseContent<Guid>(result.Data);
247234

248235
// call was successful so now deserialise the body to the response object
249-
response = responseData.Data;
236+
return Result.Success(responseData.Data);
250237
}
251238
catch (Exception ex) {
252239
// An exception has occurred, add some additional information to the message
253240
Exception exception = new Exception($"Error uploading file {fileName}.", ex);
254241

255242
throw exception;
256243
}
257-
258-
return Result.Success(response);
259244
}
260245

261246
/// <summary>

FileProcessor/Bootstrapper/ClientRegistry.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public ClientRegistry() {
2424
this.RegisterHttpClient<ISecurityServiceClient, SecurityServiceClient>();
2525
this.RegisterHttpClient<ITransactionProcessorClient, TransactionProcessorClient>();
2626

27-
//this.AddSingleton<Func<String, String>>(container => serviceName => { return ConfigurationReader.GetBaseServerUri(serviceName).OriginalString; });
2827
Func<String, String> resolver(IServiceProvider container) => serviceName => { return ConfigurationReader.GetBaseServerUri(serviceName).OriginalString; };
2928

3029
this.AddSingleton<Func<String, String>>(resolver);

FileProcessor/Bootstrapper/MiddlewareRegistry.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public MiddlewareRegistry()
5555
}
5656
});
5757
// add a custom operation filter which sets default values
58-
//c.OperationFilter<SwaggerDefaultValues>();
59-
//c.ExampleFilters();
60-
58+
6159
//Locate the XML files being generated by ASP.NET...
6260
var directory = new DirectoryInfo(AppContext.BaseDirectory);
6361
var xmlFiles = directory.GetFiles("*.xml");
@@ -69,7 +67,6 @@ public MiddlewareRegistry()
6967
}
7068
});
7169

72-
//services.AddSwaggerExamplesFromAssemblyOf<SwaggerJsonConverter>();
7370

7471
this.AddAuthentication(options =>
7572
{

FileProcessor/Common/Extensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public static IServiceCollection AddInSecureEventStoreClient(
5858
case TraceEventType.Verbose:
5959
Logger.LogDebug(logMessage);
6060
break;
61+
default:
62+
Logger.LogInformation(logMessage);
63+
break;
6164
}
6265
};
6366

@@ -102,9 +105,7 @@ public static void PreWarm(this IApplicationBuilder applicationBuilder){
102105
};
103106

104107
Func<String, Int32, ISubscriptionRepository> subscriptionRepositoryResolver = Startup.Container.GetInstance<Func<String, Int32, ISubscriptionRepository>>();
105-
106-
EventStoreClientSettings eventStoreClientSettings = EventStoreClientSettings.Create(eventStoreConnectionString);
107-
108+
108109
applicationBuilder.ConfigureSubscriptionService(subscriptionWorkersRoot,
109110
eventStoreConnectionString,
110111
eventHandlerResolvers,

0 commit comments

Comments
 (0)