Skip to content

Commit 4939d9d

Browse files
committed
linting: use path join instead of combine
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent 4bcddb4 commit 4939d9d

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagramAsync
134134
// create a dummy ILogger instance for testing
135135
var options = new HidiOptions
136136
{
137-
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
137+
OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
138138
Output = new($"{nameof(ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagramAsync)}.md")
139139
};
140140

@@ -149,7 +149,7 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagramAsync()
149149
{
150150
var options = new HidiOptions
151151
{
152-
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml")
152+
OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml")
153153
};
154154
var filePath = await OpenApiService.ShowOpenApiDocumentAsync(options, _logger, TestContext.Current.CancellationToken);
155155
Assert.True(File.Exists(filePath));
@@ -180,23 +180,23 @@ public Task ThrowIfFileDoesNotExistWhenValidatingAsync()
180180
public async Task ValidateCommandProcessesOpenApiAsync()
181181
{
182182
// create a dummy ILogger instance for testing
183-
await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
183+
await OpenApiService.ValidateOpenApiDocumentAsync(Path.Join("UtilityFiles", "SampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
184184

185185
Assert.True(true);
186186
}
187187

188188
[Fact]
189189
public async Task ValidFileReturnsTrueAsync()
190190
{
191-
var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
191+
var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Join("UtilityFiles", "SampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
192192

193193
Assert.True(isValid);
194194
}
195195

196196
[Fact]
197197
public async Task InvalidFileReturnsFalseAsync()
198198
{
199-
var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "InvalidSampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
199+
var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Join("UtilityFiles", "InvalidSampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
200200

201201
Assert.False(isValid);
202202
}
@@ -206,7 +206,7 @@ public async Task CancellingValidationReturnsNullAsync()
206206
{
207207
using var cts = new CancellationTokenSource();
208208
await cts.CancelAsync();
209-
var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, cts.Token);
209+
var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Join("UtilityFiles", "SampleOpenApi.yml"), _logger, cts.Token);
210210

211211
Assert.Null(isValid);
212212
}
@@ -216,7 +216,7 @@ public async Task TransformCommandConvertsOpenApiAsync()
216216
{
217217
var options = new HidiOptions
218218
{
219-
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
219+
OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
220220
Output = new($"{nameof(TransformCommandConvertsOpenApiAsync)}.json"),
221221
CleanOutput = true,
222222
TerseOutput = false,
@@ -236,7 +236,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAsync()
236236
{
237237
var options = new HidiOptions
238238
{
239-
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
239+
OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
240240
CleanOutput = true,
241241
TerseOutput = false,
242242
InlineLocal = false,
@@ -255,7 +255,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
255255
{
256256
var options = new HidiOptions
257257
{
258-
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
258+
OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
259259
Output = new($"{nameof(TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchFormatAsync)}.yml"),
260260
CleanOutput = true,
261261
Version = "3.0",
@@ -288,10 +288,10 @@ public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmptyAsync()
288288
[Fact]
289289
public async Task TransformToPowerShellCompliantOpenApiAsync()
290290
{
291-
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "examplepowershellsettings.json");
291+
var settingsPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "examplepowershellsettings.json");
292292
var options = new HidiOptions
293293
{
294-
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
294+
OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
295295
Output = new($"{nameof(TransformToPowerShellCompliantOpenApiAsync)}.yaml"),
296296
CleanOutput = true,
297297
Version = "3.0",
@@ -312,7 +312,7 @@ public async Task TransformToPowerShellCompliantOpenApiAsync()
312312
public async Task InvokeTransformCommandAsync()
313313
{
314314
var rootCommand = Program.CreateRootCommand();
315-
var openapi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml");
315+
var openapi = Path.Join(".", "UtilityFiles", "SampleOpenApi.yml");
316316
var outputPath = $"{nameof(InvokeTransformCommandAsync)}.json";
317317
var args = new[] { "transform", "-d", openapi, "-o", outputPath, "--co" };
318318
var parseResult = rootCommand.Parse(args);
@@ -329,7 +329,7 @@ public async Task InvokeTransformCommandAsync()
329329
public async Task InvokeShowCommandAsync()
330330
{
331331
var rootCommand = Program.CreateRootCommand();
332-
var openApi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml");
332+
var openApi = Path.Join(".", "UtilityFiles", "SampleOpenApi.yml");
333333
var outputPath = $"{nameof(InvokeShowCommandAsync)}.md";
334334
var args = new[] { "show", "-d", openApi, "-o", outputPath };
335335
var parseResult = rootCommand.Parse(args);
@@ -345,15 +345,15 @@ public async Task InvokeShowCommandAsync()
345345
public async Task InvokePluginCommandAsync()
346346
{
347347
var rootCommand = Program.CreateRootCommand();
348-
var manifest = Path.Combine(".", "UtilityFiles", "exampleapimanifest.json");
349-
var outputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, nameof(InvokePluginCommandAsync));
348+
var manifest = Path.Join(".", "UtilityFiles", "exampleapimanifest.json");
349+
var outputPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, nameof(InvokePluginCommandAsync));
350350
var args = new[] { "plugin", "-m", manifest, "--of", outputPath };
351351
var parseResult = rootCommand.Parse(args);
352352
var handler = Assert.IsType<AsynchronousCommandLineAction>(rootCommand.Subcommands.First(c => c.Name == "plugin").Action, exactMatch: false);
353353

354354
await handler.InvokeAsync(parseResult, TestContext.Current.CancellationToken);
355355

356-
using var jsDoc = JsonDocument.Parse(await File.ReadAllTextAsync(Path.Combine(outputPath, "ai-plugin.json"), TestContext.Current.CancellationToken));
356+
using var jsDoc = JsonDocument.Parse(await File.ReadAllTextAsync(Path.Join(outputPath, "ai-plugin.json"), TestContext.Current.CancellationToken));
357357
var openAiManifest = OpenAIPluginManifest.Load(jsDoc.RootElement);
358358

359359
Assert.NotNull(openAiManifest);

test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public async Task EquivalentV2AndV3DocumentsShouldProduceEquivalentObjects(strin
2222
{
2323
var settings = new OpenApiReaderSettings();
2424
settings.AddYamlReader();
25-
using var streamV2 = Resources.GetStream(Path.Combine(SampleFolderPath, $"{fileName}.v2.yaml"));
26-
using var streamV3 = Resources.GetStream(Path.Combine(SampleFolderPath, $"{fileName}.v3.yaml"));
27-
var result1 = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, $"{fileName}.v2.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
28-
var result2 = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, $"{fileName}.v3.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
25+
using var streamV2 = Resources.GetStream(Path.Join(SampleFolderPath, $"{fileName}.v2.yaml"));
26+
using var streamV3 = Resources.GetStream(Path.Join(SampleFolderPath, $"{fileName}.v3.yaml"));
27+
var result1 = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, $"{fileName}.v2.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
28+
var result2 = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, $"{fileName}.v3.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
2929

3030
result2.Document.Should().BeEquivalentTo(result1.Document,
3131
options => options.Excluding(x => x.Workspace).Excluding(y => y.BaseUri));

test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture)
6767
[Fact]
6868
public async Task ShouldParseProducesInAnyOrder()
6969
{
70-
var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "twoResponses.json"), token: TestContext.Current.CancellationToken);
70+
var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "twoResponses.json"), token: TestContext.Current.CancellationToken);
7171

7272
var okSchema = new OpenApiSchema
7373
{
@@ -226,7 +226,7 @@ public async Task ShouldParseProducesInAnyOrder()
226226
[Fact]
227227
public async Task ShouldAssignSchemaToAllResponses()
228228
{
229-
using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "multipleProduces.json"));
229+
using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "multipleProduces.json"));
230230
var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Json, cancellationToken: TestContext.Current.CancellationToken);
231231

232232
Assert.Equal(OpenApiSpecVersion.OpenApi2_0, result.Diagnostic.SpecificationVersion);
@@ -257,7 +257,7 @@ public async Task ShouldAssignSchemaToAllResponses()
257257
public async Task ShouldAllowComponentsThatJustContainAReference()
258258
{
259259
// Act
260-
var actual = (await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "ComponentRootReference.json"), token: TestContext.Current.CancellationToken)).Document;
260+
var actual = (await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "ComponentRootReference.json"), token: TestContext.Current.CancellationToken)).Document;
261261
var schema1 = actual.Components.Schemas["AllPets"];
262262
var schema1Reference = Assert.IsType<OpenApiSchemaReference>(schema1);
263263
Assert.False(schema1Reference.UnresolvedReference);
@@ -279,7 +279,7 @@ public async Task ParseDocumentWithDefaultContentTypeSettingShouldSucceed()
279279
};
280280
settings.AddYamlReader();
281281

282-
var actual = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithEmptyProduces.yaml"), settings, token: TestContext.Current.CancellationToken);
282+
var actual = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "docWithEmptyProduces.yaml"), settings, token: TestContext.Current.CancellationToken);
283283
var mediaType = actual.Document.Paths["/example"].Operations[HttpMethod.Get].Responses["200"].Content;
284284
Assert.Contains("application/json", mediaType);
285285
}

0 commit comments

Comments
 (0)