Simplify now we've deleted withInheritedProgress
This commit is contained in:
28
.github/codeql/queries/ProgressBar.qll
vendored
28
.github/codeql/queries/ProgressBar.qll
vendored
@@ -1,36 +1,16 @@
|
||||
import javascript
|
||||
|
||||
abstract class ProgressBar extends CallExpr {
|
||||
ProgressBar() { any() }
|
||||
|
||||
abstract Function getCallback();
|
||||
|
||||
abstract ObjectExpr getOptions();
|
||||
class WithProgressCall extends CallExpr {
|
||||
WithProgressCall() { this.getCalleeName() = "withProgress" }
|
||||
|
||||
predicate usesToken() { exists(this.getTokenParameter()) }
|
||||
|
||||
Parameter getTokenParameter() { result = this.getCallback().getParameter(1) }
|
||||
Parameter getTokenParameter() { result = this.getArgument(0).(Function).getParameter(1) }
|
||||
|
||||
Property getCancellableProperty() { result = this.getOptions().getPropertyByName("cancellable") }
|
||||
Property getCancellableProperty() { result = this.getArgument(1).(ObjectExpr).getPropertyByName("cancellable") }
|
||||
|
||||
predicate isCancellable() {
|
||||
this.getCancellableProperty().getInit().(BooleanLiteral).getBoolValue() =
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
class WithProgressCall extends ProgressBar {
|
||||
WithProgressCall() { this.getCalleeName() = "withProgress" }
|
||||
|
||||
override Function getCallback() { result = this.getArgument(0) }
|
||||
|
||||
override ObjectExpr getOptions() { result = this.getArgument(1) }
|
||||
}
|
||||
|
||||
class WithInheritedProgressCall extends ProgressBar {
|
||||
WithInheritedProgressCall() { this.getCalleeName() = "withInheritedProgress" }
|
||||
|
||||
override Function getCallback() { result = this.getArgument(1) }
|
||||
|
||||
override ObjectExpr getOptions() { result = this.getArgument(2) }
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import javascript
|
||||
import ProgressBar
|
||||
|
||||
from ProgressBar t
|
||||
from WithProgressCall t
|
||||
where not t.isCancellable() and t.usesToken()
|
||||
select t,
|
||||
"The $@ should not be used when the progress bar is not cancellable. Either stop using the $@ or mark the progress bar as cancellable.",
|
||||
|
||||
2
.github/codeql/queries/token-not-used.ql
vendored
2
.github/codeql/queries/token-not-used.ql
vendored
@@ -13,6 +13,6 @@
|
||||
import javascript
|
||||
import ProgressBar
|
||||
|
||||
from ProgressBar t
|
||||
from WithProgressCall t
|
||||
where t.isCancellable() and not t.usesToken()
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user