1
0
mirror of https://github.com/securego/gosec.git synced 2025-05-29 22:47:40 +02:00

Comment the reason why the file can be nil when an issue is created

Change-Id: I85295a33f540255f4904e663144b959877d0c38a
Signed-off-by: Cosmin Cojocar <ccojocar@google.com>
This commit is contained in:
Cosmin Cojocar 2025-04-08 16:13:09 +00:00 committed by Cosmin Cojocar
parent 700e9a9d18
commit 2aaa9c41d6

View File

@ -62,6 +62,7 @@ func newIssue(analyzerID string, desc string, fileSet *token.FileSet,
pos token.Pos, severity, confidence issue.Score,
) *issue.Issue {
file := fileSet.File(pos)
// This can occur when there is a compilation issue into the code.
if file == nil {
return &issue.Issue{}
}