File tree Expand file tree Collapse file tree 6 files changed +11
-20
lines changed
javascript/ql/src/semmle/javascript Expand file tree Collapse file tree 6 files changed +11
-20
lines changed Original file line number Diff line number Diff line change @@ -259,8 +259,7 @@ private class AmdDependencyImport extends Import {
259
259
* Gets the module whose absolute path matches this import, if there is only a single such module.
260
260
*/
261
261
private Module resolveByAbsolutePath ( ) {
262
- count ( guessTarget ( ) ) = 1 and
263
- result .getFile ( ) = guessTarget ( )
262
+ result .getFile ( ) = unique( File file | file = guessTarget ( ) )
264
263
}
265
264
266
265
override Module getImportedModule ( ) {
@@ -291,7 +290,7 @@ private class AmdDependencyImport extends Import {
291
290
*/
292
291
class AmdModule extends Module {
293
292
cached
294
- AmdModule ( ) { strictcount ( AmdModuleDefinition def | amdModuleTopLevel ( def , this ) ) = 1 }
293
+ AmdModule ( ) { exists ( unique ( AmdModuleDefinition def | amdModuleTopLevel ( def , this ) ) ) }
295
294
296
295
/** Gets the definition of this module. */
297
296
AmdModuleDefinition getDefine ( ) { amdModuleTopLevel ( result , this ) }
Original file line number Diff line number Diff line change @@ -66,10 +66,8 @@ module InclusionTest {
66
66
Function callee ;
67
67
68
68
IndirectInclusionTest ( ) {
69
- inner .getEnclosingExpr ( ) = callee .getAReturnedExpr ( ) and
70
- this .getACallee ( ) = callee and
71
- count ( this .getACallee ( ) ) = 1 and
72
- count ( callee .getAReturnedExpr ( ) ) = 1 and
69
+ inner .getEnclosingExpr ( ) = unique( Expr ret | ret = callee .getAReturnedExpr ( ) ) and
70
+ callee = unique( Function f | f = this .getACallee ( ) ) and
73
71
not this .isImprecise ( ) and
74
72
inner .getContainedNode ( ) .getALocalSource ( ) = DataFlow:: parameterNode ( callee .getAParameter ( ) ) and
75
73
inner .getContainerNode ( ) .getALocalSource ( ) = DataFlow:: parameterNode ( callee .getAParameter ( ) )
Original file line number Diff line number Diff line change @@ -64,10 +64,8 @@ module StringOps {
64
64
Function callee ;
65
65
66
66
IndirectStartsWith ( ) {
67
- inner .getEnclosingExpr ( ) = callee .getAReturnedExpr ( ) and
68
- this .getACallee ( ) = callee and
69
- count ( this .getACallee ( ) ) = 1 and
70
- count ( callee .getAReturnedExpr ( ) ) = 1 and
67
+ inner .getEnclosingExpr ( ) = unique( Expr ret | ret = callee .getAReturnedExpr ( ) ) and
68
+ callee = unique( Function f | f = this .getACallee ( ) ) and
71
69
not this .isImprecise ( ) and
72
70
inner .getBaseString ( ) .getALocalSource ( ) .getEnclosingExpr ( ) = callee .getAParameter ( ) and
73
71
inner .getSubstring ( ) .getALocalSource ( ) .getEnclosingExpr ( ) = callee .getAParameter ( )
@@ -295,10 +293,8 @@ module StringOps {
295
293
Function callee ;
296
294
297
295
IndirectEndsWith ( ) {
298
- inner .getEnclosingExpr ( ) = callee .getAReturnedExpr ( ) and
299
- this .getACallee ( ) = callee and
300
- count ( this .getACallee ( ) ) = 1 and
301
- count ( callee .getAReturnedExpr ( ) ) = 1 and
296
+ inner .getEnclosingExpr ( ) = unique( Expr ret | ret = callee .getAReturnedExpr ( ) ) and
297
+ callee = unique( Function f | f = this .getACallee ( ) ) and
302
298
not this .isImprecise ( ) and
303
299
inner .getBaseString ( ) .getALocalSource ( ) .getEnclosingExpr ( ) = callee .getAParameter ( ) and
304
300
inner .getSubstring ( ) .getALocalSource ( ) .getEnclosingExpr ( ) = callee .getAParameter ( )
Original file line number Diff line number Diff line change @@ -218,8 +218,7 @@ module DataFlow {
218
218
// IIFE call -> return value of IIFE
219
219
exists ( Function fun |
220
220
localCall ( this .asExpr ( ) , fun ) and
221
- result = fun .getAReturnedExpr ( ) .flow ( ) and
222
- strictcount ( fun .getAReturnedExpr ( ) ) = 1 and
221
+ result = unique( Expr ret | ret = fun .getAReturnedExpr ( ) ) .flow ( ) and
223
222
not fun .getExit ( ) .isJoin ( ) // can only reach exit by the return statement
224
223
)
225
224
}
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ class AnalyzedNode extends DataFlow::Node {
100
100
boolean getTheBooleanValue ( ) { forex ( boolean bv | bv = getABooleanValue ( ) | result = bv ) }
101
101
102
102
/** Gets the unique type inferred for this node, if any. */
103
- InferredType getTheType ( ) { count ( getAType ( ) ) = 1 and result = getAType ( ) }
103
+ InferredType getTheType ( ) { result = unique ( InferredType t | t = getAType ( ) ) }
104
104
105
105
/**
106
106
* Gets a pretty-printed representation of all types inferred for this node
Original file line number Diff line number Diff line change @@ -187,8 +187,7 @@ private class IIFEWithAnalyzedReturnFlow extends CallWithAnalyzedReturnFlow {
187
187
*/
188
188
private VarAccess getOnlyAccess ( FunctionDeclStmt fn , LocalVariable v ) {
189
189
v = fn .getVariable ( ) and
190
- result = v .getAnAccess ( ) and
191
- strictcount ( v .getAnAccess ( ) ) = 1
190
+ result = unique( VarAccess acc | acc = v .getAnAccess ( ) )
192
191
}
193
192
194
193
/** A function that only is used locally, making it amenable to type inference. */
You can’t perform that action at this time.
0 commit comments