Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor readers to reduce surface area #1958

Draft
wants to merge 2 commits into
base: vnext
Choose a base branch
from

Conversation

darrelmiller
Copy link
Member

No description provided.

{
JsonNode jsonNode;

// Parse the YAML text in the TextReader into a sequence of JsonNodes
try
{
jsonNode = LoadJsonNodesFromYamlDocument(input);
jsonNode = LoadJsonNodesFromYamlDocument(new StreamReader(input)); // Should we leave the stream open?

Check warning

Code scanning / CodeQL

Missing Dispose call on local IDisposable Warning

Disposable 'StreamReader' is created but not disposed.
@@ -56,7 +73,7 @@
// Parse the YAML
try
{
jsonNode = LoadJsonNodesFromYamlDocument(input);
jsonNode = LoadJsonNodesFromYamlDocument(new StreamReader(input));

Check warning

Code scanning / CodeQL

Missing Dispose call on local IDisposable Warning

Disposable 'StreamReader' is created but not disposed.
return ParseAsync(input, reader, format, settings).GetAwaiter().GetResult();
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
// Copy string into MemoryStream
var stream = new MemoryStream(Encoding.UTF8.GetBytes(input));

Check warning

Code scanning / CodeQL

Missing Dispose call on local IDisposable Warning

Disposable 'MemoryStream' is created but not disposed.
@@ -195,8 +163,8 @@
{
format ??= OpenApiConstants.Json;
settings ??= new OpenApiReaderSettings();
using var reader = new StringReader(input);
return Load<T>(reader, version, out diagnostic, format, settings);
var stream = new MemoryStream(Encoding.UTF8.GetBytes(input));

Check warning

Code scanning / CodeQL

Missing Dispose call on local IDisposable Warning

Disposable 'MemoryStream' is created but not disposed.
{
return Load<T>(memoryStream, version, format, out diagnostic, settings);
} else {
memoryStream = new MemoryStream();

Check warning

Code scanning / CodeQL

Missing Dispose call on local IDisposable Warning

Disposable 'MemoryStream' is created but not disposed.
var reader = OpenApiReaderRegistry.GetReader(format);
var readResult = await reader.ReadAsync(input, settings, cancellationToken);

if (settings.LoadExternalRefs)

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
settings
may be null at this access because the parameter has a null default value.
Variable
settings
may be null at this access because the parameter has a null default value.
private static ReadResult InternalLoad(MemoryStream input, string format, OpenApiReaderSettings settings = null)
{
Utils.CheckArgumentNull(format, nameof(format));
if (settings.LoadExternalRefs)

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
settings
may be null at this access because the parameter has a null default value.
Variable
settings
may be null at this access because the parameter has a null default value.
Copy link

sonarcloud bot commented Nov 26, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant