You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update query console links in types-class-hierarchy.rst
Removes 'gradle/gradle' from the queried projects because it cannot be
queried currently, and instead queries all demo projects which are currently
available.
Copy file name to clipboardExpand all lines: docs/language/learn-ql/java/types-class-hierarchy.rst
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ To determine ancestor types (including immediate super types, and also *their* s
32
32
where B.hasName("B")
33
33
select B.getASupertype+()
34
34
35
-
➤ `See this in the query console on LGTM.com <https://lgtm.com/query/674620010/>`__. If this query were run on the example snippet above, the query would return ``A``, ``I``, and ``java.lang.Object``.
35
+
➤ `See this in the query console on LGTM.com <https://lgtm.com/query/1506430738755934285/>`__. If this query were run on the example snippet above, the query would return ``A``, ``I``, and ``java.lang.Object``.
36
36
37
37
.. pull-quote::
38
38
@@ -78,7 +78,7 @@ This recipe is not too difficult to translate into a query:
➤ `See this in the query console on LGTM.com <https://lgtm.com/query/666680038/>`__. Many projects return results for this query.
81
+
➤ `See this in the query console on LGTM.com <https://lgtm.com/query/8378564667548381869/>`__. Many projects return results for this query.
82
82
83
83
Note that by casting ``target.getElementType()`` to a ``RefType``, we eliminate all cases where the element type is a primitive type, that is, ``target`` is an array of primitive type: the problem we are looking for cannot arise in that case. Unlike in Java, a cast in QL never fails: if an expression cannot be cast to the desired type, it is simply excluded from the query results, which is exactly what we want.
84
84
@@ -97,7 +97,7 @@ In code that does not use generics, this method is often used in the following w
97
97
98
98
Here, ``l`` has the raw type ``List``, so ``l.toArray`` has return type ``Object[]``, independent of the type of its argument array. Hence the cast goes from ``Object[]`` to ``A[]`` and will be flagged as problematic by our query, although at runtime this cast can never go wrong.
99
99
100
-
To identify these cases, we can create two CodeQL classes that represent, respectively, the ``Collection.toArray`` class, and calls to this method or any method that overrides it:
100
+
To identify these cases, we can create two CodeQL classes that represent, respectively, the ``Collection.toArray`` method, and calls to this method or any method that overrides it:
We'll now develop a query that finds uses of ``Collection.contains`` where the type of the queried element is unrelated to the element type of the collection, which guarantees that the test will always return ``false``.
150
150
151
-
For example, `Apache Zookeeper <http://zookeeper.apache.org/>`__ used to have a snippet of code similar to the following in class ``QuorumPeerConfig``:
151
+
For example, `Apache Zookeeper <https://zookeeper.apache.org/>`__ used to have a snippet of code similar to the following in class ``QuorumPeerConfig``:
152
152
153
153
.. code-block:: java
154
154
@@ -267,7 +267,7 @@ Now we are ready to write a first version of our query:
267
267
not haveCommonDescendant(collEltType, argType)
268
268
select juccc, "Element type " + collEltType + " is incompatible with argument type " + argType
269
269
270
-
➤ `See this in the query console on LGTM.com <https://lgtm.com/query/1505750556420/>`__.
270
+
➤ `See this in the query console on LGTM.com <https://lgtm.com/query/7947831380785106258/>`__.
271
271
272
272
Improvements
273
273
~~~~~~~~~~~~
@@ -294,7 +294,7 @@ Adding these three improvements, our final query becomes:
294
294
not argType.hasName("<nulltype>")
295
295
select juccc, "Element type " + collEltType + " is incompatible with argument type " + argType
296
296
297
-
➤ `See the full query in the query console on LGTM.com <https://lgtm.com/query/1505753056300/>`__.
297
+
➤ `See the full query in the query console on LGTM.com <https://lgtm.com/query/8846334903769538099/>`__.
0 commit comments