From e167554ad9f4b36975df86064b933a6a2c421232 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Thu, 14 Oct 2021 11:12:22 +0200 Subject: [PATCH 1/2] QL: add query to detect uses of getAQlClass --- .../queries/performance/DontUseGetAQlClass.ql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ql/src/queries/performance/DontUseGetAQlClass.ql diff --git a/ql/src/queries/performance/DontUseGetAQlClass.ql b/ql/src/queries/performance/DontUseGetAQlClass.ql new file mode 100644 index 00000000000..529a9263eec --- /dev/null +++ b/ql/src/queries/performance/DontUseGetAQlClass.ql @@ -0,0 +1,22 @@ +/** + * @name Don't use getAQlClass. + * @description Any use of getAQlClass causes both compile-time and runtime to be significantly slower. + * @kind problem + * @problem.severity warning + * @id ql/dont-use-getAQlClass + * @tags performance + * @precision very-high + */ + +import ql + +from Call call +where + ( + call.(PredicateCall).getPredicateName() = "getAQlClass" or + call.(MemberCall).getMemberName() = "getAQlClass" + ) and + not call.getLocation().getFile().getAbsolutePath().matches("%/" + ["meta", "test"] + "/%") and + not call.getLocation().getFile().getBaseName().toLowerCase() = + ["consistency.ql", "test.ql", "tst.ql", "tests.ql"] +select call, "Don't use .getAQlClass" From 5fc1b8bb29db9d563a6da37c3e7d90a7cf4e1fc2 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Thu, 14 Oct 2021 12:53:09 +0200 Subject: [PATCH 2/2] QL: lowercase query id --- ql/src/queries/performance/DontUseGetAQlClass.ql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/src/queries/performance/DontUseGetAQlClass.ql b/ql/src/queries/performance/DontUseGetAQlClass.ql index 529a9263eec..adbcb0baccc 100644 --- a/ql/src/queries/performance/DontUseGetAQlClass.ql +++ b/ql/src/queries/performance/DontUseGetAQlClass.ql @@ -3,7 +3,7 @@ * @description Any use of getAQlClass causes both compile-time and runtime to be significantly slower. * @kind problem * @problem.severity warning - * @id ql/dont-use-getAQlClass + * @id ql/dont-use-getaqlclass * @tags performance * @precision very-high */