From fffb0349a65d029613daf7fd930ea21c57a72c59 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 14 Mar 2024 13:33:06 +0000 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Koen Vlaswinkel --- .github/codeql/queries/ProgressBar.qll | 4 +++- .github/codeql/queries/progress-not-cancellable.ql | 5 ++++- .github/codeql/queries/token-not-used.ql | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/codeql/queries/ProgressBar.qll b/.github/codeql/queries/ProgressBar.qll index 042f15208..d9e0d04c0 100644 --- a/.github/codeql/queries/ProgressBar.qll +++ b/.github/codeql/queries/ProgressBar.qll @@ -7,7 +7,9 @@ abstract class ProgressBar extends CallExpr { abstract ObjectExpr getOptions(); - predicate usesToken() { this.getCallback().getNumParameter() >= 2 } + predicate usesToken() { exists(this.getTokenParameter()) } + + Parameter getTokenParameter() { result = this.getCallback().getParameter(1) } Property getCancellableProperty() { result = this.getOptions().getPropertyByName("cancellable") } diff --git a/.github/codeql/queries/progress-not-cancellable.ql b/.github/codeql/queries/progress-not-cancellable.ql index ae46351ee..2cb1abd4c 100644 --- a/.github/codeql/queries/progress-not-cancellable.ql +++ b/.github/codeql/queries/progress-not-cancellable.ql @@ -14,4 +14,7 @@ import ProgressBar from ProgressBar t where not t.isCancellable() and t.usesToken() -select t, "The token should not be used when the progress bar is not cancelable. Either stop using the token or mark the progress bar as cancellable." +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.", + t.getTokenParameter(), t.getTokenParameter().getName(), t.getTokenParameter(), + t.getTokenParameter().getName() diff --git a/.github/codeql/queries/token-not-used.ql b/.github/codeql/queries/token-not-used.ql index ffea53e63..66d153bec 100644 --- a/.github/codeql/queries/token-not-used.ql +++ b/.github/codeql/queries/token-not-used.ql @@ -1,5 +1,5 @@ /** - * @name Don't ignore the token for a cancelable progress bar + * @name Don't ignore the token for a cancellable progress bar * @kind problem * @problem.severity warning * @id vscode-codeql/token-not-used