Skip to content

Commit a570a72

Browse files
committed
Fix code quality
1 parent 398f041 commit a570a72

File tree

1 file changed

+17
-11
lines changed
  • csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore

1 file changed

+17
-11
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore/Components.qll

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,16 @@ private predicate matchingOpenCloseComponentCalls(
195195
openCall.getEnclosingCallable() = enclosing and
196196
closeCall.getTarget() instanceof MicrosoftAspNetCoreComponentsCloseComponentMethod and
197197
closeCall.getEnclosingCallable() = enclosing and
198-
closeCall.getParent().getParent() = openCall.getParent().getParent() and
199-
openCall.getParent().getIndex() = openCallIndex and
200-
closeCallIndex =
201-
min(int closeCallIndex0 |
202-
closeCall.getParent().getIndex() = closeCallIndex0 and
203-
closeCallIndex0 > openCallIndex
204-
)
198+
exists(BlockStmt block |
199+
block = closeCall.getParent().getParent() and
200+
block = openCall.getParent().getParent() and
201+
block.getChildStmt(openCallIndex) = openCall.getParent() and
202+
closeCallIndex =
203+
min(int closeCallIndex0 |
204+
block.getChildStmt(closeCallIndex0) = closeCall.getParent() and
205+
closeCallIndex0 > openCallIndex
206+
)
207+
)
205208
}
206209

207210
private module JumpNodes {
@@ -223,14 +226,17 @@ private module JumpNodes {
223226
exists(NameOfExpr ne | ne = this.getArgument(1) | result.getAnAccess() = ne.getAccess())
224227
or
225228
exists(
226-
string propertyName, MethodCall openComponent, int i, MethodCall closeComponent, int j
229+
string propertyName, MethodCall openComponent, BlockStmt block, int openIdx, int closeIdx,
230+
int thisIdx
227231
|
228232
propertyName = this.getArgument(1).(StringLiteral).getValue() and
229233
result.hasName(propertyName) and
230-
matchingOpenCloseComponentCalls(openComponent, i, closeComponent, j,
234+
matchingOpenCloseComponentCalls(openComponent, openIdx, _, closeIdx,
231235
this.getEnclosingCallable(), result.getDeclaringType()) and
232-
this.getParent().getParent() = openComponent.getParent().getParent() and
233-
this.getParent().getIndex() in [i + 1 .. j - 1]
236+
block = this.getParent().getParent() and
237+
block = openComponent.getParent().getParent() and
238+
block.getChildStmt(thisIdx) = this.getParent() and
239+
thisIdx in [openIdx + 1 .. closeIdx - 1]
234240
)
235241
)
236242
}

0 commit comments

Comments
 (0)