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

Predicate restrictAlertsToExactLocation

Holds if the query should produce alerts that match the given locations.

This predicate is active if and only if it is nonempty. If this predicate is inactive, it has no effect. If it is active, it accepts any alert that has at least one matching location.

Note that an alert that is not accepted by this filtering predicate may still be included in the query results if it is accepted by another active filtering predicate in this module. An alert is excluded from the query results if only if (1) there is at least one active filtering predicate, and (2) it is not accepted by any active filtering predicate.

An alert location is a match if it matches a row in this predicate. Each row specifies an exact location: an alert location is a match if its file path matches filePath, its start line and column match startLine and startColumn, and its end line and column match endLine and endColumn.

  • filePath: alert location file path (absolute).
  • startLine: alert location start line number (1-based).
  • startColumn: alert location start column number (1-based).
  • endLine: alert location end line number (1-based).
  • endColumn: alert location end column number (1-based).

A query should either perform no alert filtering, or adhere to all the filtering rules in this module and return all and only the accepted alerts.

This predicate is suitable for situations where we want to filter by the exact alert location, distinguishing between alerts on the same line.

See also: restrictAlertsTo.

Import path

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