@@ -42,34 +42,35 @@ private string getAMentionedNonParameter(Predicate p) {
42
42
) and
43
43
result .regexpMatch ( "^[a-z]\\w+$" ) and
44
44
not result .toLowerCase ( ) = getAParameterName ( p ) .toLowerCase ( ) and
45
- not result = [ "true" , "false" , "NaN" ] and // keywords
46
- not result .regexpMatch ( "\\d+" ) and // numbers
45
+ not result = [ "true" , "false" , "NaN" , "this" ] and // keywords
46
+ not result = getMentionedPredicates ( p .getLocation ( ) .getFile ( ) ) and
47
+ // variables inside the predicate are also fine
48
+ not result = any ( VarDecl var | var .getEnclosingPredicate ( ) = p ) .getName ( )
49
+ }
50
+
51
+ /** Gets the names of all predicates that are mentioned in `file`. */
52
+ pragma [ noinline]
53
+ private string getMentionedPredicates ( File file ) {
47
54
// predicates get mentioned all the time, it's fine.
48
- not result =
49
- any ( Predicate pred | pred .getLocation ( ) .getFile ( ) = p .getLocation ( ) .getFile ( ) ) .getName ( ) and
50
- // classes get mentioned all the time, it's fine.
51
- not result =
52
- any ( TypeExpr t | t .getLocation ( ) .getFile ( ) = p .getLocation ( ) .getFile ( ) )
53
- .getResolvedType ( )
54
- .getName ( )
55
+ result = any ( Predicate pred | pred .getLocation ( ) .getFile ( ) = file ) .getName ( ) or
56
+ result = any ( Call c | c .getLocation ( ) .getFile ( ) = file ) .getTarget ( ) .getName ( )
55
57
}
56
58
57
59
/** Gets a parameter name from `p` that is not mentioned in the qldoc. */
58
60
private string getAnUndocumentedParameter ( Predicate p ) {
59
61
result = getAParameterName ( p ) and
60
62
not result .toLowerCase ( ) = getADocumentedParameter ( p ) .toLowerCase ( ) and
61
- not result = [ "config" , "conf" , "cfg" ] // DataFlow configurations are often undocumented, and that's fine.
62
- }
63
-
64
- /** Holds if `p` has documented parameters, but `param` is undocumented */
65
- private predicate missingDocumentation ( Predicate p , string param ) {
66
- param = getAnUndocumentedParameter ( p ) and
67
- exists ( getADocumentedParameter ( p ) )
63
+ not result = [ "config" , "conf" , "cfg" ] and // DataFlow configurations are often undocumented, and that's fine.
64
+ not (
65
+ // "the given" often refers to the first parameter.
66
+ p .getQLDoc ( ) .getContents ( ) .regexpMatch ( "(?s).*\\bthe given\\b.*" ) and
67
+ result = p .getParameter ( 0 ) .getName ( )
68
+ )
68
69
}
69
70
70
71
/** Gets the one string containing the undocumented parameters from `p` */
71
72
private string getUndocumentedParameters ( Predicate p ) {
72
- result = strictconcat ( string param | missingDocumentation ( p , param ) | param , ", or " )
73
+ result = strictconcat ( string param | param = getAnUndocumentedParameter ( p ) | param , ", or " )
73
74
}
74
75
75
76
/** Gets the parameter-like names mentioned in the QLDoc of `p` that are not parameters. */
@@ -78,6 +79,7 @@ private string getMentionedNonParameters(Predicate p) {
78
79
}
79
80
80
81
from Predicate p
82
+ where not p .getLocation ( ) .getFile ( ) .getBaseName ( ) = "Aliases.qll" // these are OK
81
83
select p ,
82
84
"The QLDoc has no documentation for " + getUndocumentedParameters ( p ) + ", but the QLDoc mentions "
83
85
+ getMentionedNonParameters ( p )
0 commit comments