Skip to content

Commit

Permalink
Keep stream open when parsing yaml files
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Sep 23, 2024
1 parent 58495e9 commit 2d7f2de
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 118 deletions.
1 change: 1 addition & 0 deletions src/Meziantou.Framework.DependencyScanning/Dependency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public Dependency(string? name, string? version, DependencyType type, Location?
public DependencyType Type { get; }
public Location? NameLocation { get; }
public Location? VersionLocation { get; }
public ISet<string> Tags { get; } = new HashSet<string>(StringComparer.Ordinal);

public Task UpdateNameAsync(string newValue, CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>$(LatestTargetFrameworks)</TargetFrameworks>
<IsTrimmable>false</IsTrimmable>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Description>Find dependencies in source files. Support multiple package managers such as NuGet, npm, Docker, PyPi, and so on</Description>
</PropertyGroup>

Expand Down
14 changes: 14 additions & 0 deletions src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ public void ReportDependency(Dependency dependency)
_onDependencyFound(dependency);
}

public void ReportDependency<TScanner>(string? name, string? version, DependencyType type, Location? nameLocation, Location? versionLocation)
where TScanner : DependencyScanner
{
ReportDependency<TScanner>(name, version, type, nameLocation, versionLocation, ReadOnlySpan<string>.Empty);
}

public void ReportDependency<TScanner>(string? name, string? version, DependencyType type, Location? nameLocation, Location? versionLocation, ReadOnlySpan<string> tags)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (ubuntu-22.04, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (macos-14, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Debug)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Release)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Debug, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 37 in src/Meziantou.Framework.DependencyScanning/ScanFileContext.cs

View workflow job for this annotation

GitHub Actions / build_and_test_x64 (windows-2022, Release, /p:InvariantGlobalization=true)

Remove unused parameter 'tags' if it is not part of a shipped public API (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)
where TScanner : DependencyScanner
{
var dep = new Dependency(name, version, type, nameLocation, versionLocation);
dep.Tags.Add(typeof(TScanner).FullName);
ReportDependency(dep);
}

internal void ResetStream()
{
if (_content.IsValueCreated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ private static void ReportDependency(ScanFileContext context, YamlNode node, Dep
var index = value.IndexOf(versionSeparator, StringComparison.Ordinal);
if (index < 0)
{
context.ReportDependency(new Dependency(name: value, version: null, dependencyType, nameLocation: GetLocation(context, node), versionLocation: null));
context.ReportDependency<AzureDevOpsScanner>(name: value, version: null, dependencyType, nameLocation: GetLocation(context, node), versionLocation: null);
}
else
{
context.ReportDependency(new Dependency(
context.ReportDependency<AzureDevOpsScanner>(
name: value[..index],
version: value[(index + 1)..],
dependencyType,
nameLocation: GetLocation(context, node, start: 0, length: index),
versionLocation: GetLocation(context, node, start: index + 1, length: value.Length - index - 1)));
versionLocation: GetLocation(context, node, start: index + 1, length: value.Length - index - 1));
}
}

Expand Down Expand Up @@ -80,7 +80,7 @@ private static void ScanPool(ScanFileContext context, YamlNode node)
var value = GetScalarValue(vmImageNode);
if (value is not null)
{
context.ReportDependency(new Dependency(name: null, version: value, DependencyType.AzureDevOpsVMPool, nameLocation: null, versionLocation: GetLocation(context, vmImageNode)));
context.ReportDependency<AzureDevOpsScanner>(name: null, version: value, DependencyType.AzureDevOpsVMPool, nameLocation: null, versionLocation: GetLocation(context, vmImageNode));
}
}

Expand Down Expand Up @@ -165,7 +165,7 @@ private static void ScanResources(ScanFileContext context, YamlNode node)
var version = GetProperty(repository, "ref", StringComparison.Ordinal);
if (name is not null)
{
context.ReportDependency(new Dependency(name: GetScalarValue(name), version: GetScalarValue(version), DependencyType.GitReference, nameLocation: GetLocation(context, name), versionLocation: GetLocation(context, version)));
context.ReportDependency<AzureDevOpsScanner>(name: GetScalarValue(name), version: GetScalarValue(version), DependencyType.GitReference, nameLocation: GetLocation(context, name), versionLocation: GetLocation(context, version));
}
}
}
Expand All @@ -177,7 +177,7 @@ public override ValueTask ScanAsync(ScanFileContext context)
{
try
{
using var textReader = new StreamReader(context.Content);
using var textReader = new StreamReader(context.Content, leaveOpen: true);
var reader = new MergingParser(new Parser(textReader));
var yaml = new YamlStream();
yaml.Load(reader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public override async ValueTask ScanAsync(ScanFileContext context)
var packageName = packageNameGroup.Value;
var versionGroup = match.Groups["Version"];
var version = versionGroup.Value;
context.ReportDependency(new Dependency(packageName, version, DependencyType.DockerImage,
context.ReportDependency<DockerfileDependencyScanner>(packageName, version, DependencyType.DockerImage,
nameLocation: new TextLocation(context.FileSystem, context.FullPath, lineNo, packageNameGroup.Index + 1, packageNameGroup.Length),
versionLocation: new TextLocation(context.FileSystem, context.FullPath, lineNo, versionGroup.Index + 1, versionGroup.Length)));
versionLocation: new TextLocation(context.FileSystem, context.FullPath, lineNo, versionGroup.Index + 1, versionGroup.Length));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ private static void ExtractMsBuildSdks(ScanFileContext context, JToken doc)
var sdkVersion = sdk.Value.Value<string>();
if (sdkVersion is not null)
{
context.ReportDependency(new Dependency(sdk.Name, sdkVersion, DependencyType.NuGet,
context.ReportDependency<DotNetGlobalJsonDependencyScanner>(sdk.Name, sdkVersion, DependencyType.NuGet,
nameLocation: new NonUpdatableLocation(context),
versionLocation: new JsonLocation(context, sdk.Value)));
versionLocation: new JsonLocation(context, sdk.Value));
}
}
}
Expand All @@ -51,9 +51,9 @@ private static void ExtractSdk(ScanFileContext context, JToken doc)
var token = doc.SelectToken("$.sdk.version");
if (token?.Value<string>() is string version)
{
context.ReportDependency(new Dependency(name: null, version, DependencyType.DotNetSdk,
context.ReportDependency<DotNetGlobalJsonDependencyScanner>(name: null, version, DependencyType.DotNetSdk,
nameLocation: null,
versionLocation: new JsonLocation(context, token)));
versionLocation: new JsonLocation(context, token));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public override async ValueTask ScanAsync(ScanFileContext context)

if (version is not null)
{
context.ReportDependency(new Dependency(packageName, version, DependencyType.NuGet,
context.ReportDependency<DotNetToolManifestDependencyScanner>(packageName, version, DependencyType.NuGet,
nameLocation: new NonUpdatableLocation(context),
versionLocation: new JsonLocation(context, valueElement)));
versionLocation: new JsonLocation(context, valueElement));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override ValueTask ScanAsync(ScanFileContext context)
{
try
{
using var textReader = new StreamReader(context.Content);
using var textReader = new StreamReader(context.Content, leaveOpen: true);
var reader = new MergingParser(new Parser(textReader));
var yaml = new YamlStream();
yaml.Load(reader);
Expand Down Expand Up @@ -70,15 +70,15 @@ public override ValueTask ScanAsync(ScanFileContext context)
var nameLocation = GetLocation(context, usesValue, start: DockerPrefix.Length, length: name.Length);
var versionLocation = GetLocation(context, usesValue, start: DockerPrefix.Length + index + 1, length: version.Length);

context.ReportDependency(new Dependency(name, version, DependencyType.DockerImage, nameLocation, versionLocation));
context.ReportDependency<GitHubActionsScanner>(name, version, DependencyType.DockerImage, nameLocation, versionLocation);
}
else
{
// no version
var name = value[DockerPrefix.Length..];
var nameLocation = GetLocation(context, usesValue, start: DockerPrefix.Length, length: name.Length);

context.ReportDependency(new Dependency(name, version: null, DependencyType.DockerImage, nameLocation, versionLocation: null));
context.ReportDependency<GitHubActionsScanner>(name, version: null, DependencyType.DockerImage, nameLocation, versionLocation: null);

}
}
Expand Down Expand Up @@ -142,16 +142,16 @@ private static void ReportDependencyWithSeparator(ScanFileContext context, YamlN
var index = value.IndexOf(versionSeparator, StringComparison.Ordinal);
if (index < 0)
{
context.ReportDependency(new Dependency(name: value, version: null, dependencyType, nameLocation: GetLocation(context, node), versionLocation: null));
context.ReportDependency<GitHubActionsScanner>(name: value, version: null, dependencyType, nameLocation: GetLocation(context, node), versionLocation: null);
}
else
{
context.ReportDependency(new Dependency(
context.ReportDependency<GitHubActionsScanner>(
name: value[..index],
version: value[(index + 1)..],
dependencyType,
nameLocation: GetLocation(context, node, start: 0, length: index),
versionLocation: GetLocation(context, node, start: index + 1, length: value.Length - index - 1)));
versionLocation: GetLocation(context, node, start: index + 1, length: value.Length - index - 1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public override ValueTask ScanAsync(ScanFileContext context)
using var repository = new Repository(Path.GetDirectoryName(context.FullPath));
foreach (var module in repository.Submodules)
{
context.ReportDependency(new Dependency(module.Url, module.WorkDirCommitId.Sha, DependencyType.GitSubmodule,
context.ReportDependency<GitSubmoduleDependencyScanner>(module.Url, module.WorkDirCommitId.Sha, DependencyType.GitSubmodule,
nameLocation: new NonUpdatableLocation(context),
versionLocation: new NonUpdatableLocation(context)));
versionLocation: new NonUpdatableLocation(context));
}
}
catch (LibGit2SharpException)
Expand Down
Loading

0 comments on commit 2d7f2de

Please sign in to comment.