@@ -102,11 +102,11 @@ String shouldStartCapital(Select sel) {
102102 * select foo(), "XSS from using a unsafe value." // <- good
103103 * ```
104104 */
105- String avoidHere ( string part ) {
105+ String avoidHere ( Select sel , string part ) {
106106 part = [ "here" , "this location" ] and
107107 (
108108 result .getValue ( ) .regexpMatch ( ".*\\b" + part + "\\b.*" ) and
109- result = getSelectPart ( _ , _)
109+ result = getSelectPart ( sel , _)
110110 )
111111}
112112
@@ -184,17 +184,18 @@ String doubleWhitespace(Select sel) {
184184 result .getValue ( ) .regexpMatch ( ".*\\s\\s.*" )
185185}
186186
187- from AstNode node , string msg
187+ from AstNode node , string msg , Select sel
188188where
189189 not node .getLocation ( ) .getFile ( ) .getAbsolutePath ( ) .matches ( "%/test/%" ) and
190+ sel .getQueryDoc ( ) .getQueryKind ( ) = [ "problem" , "path-problem" ] and
190191 (
191- node = shouldHaveFullStop ( _ ) and
192+ node = shouldHaveFullStop ( sel ) and
192193 msg = "Alert message should end with a full stop."
193194 or
194- node = shouldStartCapital ( _ ) and
195+ node = shouldStartCapital ( sel ) and
195196 msg = "Alert message should start with a capital letter."
196197 or
197- exists ( string part | node = avoidHere ( part ) |
198+ exists ( string part | node = avoidHere ( sel , part ) |
198199 part = "here" and
199200 msg =
200201 "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
203204 msg = "Try to more descriptive phrase instead of \"this location\" if possible."
204205 )
205206 or
206- node = avoidArticleInLinkText ( _ ) and
207+ node = avoidArticleInLinkText ( sel ) and
207208 msg = "Avoid starting a link text with an indefinite article."
208209 or
209- node = dontQuoteSubstitutions ( _ ) and
210+ node = dontQuoteSubstitutions ( sel ) and
210211 msg = "Don't quote substitutions in alert messages."
211212 or
212- node = wrongFlowsPhrase ( _ , "data" ) and
213+ node = wrongFlowsPhrase ( sel , "data" ) and
213214 msg = "Use \"flows to\" instead of \"depends on\" in data flow queries."
214215 or
215- node = wrongFlowsPhrase ( _ , "taint" ) and
216+ node = wrongFlowsPhrase ( sel , "taint" ) and
216217 msg = "Use \"depends on\" instead of \"flows to\" in taint tracking queries."
217218 or
218- node = doubleWhitespace ( _ ) and
219+ node = doubleWhitespace ( sel ) and
219220 msg = "Avoid using double whitespace in alert messages."
220221 )
221222select node , msg
0 commit comments