Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public string GenerateString(IEnumerable<IList<object>> rows)
foreach (var row in rows)
{
sb.Append(verticalLineChar);
if (row.Count() != columns.Count)
if (row.Count != columns.Count)
{
throw new InvalidOperationException("All rows must have length equal to the number of columns present.");
}
Expand All @@ -71,7 +71,7 @@ private void PrintTitleSection(StringBuilder sb)
WriteFlatLine(sb, false);
var tableWidth = columns.Sum(column => column.Width);
sb.Append(verticalLineChar);
sb.Append(tableTitle.PadRight(tableWidth + columns.Count() - 1));
sb.Append(tableTitle.PadRight(tableWidth + columns.Count - 1));
sb.Append(verticalLineChar);

sb.AppendLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ await DockerService.TryPullImageAsync(refWithDigest, cancellationToken)))
private bool ValidateBaseImageLayers(ContainerDetails scannedImageDetails, ContainerDetails baseImageDetails)
{
var scannedImageLayers = scannedImageDetails.Layers.ToArray();
return !(baseImageDetails.Layers.Count() > scannedImageLayers.Count() || baseImageDetails.Layers.Where((layer, index) => scannedImageLayers[index].DiffId != layer.DiffId).Any());
return !(baseImageDetails.Layers.Count() > scannedImageLayers.Length || baseImageDetails.Layers.Where((layer, index) => scannedImageLayers[index].DiffId != layer.DiffId).Any());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static IDictionary<string, string> GetDetectorArgs(IEnumerable<string> de
{
var keyValue = arg.Split('=');

if (keyValue.Count() != 2)
if (keyValue.Length != 2)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private static IDictionary<string, string> GetDetectorArgs(IEnumerable<string> d
{
var keyValue = arg.Split('=');

if (keyValue.Count() != 2)
if (keyValue.Length != 2)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public IEnumerable<IComponentDetector> GetDetectors(Assembly assemblyToSearch, I
var loadedDetectors = LoadComponentDetectorsFromAssemblies(new List<Assembly> { assemblyToSearch }, extraDetectorAssemblies);

var pluralPhrase = loadedDetectors.Count == 1 ? "detector was" : "detectors were";
Logger.LogInfo($"{loadedDetectors.Count()} {pluralPhrase} found in {assemblyToSearch.FullName}\n");
Logger.LogInfo($"{loadedDetectors.Count} {pluralPhrase} found in {assemblyToSearch.FullName}\n");

return loadedDetectors;
}
Expand All @@ -69,7 +69,7 @@ private IList<IComponentDetector> GetComponentDetectors(IEnumerable<DirectoryInf
var loadedDetectors = LoadComponentDetectorsFromAssemblies(new[] { assembly }, extraDetectorAssemblies);

var pluralPhrase = loadedDetectors.Count == 1 ? "detector was" : "detectors were";
Logger.LogInfo($"{loadedDetectors.Count()} {pluralPhrase} found in {assembly.GetName().Name}\n");
Logger.LogInfo($"{loadedDetectors.Count} {pluralPhrase} found in {assembly.GetName().Name}\n");

detectors.AddRange(loadedDetectors);

Expand All @@ -93,7 +93,7 @@ private IList<IComponentDetector> GetComponentDetectors(IEnumerable<DirectoryInf
var loadedDetectors = LoadComponentDetectorsFromAssemblies(assemblies, extraDetectorAssemblies);

var pluralPhrase = loadedDetectors.Count == 1 ? "detector was" : "detectors were";
Logger.LogInfo($"{loadedDetectors.Count()} {pluralPhrase} found in {searchPath}\n");
Logger.LogInfo($"{loadedDetectors.Count} {pluralPhrase} found in {searchPath}\n");

detectors.AddRange(loadedDetectors);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void GetEnumerator_LogsAndBreaksEnumerationWhenFileIsMissing()
},
}, loggerMock.Object).ToList();

enumerable.Count()
enumerable.Count
.Should().Be(1);

loggerMock.VerifyAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task ScanDirectoryAsync_ExcludedFrameworkComponent_2_2_Verification
var ommittedComponentInformationJson = scanResult.AdditionalTelemetryDetails[NuGetProjectModelProjectCentricComponentDetector.OmittedFrameworkComponentsTelemetryKey];
var omittedComponentsWithCount = JsonConvert.DeserializeObject<Dictionary<string, int>>(ommittedComponentInformationJson);

Assert.IsTrue(omittedComponentsWithCount.Keys.Count() > 5, "Ommitted framework assemblies are missing. There should be more than ten, but this is a gut check to make sure we have data.");
Assert.IsTrue(omittedComponentsWithCount.Keys.Count > 5, "Ommitted framework assemblies are missing. There should be more than ten, but this is a gut check to make sure we have data.");
Assert.AreEqual(omittedComponentsWithCount["Microsoft.NETCore.App"], 4, "There should be four cases of the NETCore.App library being omitted in the test data.");
}

Expand All @@ -134,7 +134,7 @@ public async Task ScanDirectoryAsync_DependencyGraph_2_2_additional_Verification
Assert.IsTrue(dependencies.Contains(expectedId));
}

Assert.AreEqual(dependencies.Count(), expectedDependencyIdsForCompositionTypedParts.Count());
Assert.AreEqual(dependencies.Count(), expectedDependencyIdsForCompositionTypedParts.Length);

Assert.AreEqual(graph.GetComponents().Count(), detectedComponents.Count());

Expand Down Expand Up @@ -225,7 +225,7 @@ public async Task ScanDirectoryAsync_ExcludedFrameworkComponent_3_1_Verification
var omittedComponentsWithCount = JsonConvert.DeserializeObject<Dictionary<string, int>>(ommittedComponentInformationJson);

// With 3.X, we don't expect there to be a lot of these, but there are still netstandard libraries present which can bring things into the graph
Assert.AreEqual(omittedComponentsWithCount.Keys.Count(), 4, "Ommitted framework assemblies are missing. There should be more than ten, but this is a gut check to make sure we have data.");
Assert.AreEqual(omittedComponentsWithCount.Keys.Count, 4, "Ommitted framework assemblies are missing. There should be more than ten, but this is a gut check to make sure we have data.");
Assert.AreEqual(omittedComponentsWithCount["System.Reflection"], 1, "There should be one case of the System.Reflection library being omitted in the test data.");
}

Expand Down Expand Up @@ -294,7 +294,7 @@ public async Task ScanDirectory_NoPackageSpec()

var dependencyGraphs = componentRecorder.GetDependencyGraphsByLocation();

dependencyGraphs.Count().Should().Be(0);
dependencyGraphs.Count.Should().Be(0);
}

private string Convert22SampleToOSAgnostic(string project_assets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public async Task ParseFile_RequirementTxtHasComment_CommentAreIgnored()
var result = await service.ParseFile(testPath);
(string, GitComponent) expected = ("knack==0.4.1", null);

Assert.AreEqual(1, result.Count());
Assert.AreEqual(1, result.Count);
Assert.AreEqual(expected, result.First());
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,9 @@ private string CreatePackageJsonFileContent(IList<YarnTestComponentDefinition> c
builder.Append(@"""dependencies"": {");

var prodComponents = components.Where(c => !c.IsDevDependency).ToList();
for (var i = 0; i < prodComponents.Count(); i++)
for (var i = 0; i < prodComponents.Count; i++)
{
if (i == prodComponents.Count() - 1)
if (i == prodComponents.Count - 1)
{
builder.Append($@" ""{prodComponents[i].Name}"": ""{prodComponents[i].RequestedVersion}""");
}
Expand All @@ -855,9 +855,9 @@ private string CreatePackageJsonFileContent(IList<YarnTestComponentDefinition> c

var dependencyComponents = components.Where(c => c.IsDevDependency).ToList();

for (var i = 0; i < dependencyComponents.Count(); i++)
for (var i = 0; i < dependencyComponents.Count; i++)
{
if (i == dependencyComponents.Count() - 1)
if (i == dependencyComponents.Count - 1)
{
builder.Append($@" ""{dependencyComponents[i].Name}"": ""{dependencyComponents[i].RequestedVersion}""");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Test_AccumulateAndConvertToContract()

var convertedGraphContract = GraphTranslationUtility.AccumulateAndConvertToContract(dependencyGraphs);

convertedGraphContract.Count().Should().Be(2);
convertedGraphContract.Count.Should().Be(2);
convertedGraphContract.Keys.Should().BeEquivalentTo(new List<string>() { "file1.json", "file2.json" });

var graph1 = convertedGraphContract["file1.json"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public void DetectComponents_Graph_Happy_Path()
var result = DetectComponentsHappyPath(args, restrictions => { }, new List<ComponentRecorder> { componentRecorder });

result.Result.Should().Be(ProcessingResultCode.Success);
result.DependencyGraphs.Count().Should().Be(1);
result.DependencyGraphs.Count.Should().Be(1);
var matchingGraph = result.DependencyGraphs.First();
matchingGraph.Key.Should().Be(mockGraphLocation);
var explicitlyReferencedComponents = matchingGraph.Value.ExplicitlyReferencedComponentIds;
Expand All @@ -255,7 +255,7 @@ public void DetectComponents_Graph_Happy_Path()

var actualGraph = matchingGraph.Value.Graph;
actualGraph.Keys.Count.Should().Be(2);
actualGraph[detectedComponents[0].Component.Id].Count().Should().Be(1);
actualGraph[detectedComponents[0].Component.Id].Count.Should().Be(1);
actualGraph[detectedComponents[0].Component.Id].Should().Contain(detectedComponents[1].Component.Id);
actualGraph[detectedComponents[1].Component.Id].Should().BeNull();

Expand Down Expand Up @@ -302,7 +302,7 @@ public void DetectComponents_Graph_AccumulatesGraphsOnSameLocation()
var result = DetectComponentsHappyPath(args, restrictions => { }, new List<ComponentRecorder> { componentRecorder });

result.Result.Should().Be(ProcessingResultCode.Success);
result.DependencyGraphs.Count().Should().Be(1);
result.DependencyGraphs.Count.Should().Be(1);
var matchingGraph = result.DependencyGraphs.First();
matchingGraph.Key.Should().Be(mockGraphLocation);
var explicitlyReferencedComponents = matchingGraph.Value.ExplicitlyReferencedComponentIds;
Expand All @@ -312,9 +312,9 @@ public void DetectComponents_Graph_AccumulatesGraphsOnSameLocation()

var actualGraph = matchingGraph.Value.Graph;
actualGraph.Keys.Count.Should().Be(2);
actualGraph[detectedComponents[0].Component.Id].Count().Should().Be(1);
actualGraph[detectedComponents[0].Component.Id].Count.Should().Be(1);
actualGraph[detectedComponents[0].Component.Id].Should().Contain(detectedComponents[1].Component.Id);
actualGraph[detectedComponents[1].Component.Id].Count().Should().Be(1);
actualGraph[detectedComponents[1].Component.Id].Count.Should().Be(1);
actualGraph[detectedComponents[1].Component.Id].Should().Contain(detectedComponents[0].Component.Id);
}

Expand Down Expand Up @@ -589,7 +589,7 @@ private TestOutput DetectComponentsHappyPath(
detectorRestrictionServiceMock.Setup(
x => x.ApplyRestrictions(
It.IsAny<DetectorRestrictions>(),
It.Is<IEnumerable<IComponentDetector>>(inputDetectors => registeredDetectors.Intersect(inputDetectors).Count() == registeredDetectors.Count())))
It.Is<IEnumerable<IComponentDetector>>(inputDetectors => registeredDetectors.Intersect(inputDetectors).Count() == registeredDetectors.Length)))
.Returns(restrictedDetectors)
.Callback<DetectorRestrictions, IEnumerable<IComponentDetector>>(
(restrictions, detectors) => restrictionAsserter?.Invoke(restrictions));
Expand All @@ -611,7 +611,7 @@ private TestOutput DetectComponentsHappyPath(
detectorProcessingServiceMock.Setup(x =>
x.ProcessDetectorsAsync(
args,
It.Is<IEnumerable<IComponentDetector>>(inputDetectors => restrictedDetectors.Intersect(inputDetectors).Count() == restrictedDetectors.Count()),
It.Is<IEnumerable<IComponentDetector>>(inputDetectors => restrictedDetectors.Intersect(inputDetectors).Count() == restrictedDetectors.Length),
Match.Create<DetectorRestrictions>(restriction => true)))
.ReturnsAsync(processingResult);

Expand All @@ -634,7 +634,7 @@ private ScanResult SetupRecorderBasedScanning(
detectorRestrictionServiceMock.Setup(
x => x.ApplyRestrictions(
It.IsAny<DetectorRestrictions>(),
It.Is<IEnumerable<IComponentDetector>>(inputDetectors => registeredDetectors.Intersect(inputDetectors).Count() == registeredDetectors.Count())))
It.Is<IEnumerable<IComponentDetector>>(inputDetectors => registeredDetectors.Intersect(inputDetectors).Count() == registeredDetectors.Length)))
.Returns(restrictedDetectors);

// We initialize detected component's DetectedBy here because of a Moq constraint -- certain operations (Adding interfaces) have to happen before .Object
Expand All @@ -654,7 +654,7 @@ private ScanResult SetupRecorderBasedScanning(
detectorProcessingServiceMock.Setup(x =>
x.ProcessDetectorsAsync(
args,
It.Is<IEnumerable<IComponentDetector>>(inputDetectors => restrictedDetectors.Intersect(inputDetectors).Count() == restrictedDetectors.Count()),
It.Is<IEnumerable<IComponentDetector>>(inputDetectors => restrictedDetectors.Intersect(inputDetectors).Count() == restrictedDetectors.Length),
Match.Create<DetectorRestrictions>(restriction => true)))
.ReturnsAsync(processingResult);

Expand Down