Skip to content
Merged
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
6 changes: 3 additions & 3 deletions Analyzers/Analyzers/SecureIO/FileOperationAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private static IEnumerable<ArgumentSyntax> GetPathArgumentsFromObjectCreation(
var objectCreationWitinVariableDeclarator = variableDeclaratorMatchingMemberAccess
.DescendantNodes(descendIntoChildren: node => node.ChildNodes().Any())
.OfType<ObjectCreationExpressionSyntax>()
.First();
.FirstOrDefault();

if (objectCreationWitinVariableDeclarator is null)
{
Expand Down Expand Up @@ -443,13 +443,13 @@ private static List<LocationToAnalyze> GetFileOperationLocationsToAnalyze(
// Cases where the path argument was not added to the locations to analyze => assume the first position of the block
if (!locationsToAnalyze.Exists(locationToAnalyze => locationToAnalyze.PathArgumentName == pathArgumentName))
{
var firstPosition = descendantNodes.First();
var firstPosition = descendantNodes.FirstOrDefault();
if (firstPosition == null)
{
continue;
}

locationsToAnalyze.Add(new LocationToAnalyze(descendantNodes.First().GetLocation(), pathArgumentName));
locationsToAnalyze.Add(new LocationToAnalyze(firstPosition.GetLocation(), pathArgumentName));
}
}

Expand Down