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

Predicate AlertFilteringImpl::filterByLocation

Holds if the given location intersects the diff range. When that is the case, ensuring that alerts mentioning this location are included in the query results is a valid overapproximation of the requirements for diff-informed queries as documented under restrictAlertsTo.

Testing for full intersection rather than only matching the start line means that this predicate is more broadly useful than just checking whether a specific element is considered to be in the diff range of GitHub Code Scanning:

  • If it’s inconvenient to pass the exact Location of the element of interest, it’s valid to use a Location of an enclosing element.
  • This predicate could be useful for other systems of alert presentation where the rules don’t exactly match GitHub Code Scanning.

If there is no diff range, this predicate holds for all locations. Note that this predicate has a bindingset and will therefore be inlined; callers should include enough context to ensure efficient evaluation.

Import path

import codeql.util.AlertFiltering
predicate filterByLocation(Location location)