Skip to content

Commit

Permalink
fix: handle no matches
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Apr 4, 2024
1 parent bd0a0d2 commit 6ed15a3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/check/occurrence.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (o Occurrence) Run(blk nlp.Block, _ *core.File) ([]core.Alert, error) {
Check: o.Name, Severity: o.Level, Span: []int{1, 1},
Link: o.Link}
} else {
span := locs[0]
span := []int{}

// We look for the first non-code match.
//
Expand All @@ -91,6 +91,13 @@ func (o Occurrence) Run(blk nlp.Block, _ *core.File) ([]core.Alert, error) {
}
}

// If we can't find a non-code match, we return early.
//
// The alternative here is to use `scope: raw`.
if len(span) == 0 {
return alerts, nil
}

a, err = makeAlert(o.Definition, span, txt)
if err != nil {
return alerts, err
Expand Down

0 comments on commit 6ed15a3

Please sign in to comment.