Skip to content

Commit d65e6be

Browse files
Simplify now we've deleted withInheritedProgress
1 parent 115ff83 commit d65e6be

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed
+4-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
11
import javascript
22

3-
abstract class ProgressBar extends CallExpr {
4-
ProgressBar() { any() }
5-
6-
abstract Function getCallback();
7-
8-
abstract ObjectExpr getOptions();
3+
class WithProgressCall extends CallExpr {
4+
WithProgressCall() { this.getCalleeName() = "withProgress" }
95

106
predicate usesToken() { exists(this.getTokenParameter()) }
117

12-
Parameter getTokenParameter() { result = this.getCallback().getParameter(1) }
8+
Parameter getTokenParameter() { result = this.getArgument(0).(Function).getParameter(1) }
139

14-
Property getCancellableProperty() { result = this.getOptions().getPropertyByName("cancellable") }
10+
Property getCancellableProperty() { result = this.getArgument(1).(ObjectExpr).getPropertyByName("cancellable") }
1511

1612
predicate isCancellable() {
1713
this.getCancellableProperty().getInit().(BooleanLiteral).getBoolValue() =
1814
true
1915
}
2016
}
21-
22-
class WithProgressCall extends ProgressBar {
23-
WithProgressCall() { this.getCalleeName() = "withProgress" }
24-
25-
override Function getCallback() { result = this.getArgument(0) }
26-
27-
override ObjectExpr getOptions() { result = this.getArgument(1) }
28-
}
29-
30-
class WithInheritedProgressCall extends ProgressBar {
31-
WithInheritedProgressCall() { this.getCalleeName() = "withInheritedProgress" }
32-
33-
override Function getCallback() { result = this.getArgument(1) }
34-
35-
override ObjectExpr getOptions() { result = this.getArgument(2) }
36-
}

.github/codeql/queries/progress-not-cancellable.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import javascript
1313
import ProgressBar
1414

15-
from ProgressBar t
15+
from WithProgressCall t
1616
where not t.isCancellable() and t.usesToken()
1717
select t,
1818
"The $@ should not be used when the progress bar is not cancellable. Either stop using the $@ or mark the progress bar as cancellable.",

.github/codeql/queries/token-not-used.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
import javascript
1414
import ProgressBar
1515

16-
from ProgressBar t
16+
from WithProgressCall t
1717
where t.isCancellable() and not t.usesToken()
1818
select t, "This progress bar is $@ but the token is not used. Either use the token or mark the progress bar as not cancellable.", t.getCancellableProperty(), "cancellable"

0 commit comments

Comments
 (0)