CodeQL library for Ruby
codeql/ruby-all 4.1.0 (changelog, source)
Search

Predicate restrictAlertsTo

Holds if the query should produce alerts that match the given line ranges.

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. If startLineStart and startLineEnd are both 0, the row specifies a whole-file match, and a location is a match if its file path matches filePath. Otherwise, the row specifies a line-range match, and a location is a match if its file path matches filePath, and its start line is between startLineStart and startLineEnd, inclusive. (Note that only start line of the location is used for matching because an alert is displayed on the first line of its location.)

  • filePath: alert location file path (absolute).
  • startLineStart: inclusive start of the range for alert location start line number (1-based).
  • startLineEnd: inclusive end of the range for alert location start line 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 alerts at line granularity, such as based on the pull request diff.

See also: restrictAlertsToExactLocation.

Import path

import codeql.util.AlertFiltering
predicate restrictAlertsTo(string filePath, int startLineStart, int startLineEnd)