From 063a8bbc43522018301e240a0d867282f61ddadd Mon Sep 17 00:00:00 2001 From: Taus Date: Tue, 8 Mar 2022 15:20:35 +0100 Subject: [PATCH] Python: Apply suggestions from code review Co-authored-by: yoff --- cpp/ql/test/TestUtilities/InlineExpectationsTest.qll | 4 +++- .../ql/test/TestUtilities/InlineExpectationsTest.qll | 4 +++- java/ql/test/TestUtilities/InlineExpectationsTest.qll | 4 +++- .../python/dataflow/new/internal/DataFlowPrivate.qll | 2 +- python/ql/lib/semmle/python/frameworks/Aiomysql.qll | 10 +++++----- python/ql/lib/semmle/python/frameworks/Aiopg.qll | 10 +++++----- python/ql/lib/semmle/python/frameworks/Asyncpg.qll | 4 ++-- python/ql/lib/semmle/python/types/ClassObject.qll | 2 +- python/ql/src/Imports/DeprecatedModule.ql | 5 +---- .../ql/test/TestUtilities/InlineExpectationsTest.qll | 4 +++- .../ql/lib/RecordedCalls.qll | 2 +- ruby/ql/test/TestUtilities/InlineExpectationsTest.qll | 4 +++- 12 files changed, 31 insertions(+), 24 deletions(-) diff --git a/cpp/ql/test/TestUtilities/InlineExpectationsTest.qll b/cpp/ql/test/TestUtilities/InlineExpectationsTest.qll index 7d788b26cbe..a4d264b2703 100644 --- a/cpp/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/cpp/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string { abstract predicate hasActualResult(Location location, string element, string tag, string value); /** - * Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. + * Holds if there is an optional result on the specified location. + * + * This is similar to `hasActualResult`, but returns results that do not require a matching annotation. * A failure will still arise if there is an annotation that does not match any results, but not vice versa. * Override this predicate to specify optional results. */ diff --git a/csharp/ql/test/TestUtilities/InlineExpectationsTest.qll b/csharp/ql/test/TestUtilities/InlineExpectationsTest.qll index 7d788b26cbe..a4d264b2703 100644 --- a/csharp/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/csharp/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string { abstract predicate hasActualResult(Location location, string element, string tag, string value); /** - * Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. + * Holds if there is an optional result on the specified location. + * + * This is similar to `hasActualResult`, but returns results that do not require a matching annotation. * A failure will still arise if there is an annotation that does not match any results, but not vice versa. * Override this predicate to specify optional results. */ diff --git a/java/ql/test/TestUtilities/InlineExpectationsTest.qll b/java/ql/test/TestUtilities/InlineExpectationsTest.qll index 7d788b26cbe..a4d264b2703 100644 --- a/java/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/java/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string { abstract predicate hasActualResult(Location location, string element, string tag, string value); /** - * Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. + * Holds if there is an optional result on the specified location. + * + * This is similar to `hasActualResult`, but returns results that do not require a matching annotation. * A failure will still arise if there is an annotation that does not match any results, but not vice versa. * Override this predicate to specify optional results. */ diff --git a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll index a521c95c8c1..887cedf2e48 100644 --- a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll +++ b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll @@ -1619,7 +1619,7 @@ import IterableUnpacking */ module MatchUnpacking { /** - * Holds when there is flow from the subject `nodeFrom` to the case `nodeTo` of a `match` statement. + * Holds when there is flow from the subject `nodeFrom` to the (top-level) pattern `nodeTo` of a `match` statement. * * The subject of a match flows to each top-level pattern * (a pattern directly under a `case` statement). diff --git a/python/ql/lib/semmle/python/frameworks/Aiomysql.qll b/python/ql/lib/semmle/python/frameworks/Aiomysql.qll index 592397e0431..ae856589528 100644 --- a/python/ql/lib/semmle/python/frameworks/Aiomysql.qll +++ b/python/ql/lib/semmle/python/frameworks/Aiomysql.qll @@ -15,7 +15,7 @@ private module Aiomysql { private import semmle.python.internal.Awaited /** - * Gets the `ConnectionPool` that is created when the result of `aiomysql.create_pool()` is awaited. + * Gets a `ConnectionPool` that is created when the result of `aiomysql.create_pool()` is awaited. * See https://aiomysql.readthedocs.io/en/stable/pool.html */ API::Node connectionPool() { @@ -23,7 +23,7 @@ private module Aiomysql { } /** - * Gets the `Connection` that is created when + * Gets a `Connection` that is created when * - the result of `aiomysql.connect()` is awaited. * - the result of calling `aquire` on a `ConnectionPool` is awaited. * See https://aiomysql.readthedocs.io/en/stable/connection.html#connection @@ -35,7 +35,7 @@ private module Aiomysql { } /** - * Gets the `Cursor` that is created when + * Gets a `Cursor` that is created when * - the result of calling `cursor` on a `ConnectionPool` is awaited. * - the result of calling `cursor` on a `Connection` is awaited. * See https://aiomysql.readthedocs.io/en/stable/cursors.html @@ -85,7 +85,7 @@ private module Aiomysql { } /** - * Gets the `Engine` that is created when the result of calling `aiomysql.sa.create_engine` is awaited. + * Gets an `Engine` that is created when the result of calling `aiomysql.sa.create_engine` is awaited. * See https://aiomysql.readthedocs.io/en/stable/sa.html#engine */ API::Node engine() { @@ -98,7 +98,7 @@ private module Aiomysql { } /** - * Gets the `SAConnection` that is created when the result of calling `aquire` on an `Engine` is awaited. + * Gets an `SAConnection` that is created when the result of calling `aquire` on an `Engine` is awaited. * See https://aiomysql.readthedocs.io/en/stable/sa.html#connection */ API::Node saConnection() { result = engine().getMember("acquire").getReturn().getAwaited() } diff --git a/python/ql/lib/semmle/python/frameworks/Aiopg.qll b/python/ql/lib/semmle/python/frameworks/Aiopg.qll index 83f8a446c7b..6d5937ed789 100644 --- a/python/ql/lib/semmle/python/frameworks/Aiopg.qll +++ b/python/ql/lib/semmle/python/frameworks/Aiopg.qll @@ -15,7 +15,7 @@ private module Aiopg { private import semmle.python.internal.Awaited /** - * Gets the `ConnectionPool` that is created when the result of `aiopg.create_pool()` is awaited. + * Gets a `ConnectionPool` that is created when the result of `aiopg.create_pool()` is awaited. * See https://aiopg.readthedocs.io/en/stable/core.html#pool */ API::Node connectionPool() { @@ -23,7 +23,7 @@ private module Aiopg { } /** - * Gets the `Connection` that is created when + * Gets a `Connection` that is created when * - the result of `aiopg.connect()` is awaited. * - the result of calling `aquire` on a `ConnectionPool` is awaited. * See https://aiopg.readthedocs.io/en/stable/core.html#connection @@ -35,7 +35,7 @@ private module Aiopg { } /** - * Gets the `Cursor` that is created when + * Gets a `Cursor` that is created when * - the result of calling `cursor` on a `ConnectionPool` is awaited. * - the result of calling `cursor` on a `Connection` is awaited. * See https://aiopg.readthedocs.io/en/stable/core.html#cursor @@ -85,7 +85,7 @@ private module Aiopg { } /** - * Gets the `Engine` that is created when the result of calling `aiopg.sa.create_engine` is awaited. + * Gets an `Engine` that is created when the result of calling `aiopg.sa.create_engine` is awaited. * See https://aiopg.readthedocs.io/en/stable/sa.html#engine */ API::Node engine() { @@ -94,7 +94,7 @@ private module Aiopg { } /** - * Gets the `SAConnection` that is created when the result of calling `aquire` on an `Engine` is awaited. + * Gets an `SAConnection` that is created when the result of calling `aquire` on an `Engine` is awaited. * See https://aiopg.readthedocs.io/en/stable/sa.html#connection */ API::Node saConnection() { result = engine().getMember("acquire").getReturn().getAwaited() } diff --git a/python/ql/lib/semmle/python/frameworks/Asyncpg.qll b/python/ql/lib/semmle/python/frameworks/Asyncpg.qll index 20804cdfed7..51034d7d7f2 100644 --- a/python/ql/lib/semmle/python/frameworks/Asyncpg.qll +++ b/python/ql/lib/semmle/python/frameworks/Asyncpg.qll @@ -12,13 +12,13 @@ private import semmle.python.ApiGraphs private module Asyncpg { private import semmle.python.internal.Awaited - /** Gets the `ConnectionPool` that is created when the result of `asyncpg.create_pool()` is awaited. */ + /** Gets a `ConnectionPool` that is created when the result of `asyncpg.create_pool()` is awaited. */ API::Node connectionPool() { result = API::moduleImport("asyncpg").getMember("create_pool").getReturn().getAwaited() } /** - * Gets the `Connection` that is created when + * Gets a `Connection` that is created when * - the result of `asyncpg.connect()` is awaited. * - the result of calling `aquire` on a `ConnectionPool` is awaited. */ diff --git a/python/ql/lib/semmle/python/types/ClassObject.qll b/python/ql/lib/semmle/python/types/ClassObject.qll index 9dd09d9d901..7ed8b824999 100644 --- a/python/ql/lib/semmle/python/types/ClassObject.qll +++ b/python/ql/lib/semmle/python/types/ClassObject.qll @@ -447,7 +447,7 @@ ClassObject theBuiltinFunctionType() { /** Gets the class of Python functions */ ClassObject thePyFunctionType() { result.asBuiltin() = Builtin::special("FunctionType") } -/** Gets thGets the builtin class 'classmethod' */ +/** Gets the builtin class 'classmethod' */ ClassObject theClassMethodType() { result.asBuiltin() = Builtin::special("ClassMethod") } /** Gets the builtin class 'staticmethod' */ diff --git a/python/ql/src/Imports/DeprecatedModule.ql b/python/ql/src/Imports/DeprecatedModule.ql index 2b52596ce1d..5f5a8af3ae9 100644 --- a/python/ql/src/Imports/DeprecatedModule.ql +++ b/python/ql/src/Imports/DeprecatedModule.ql @@ -13,10 +13,7 @@ import python /** - * Gets the name of a deprecated module (for a particular version of Python) and the name of a suggested - * replacement. - * - * The module `name` was deprecated in Python version `major`.`minor`, + * Holds if the module `name` was deprecated in Python version `major`.`minor`, * and module `instead` should be used instead (or `instead = "no replacement"`) */ predicate deprecated_module(string name, string instead, int major, int minor) { diff --git a/python/ql/test/TestUtilities/InlineExpectationsTest.qll b/python/ql/test/TestUtilities/InlineExpectationsTest.qll index 7d788b26cbe..a4d264b2703 100644 --- a/python/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/python/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string { abstract predicate hasActualResult(Location location, string element, string tag, string value); /** - * Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. + * Holds if there is an optional result on the specified location. + * + * This is similar to `hasActualResult`, but returns results that do not require a matching annotation. * A failure will still arise if there is an annotation that does not match any results, but not vice versa. * Override this predicate to specify optional results. */ diff --git a/python/tools/recorded-call-graph-metrics/ql/lib/RecordedCalls.qll b/python/tools/recorded-call-graph-metrics/ql/lib/RecordedCalls.qll index 62f5047a509..567996f9462 100644 --- a/python/tools/recorded-call-graph-metrics/ql/lib/RecordedCalls.qll +++ b/python/tools/recorded-call-graph-metrics/ql/lib/RecordedCalls.qll @@ -162,7 +162,7 @@ private Builtin traverse_qualname(Builtin parent, string qualname) { } /** - * Arecorded call where we can identify both the `call` and the `callee` uniquely. + * A recorded call where we can identify both the `call` and the `callee` uniquely. */ class IdentifiedRecordedCall extends XMLRecordedCall { IdentifiedRecordedCall() { diff --git a/ruby/ql/test/TestUtilities/InlineExpectationsTest.qll b/ruby/ql/test/TestUtilities/InlineExpectationsTest.qll index 7d788b26cbe..a4d264b2703 100644 --- a/ruby/ql/test/TestUtilities/InlineExpectationsTest.qll +++ b/ruby/ql/test/TestUtilities/InlineExpectationsTest.qll @@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string { abstract predicate hasActualResult(Location location, string element, string tag, string value); /** - * Holds similarly to `hasActualResult`, but returns results that do not require a matching annotation. + * Holds if there is an optional result on the specified location. + * + * This is similar to `hasActualResult`, but returns results that do not require a matching annotation. * A failure will still arise if there is an annotation that does not match any results, but not vice versa. * Override this predicate to specify optional results. */