Skip to content

Commit d5ab119

Browse files
committed
actually count the number of chars
1 parent 83ecc06 commit d5ab119

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/FunctionBodyFeatures.qll

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,27 @@ ASTNode getAnASTNodeWithAFeature(Function f) {
128128
}
129129

130130
int getNumCharsInFunction(Function f) {
131-
result = strictsum(int i |
132-
exists(ASTNode node | node = getAnASTNodeWithAFeature(f) and i = getTokenizedAstNode(node).length()) |
133-
i
134-
)
131+
result =
132+
strictsum(ASTNode node | node = getAnASTNodeWithAFeature(f) | getTokenizedAstNode(node).length())
135133
}
136134

137135
// Evaluator string limit is 5395415 characters. We choose a limit lower than this.
138136
private int getMaxChars() { result = 1000000 }
139137

140138
Function getFeaturizableFunction(Function f) {
141-
result = f and getNumCharsInFunction(f) <= getMaxChars()
139+
result = f and getNumCharsInFunction(f) <= getMaxChars()
142140
}
143141

144142
/**
145143
* Returns a featurized representation of the function that can be used to populate the
146144
* `enclosingFunctionBody` feature for an endpoint.
147145
*/
148146
string getBodyTokensFeature(Function function) {
149-
// Performance optimization: If a function has more than getMaxChars() characters in its body subtokens,
147+
// Performance optimization: If a function has more than getMaxChars() characters in its body subtokens,
150148
// then featurize it as absent.
151149
function = getFeaturizableFunction(function) and
152-
result = strictconcat(Location l, string token |
150+
result =
151+
strictconcat(Location l, string token |
153152
// The use of a nested exists here allows us to avoid duplicates due to two AST nodes in the
154153
// same location featurizing to the same token. By using a nested exists, we take only unique
155154
// (location, token) pairs.

0 commit comments

Comments
 (0)