@@ -79,14 +79,27 @@ module AlertFilteringImpl<LocationSig Location> {
79
79
private predicate restrictAlertsToEntireFile ( string filePath ) { restrictAlertsTo ( filePath , 0 , 0 ) }
80
80
81
81
pragma [ nomagic]
82
- private predicate restrictAlertsToStartLine ( string filePath , int line ) {
82
+ private predicate restrictAlertsToLine ( string filePath , int line ) {
83
83
exists ( int startLineStart , int startLineEnd |
84
84
restrictAlertsTo ( filePath , startLineStart , startLineEnd ) and
85
85
line = [ startLineStart .. startLineEnd ]
86
86
)
87
87
}
88
88
89
- /** Applies alert filtering to the given location. */
89
+ /**
90
+ * Holds if the given location intersects the diff range. Testing for full
91
+ * intersection rather than only matching the start line means that this
92
+ * predicate is more broadly useful than just checking whether a specific
93
+ * element is considered to be in the diff range of GitHub Code Scanning:
94
+ * - If it's inconvenient to pass the exact `Location` of the element of
95
+ * interest, it's valid to use a `Location` of an enclosing element.
96
+ * - This predicate could be useful for other systems of alert presentation
97
+ * where the rules don't exactly match GitHub Code Scanning.
98
+ *
99
+ * If there is no diff range, this predicate holds for all locations. Note
100
+ * that this predicate has a bindingset and will therefore be inlined;
101
+ * callers should include enough context to ensure efficient evaluation.
102
+ */
90
103
bindingset [ location]
91
104
predicate filterByLocation ( Location location ) {
92
105
not restrictAlertsTo ( _, _, _) and not restrictAlertsToExactLocation ( _, _, _, _, _)
@@ -98,7 +111,7 @@ module AlertFilteringImpl<LocationSig Location> {
98
111
exists ( int locStartLine , int locEndLine |
99
112
location .hasLocationInfo ( filePath , locStartLine , _, locEndLine , _)
100
113
|
101
- restrictAlertsToStartLine ( pragma [ only_bind_into ] ( filePath ) , [ locStartLine .. locEndLine ] )
114
+ restrictAlertsToLine ( pragma [ only_bind_into ] ( filePath ) , [ locStartLine .. locEndLine ] )
102
115
)
103
116
)
104
117
or
0 commit comments