Skip to content

Commit 6d10731

Browse files
authored
Merge pull request #1653 from felicity-semmle/learn-ql/SD-3690-vale-corrections
Learn QL: corrections for issues found using Vale
2 parents bf0201a + 2060fdc commit 6d10731

37 files changed

+288
-185
lines changed

docs/ql-documentation/learn-ql/advanced/abstract-classes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A classic example where this approach is useful is when modeling ASTs (Abstract
1010

1111
Each value in a concrete class satisfies a particular logical property - the *characteristic predicate* (or *character* for short) of that class. This characteristic predicate consists of the conjunction (``and``) of its own body (if any) and the characteristic predicates of its superclasses.
1212

13-
For example, we could derive a subclass ``MainMethod`` from the standard QL class ``Method`` that contains precisely those Java functions called "main":
13+
For example, we could derive a subclass ``MainMethod`` from the standard QL class ``Method`` that contains precisely those Java functions called ``"main"``:
1414

1515
.. code-block:: ql
1616
@@ -33,7 +33,7 @@ Letting ``cp(C)`` denote the characteristic predicate of class ``C``, it is clea
3333
3434
cp(MainMethod) = cp(Method) and hasName("main")
3535
36-
That is, entities are "main" methods if and only if they are methods that are also called "main".
36+
That is, entities are *main* methods if and only if they are methods that are also called ``"main"``.
3737

3838
Abstract classes
3939
----------------

docs/ql-documentation/learn-ql/advanced/folding-predicates.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Example
1616
e1.getLocation().getStartLine() = e2.getLocation().getStartLine()
1717
}
1818
19-
Here we are doing some lookups on ``Element``\ s. Going from ``Element -> File`` and ``Element -> Location -> StartLine`` are linear: there is only one ``File`` for each ``Element``, and one ``Location`` for each ``Element``, etc. However, as written it is difficult for the optimizer to pick out the best ordering here. We want to do the quick, linear parts first, and then join on the resultant larger tables, rather than joining first and then doing the linear lookups. We can precipitate this kind of ordering by rewriting the above predicate as follows:
19+
Here we explore some lookups on ``Element``\ s. Going from ``Element -> File`` and ``Element -> Location -> StartLine`` are linear: there is only one ``File`` for each ``Element``, and one ``Location`` for each ``Element``, etc. However, as written it is difficult for the optimizer to pick out the best ordering here. We want to do the quick, linear parts first, and then join on the resultant larger tables, rather than joining first and then doing the linear lookups. We can precipitate this kind of ordering by rewriting the above predicate as follows:
2020

2121
.. code-block:: ql
2222

docs/ql-documentation/learn-ql/advanced/monotonic-aggregates.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ For most usages, aggregates have very straightforward behavior. They can be thou
4242

4343
For every combination of values for the declared **variables**, for which the **range** holds, take one value of the **expression** and apply the **aggregation function** to the resulting values.
4444

45-
How does this work? Let us take the simple example given above of calculating the sum of your employees' salaries. Suppose that your employees are Alice, Ben and Charles, whose salaries are $30k, $40k, and $50k respectively. Then to calculate ``result``, we follow our recipe:
45+
How does this work? Let us take the simple example given above of calculating the sum of your employees' salaries. Suppose that your employees are Alice, Ben, and Charles, whose salaries are $30k, $40k, and $50k respectively. Then to calculate ``result``, we follow our recipe:
4646

4747
+----------------------------------------------------------------+-------------------------------------+
4848
| For every combination of values for the declared **variables** | Alice, Ben, Charles, Denis, Edna... |
@@ -192,7 +192,7 @@ Rank is a slightly unusual aggregate. It takes the possible values of the expres
192192
where salary = rank[salaryRank](Employee e | managedByMe(e) | e.getSalary())
193193
select salary, salaryRank
194194
195-
assigns, for each of my managees, their salary to ``salary``, and the rank of their salary to ``salaryRank``. In our running example, the results would be:
195+
assigns, for each person I manage, their salary to ``salary``, and the rank of their salary to ``salaryRank``. In our running example, the results would be:
196196

197197
+------------+----------------+
198198
| ``salary`` | ``salaryRank`` |

docs/ql-documentation/learn-ql/beginner/find-thief-1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ There is too much information to search through by hand, so you decide to use yo
4545
#. Select a language and a demo project. For this tutorial, any language and project will do.
4646
#. Delete the default code ``import <language> select "hello world"``.
4747

48-
QL Libraries
48+
QL libraries
4949
------------
5050

5151
We've defined a number of QL `predicates <https://help.semmle.com/QL/ql-handbook/predicates.html>`__ to help you extract data from your table. A QL predicate is a mini-query that expresses a relation between various pieces of data and describes some of their properties. In this case, the predicates give you information about a person, for example their height or age.

docs/ql-documentation/learn-ql/beginner/find-thief-2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Find the thief: Start the search
22
================================
33

4-
The villagers answered "yes" to the question "Is the thief taller than 150cm?". To use this information, you can write the following query to list all villagers taller than 150cm. These are all possible suspects.
4+
The villagers answered "yes" to the question "Is the thief taller than 150cm?" To use this information, you can write the following query to list all villagers taller than 150cm. These are all possible suspects.
55

66
.. code-block:: ql
77

docs/ql-documentation/learn-ql/beginner/fire-1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The expression ``southern(this)`` defines the logical property represented by th
5555

5656
Note
5757

58-
If you are familiar with object-oriented programming languages, you might be tempted to think of the characteristic predicate as a "constructor". However, this is **not** the case - it is a logical property which does not create any objects.
58+
If you are familiar with object-oriented programming languages, you might be tempted to think of the characteristic predicate as a *constructor*. However, this is **not** the case - it is a logical property which does not create any objects.
5959

6060
You always need to define a class in QL in terms of an existing (larger) class. In our example, a ``Southerner`` is a special kind of ``Person``, so we say that ``Southerner`` *extends* ("is a subset of") ``Person``.
6161

docs/ql-documentation/learn-ql/beginner/heir.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ This is getting complicated. Ideally, you want to define a predicate ``relativeO
8989

9090
How could you do that?
9191

92-
It helps to think of a precise definition of "relative". A possible definition is that two people are related if they have a common ancestor.
92+
It helps to think of a precise definition of *relative*. A possible definition is that two people are related if they have a common ancestor.
9393

9494
You can introduce a predicate ``ancestorOf(Person p)`` that lists all ancestors of ``p``. An ancestor of ``p`` is just a parent of ``p``, or a parent of a parent of ``p``, or a parent of a parent of a parent of ``p``, and so on. Unfortunately, this leads to an endless list of parents. You can't write an infinite QL query, so there must be an easier approach.
9595

docs/ql-documentation/learn-ql/cpp/dataflow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ For a more general introduction to modeling data flow in QL, see :doc:`Introduct
1212
Local data flow
1313
---------------
1414

15-
Local data flow is data flow within a single function. Local data flow is usually easier, faster and more precise than global data flow, and is sufficient for many queries.
15+
Local data flow is data flow within a single function. Local data flow is usually easier, faster, and more precise than global data flow, and is sufficient for many queries.
1616

1717
Using local data flow
1818
~~~~~~~~~~~~~~~~~~~~~

docs/ql-documentation/learn-ql/cpp/expressions-types.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tutorial: Expressions, types and statements
44
Overview
55
--------
66

7-
This topic contains worked examples of how to write queries using the standard QL library classes for C/C++ expressions, types and statements.
7+
This topic contains worked examples of how to write queries using the standard QL library classes for C/C++ expressions, types, and statements.
88

99
Expressions and types
1010
---------------------

docs/ql-documentation/learn-ql/cpp/introduce-libraries-cpp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Symbol table
4949
- ``TypedefType`` — typedefs
5050
- ``ArrayType`` — arrays
5151
- ``PointerType`` — pointers
52-
- ``SpecifiedType`` — qualifiers such as const, volatile, or restrict
52+
- ``SpecifiedType`` — qualifiers such as ``const``, ``volatile``, or ``restrict``
5353

5454
- ``Namespace`` — namespaces (defined in the `Namespace.qll <https://help.semmle.com/qldoc/cpp/semmle/code/cpp/Namespace.qll/module.Namespace.html>`__ library)
5555

0 commit comments

Comments
 (0)