@@ -102,11 +102,11 @@ String shouldStartCapital(Select sel) {
102
102
* select foo(), "XSS from using a unsafe value." // <- good
103
103
* ```
104
104
*/
105
- String avoidHere ( string part ) {
105
+ String avoidHere ( Select sel , string part ) {
106
106
part = [ "here" , "this location" ] and
107
107
(
108
108
result .getValue ( ) .regexpMatch ( ".*\\b" + part + "\\b.*" ) and
109
- result = getSelectPart ( _ , _)
109
+ result = getSelectPart ( sel , _)
110
110
)
111
111
}
112
112
@@ -184,17 +184,18 @@ String doubleWhitespace(Select sel) {
184
184
result .getValue ( ) .regexpMatch ( ".*\\s\\s.*" )
185
185
}
186
186
187
- from AstNode node , string msg
187
+ from AstNode node , string msg , Select sel
188
188
where
189
189
not node .getLocation ( ) .getFile ( ) .getAbsolutePath ( ) .matches ( "%/test/%" ) and
190
+ sel .getQueryDoc ( ) .getQueryKind ( ) = [ "problem" , "path-problem" ] and
190
191
(
191
- node = shouldHaveFullStop ( _ ) and
192
+ node = shouldHaveFullStop ( sel ) and
192
193
msg = "Alert message should end with a full stop."
193
194
or
194
- node = shouldStartCapital ( _ ) and
195
+ node = shouldStartCapital ( sel ) and
195
196
msg = "Alert message should start with a capital letter."
196
197
or
197
- exists ( string part | node = avoidHere ( part ) |
198
+ exists ( string part | node = avoidHere ( sel , part ) |
198
199
part = "here" and
199
200
msg =
200
201
"Try to use a descriptive phrase instead of \"here\". Use \"this location\" if you can't get around mentioning the current location."
@@ -203,19 +204,19 @@ where
203
204
msg = "Try to more descriptive phrase instead of \"this location\" if possible."
204
205
)
205
206
or
206
- node = avoidArticleInLinkText ( _ ) and
207
+ node = avoidArticleInLinkText ( sel ) and
207
208
msg = "Avoid starting a link text with an indefinite article."
208
209
or
209
- node = dontQuoteSubstitutions ( _ ) and
210
+ node = dontQuoteSubstitutions ( sel ) and
210
211
msg = "Don't quote substitutions in alert messages."
211
212
or
212
- node = wrongFlowsPhrase ( _ , "data" ) and
213
+ node = wrongFlowsPhrase ( sel , "data" ) and
213
214
msg = "Use \"flows to\" instead of \"depends on\" in data flow queries."
214
215
or
215
- node = wrongFlowsPhrase ( _ , "taint" ) and
216
+ node = wrongFlowsPhrase ( sel , "taint" ) and
216
217
msg = "Use \"depends on\" instead of \"flows to\" in taint tracking queries."
217
218
or
218
- node = doubleWhitespace ( _ ) and
219
+ node = doubleWhitespace ( sel ) and
219
220
msg = "Avoid using double whitespace in alert messages."
220
221
)
221
222
select node , msg
0 commit comments