CodeQL library for Swift
codeql/swift-all 5.0.10-dev (changelog, source)
Search

Predicate restrictAlertsToExactLocation

Holds if the query may restrict its computation to only produce alerts that match the given character ranges. This predicate is suitable for testing, where we want to distinguish between alerts on the same line.

This predicate is active if and only if it is nonempty. If this predicate is inactive, it has no effect. If it is active, queries may omit alerts that don’t have a matching (see below) primary or related location (in SARIF terminology). Queries are still allowed to produce alerts that have no matching locations, but they are not required to do so.

An alert location is a match if it matches a row in this predicate. Each row specifies a character-range match, and a location is a match if its file path matches filePath, and its character range wholly contains the character range from startColumn on startLine to endColumn on endLine (inclusive).

  • filePath: alert location file path (absolute).
  • startLine: inclusive start line of the character range (1-based).
  • startColumn: inclusive start column of the character range (1-based).
  • endLine: inclusive end line of the character range (1-based).
  • endColumn: inclusive end column of the character range (1-based).

Note that even if an alert has no matching locations for this filtering predicate, it could still have matching locations for other filtering predicates in this module. In that case, queries must still produce such an alert. An alert can be omitted only if (1) there is at least one active filtering predicate, and (2) it has no matching locations for any active filtering predicate.

See also: restrictAlertsTo.

Import path

import codeql.util.AlertFiltering
predicate restrictAlertsToExactLocation(string filePath, int startLine, int startColumn, int endLine, int endColumn)