Skip to content

Commit 5d6db61

Browse files
committed
Fixed more smells
1 parent eb539de commit 5d6db61

File tree

6 files changed

+9
-10
lines changed

6 files changed

+9
-10
lines changed

src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public override void Visit(OpenApiPathItem pathItem)
6464
public override void Visit(OpenApiOperation operation)
6565
{
6666
if (string.IsNullOrWhiteSpace(operation.OperationId))
67-
throw new ArgumentNullException(nameof(operation.OperationId), $"OperationId is required {PathString}");
67+
throw new ArgumentException(nameof(operation), $"OperationId is required {PathString}");
6868

6969
var operationId = operation.OperationId;
7070
var operationTypeExtension = operation.Extensions.GetExtension("x-ms-docs-operation-type");
@@ -90,7 +90,6 @@ private static string ResolveVerbSegmentInOpertationId(string operationId)
9090
var charPos = operationId.LastIndexOf('.', operationId.Length - 1);
9191
if (operationId.Contains('_') || charPos < 0)
9292
return operationId;
93-
// TODO: Optimize this call.
9493
var newOperationId = new StringBuilder(operationId);
9594
newOperationId[charPos] = '_';
9695
operationId = newOperationId.ToString();

src/Microsoft.OpenApi.Hidi/Handlers/PluginCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public async Task<int> InvokeAsync(InvocationContext context)
3737
catch (Exception ex)
3838
{
3939
#if DEBUG
40-
logger.LogCritical(ex, ex.Message);
40+
logger.LogCritical(ex, "Command failed");
4141
throw; // so debug tools go straight to the source of the exception when attached
4242
#else
43-
logger.LogCritical( ex.Message);
43+
logger.LogCritical(ex.Message);
4444
return 1;
4545
#endif
4646
}

src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
3737
catch (Exception ex)
3838
{
3939
#if DEBUG
40-
logger.LogCritical(ex, ex.Message);
40+
logger.LogCritical(ex, "Command failed");
4141
throw; // so debug tools go straight to the source of the exception when attached
4242
#else
4343
logger.LogCritical( ex.Message);

src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
3737
catch (Exception ex)
3838
{
3939
#if DEBUG
40-
logger.LogCritical(ex, ex.Message);
40+
logger.LogCritical(ex, "Command failed");
4141
throw; // so debug tools go straight to the source of the exception when attached
4242
#else
4343
logger.LogCritical( ex.Message);

src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
3737
catch (Exception ex)
3838
{
3939
#if DEBUG
40-
logger.LogCritical(ex, ex.Message);
40+
logger.LogCritical(ex, "Command failed");
4141
throw; // so debug tools go straight to the source of the exception when attached
4242
#else
4343
logger.LogCritical( ex.Message);

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private static async Task<OpenApiDocument> GetOpenApi(HidiOptions options, ILogg
214214
if (!string.IsNullOrEmpty(options.Csdl))
215215
{
216216
var stopwatch = new Stopwatch();
217-
using (logger.BeginScope($"Convert CSDL: {options.Csdl}", options.Csdl))
217+
using (logger.BeginScope("Convert CSDL: {csdl}", options.Csdl))
218218
{
219219
stopwatch.Start();
220220
stream = await GetStream(options.Csdl, logger, cancellationToken);
@@ -356,7 +356,7 @@ private static async Task<ReadResult> ParseOpenApi(string openApiFile, bool inli
356356
{
357357
ReadResult result;
358358
Stopwatch stopwatch = Stopwatch.StartNew();
359-
using (logger.BeginScope($"Parsing OpenAPI: {openApiFile}", openApiFile))
359+
using (logger.BeginScope("Parsing OpenAPI: {openApiFile}", openApiFile))
360360
{
361361
stopwatch.Start();
362362

@@ -621,7 +621,7 @@ private static void LogErrors(ILogger logger, ReadResult result)
621621
{
622622
foreach (var error in context.Errors)
623623
{
624-
logger.LogError($"Detected error during parsing: {error}", error.ToString());
624+
logger.LogError("Detected error during parsing: {error}", error.ToString());
625625
}
626626
}
627627
}

0 commit comments

Comments
 (0)