Skip to content

Commit 5ba3b67

Browse files
committed
Move into if statement
1 parent 76fe3fa commit 5ba3b67

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -849,24 +849,24 @@ private IEnumerable<string> GetFeeds(Func<IList<string>> getNugetFeeds)
849849
.Where(folder => folder != null)
850850
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!)))
851851
.ToHashSet();
852+
853+
// If we have discovered any explicit feeds, then we also expect these to be in the set of all feeds.
854+
// Normally, it is a safe assumption to make that `GetNugetFeedsFromFolder` will include the feeds configured
855+
// in a NuGet configuration file in the given directory. There is one exception: on a system with case-sensitive
856+
// file systems, we may discover a configuration file such as `Nuget.Config` which is not recognised by `dotnet nuget`.
857+
// In that case, our call to `GetNugetFeeds` will retrieve the feeds from that file (because it is accepted when
858+
// provided explicitly as `--configfile` argument), but the call to `GetNugetFeedsFromFolder` will not.
859+
if (explicitFeeds.Count > 0)
860+
{
861+
allFeeds.UnionWith(explicitFeeds);
862+
}
852863
}
853864
else
854865
{
855866
// If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory.
856867
allFeeds = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(this.fileProvider.SourceDir.FullName)).ToHashSet();
857868
}
858869

859-
// If we have discovered any explicit feeds, then we also expect these to be in the set of all feeds.
860-
// Normally, it is a safe assumption to make that `GetNugetFeedsFromFolder` will include the feeds configured
861-
// in a NuGet configuration file in the given directory. There is one exception: on a system with case-sensitive
862-
// file systems, we may discover a configuration file such as `Nuget.Config` which is not recognised by `dotnet nuget`.
863-
// In that case, our call to `GetNugetFeeds` will retrieve the feeds from that file (because it is accepted when
864-
// provided explicitly as `--configfile` argument), but the call to `GetNugetFeedsFromFolder` will not.
865-
if (explicitFeeds.Count > 0)
866-
{
867-
allFeeds.UnionWith(explicitFeeds);
868-
}
869-
870870
logger.LogInfo($"Found {allFeeds.Count} NuGet feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}");
871871

872872
return (explicitFeeds, allFeeds);

0 commit comments

Comments
 (0)