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
Alternatively, you can go straight to the query console by clicking **Query console** (at the top of any page), selecting **C/C++** from the **Language** drop-down list, then choosing one or more projects to query from those displayed in the **Project** drop-down list.
#. Copy the following query into the text box in the query console:
26
+
#. In the quick query tab, delete ``select ""`` and paste the following query beneath the import statement ``import cpp``.
35
27
36
28
.. code-block:: ql
37
29
38
-
import cpp
39
-
40
30
from IfStmt ifstmt, BlockStmt block
41
31
where ifstmt.getThen() = block and
42
32
block.getNumStmt() = 0
43
33
select ifstmt, "This 'if' statement is redundant."
44
34
45
-
LGTM checks whether your query compiles and, if all is well, the **Run** button changes to green to indicate that you can go ahead and run the query.
46
-
47
-
#. Click **Run**.
48
-
49
-
The name of the project you are querying, and the ID of the most recently analyzed commit to the project, are listed below the query box. To the right of this is an icon that indicates the progress of the query operation:
The query will take a few moments to return results. When the query completes, the results are displayed below the project name. The query results are listed in two columns, corresponding to the two expressions in the ``select`` clause of the query. The first column corresponds to the expression ``ifstmt`` and is linked to the location in the source code of the project where ``ifstmt`` occurs. The second column is the alert message.
40
+
If any matching code is found, click a link in the ``ifstmt`` column to open the file and highlight the matching ``if`` statement.
An ellipsis (…) at the bottom of the table indicates that the entire list is not displayed—click it to show more results.
69
-
70
-
#. If any matching code is found, click a link in the ``ifstmt`` column to view the ``if`` statement in the code viewer.
71
-
72
-
The matching ``if`` statement is highlighted with a yellow background in the code viewer. If any code in the file also matches a query from the standard query library for that language, you will see a red alert message at the appropriate point within the code.
.. |result-col-1| replace:: The first column corresponds to the expression ``ifstmt`` and is linked to the location in the source code of the project where ``ifstmt`` occurs.
Alternatively, you can go straight to the query console by clicking **Query console** (at the top of any page), selecting **C#** from the **Language** drop-down list, then choosing one or more projects to query from those displayed in the **Project** drop-down list.
#. Copy the following query into the text box in the query console:
26
+
#. In the quick query tab, delete ``select ""`` and paste the following query beneath the import statement ``import csharp``.
35
27
36
28
.. code-block:: ql
37
29
38
-
import csharp
39
-
40
30
from IfStmt ifstmt, BlockStmt block
41
31
where ifstmt.getThen() = block and
42
32
block.isEmpty()
43
33
select ifstmt, "This 'if' statement is redundant."
44
34
45
-
LGTM checks whether your query compiles and, if all is well, the **Run** button changes to green to indicate that you can go ahead and run the query.
46
-
47
-
#. Click **Run**.
48
-
49
-
The name of the project you are querying, and the ID of the most recently analyzed commit to the project, are listed below the query box. To the right of this is an icon that indicates the progress of the query operation:
Your query is always run against the most recently analyzed commit to the selected project.
40
+
If any matching code is found, click a link in the ``ifstmt`` column to open the file and highlight the matching ``if`` statement.
59
41
60
-
The query will take a few moments to return results. When the query completes, the results are displayed below the project name. The query results are listed in two columns, corresponding to the two expressions in the ``select`` clause of the query. The first column corresponds to the expression ``ifstmt`` and is linked to the location in the source code of the project where ``ifstmt`` occurs. The second column is the alert message.
An ellipsis (…) at the bottom of the table indicates that the entire list is not displayed—click it to show more results.
69
-
70
-
#. If any matching code is found, click a link in the ``ifstmt`` column to view the ``if`` statement in the code viewer.
71
-
72
-
The matching ``if`` statement is highlighted with a yellow background in the code viewer. If any code in the file also matches a query from the standard query library for that language, you will see a red alert message at the appropriate point within the code.
.. |result-col-1| replace:: The first column corresponds to the expression ``ifstmt`` and is linked to the location in the source code of the project where ``ifstmt`` occurs.
Alternatively, you can go straight to the query console by clicking **Query console** (at the top of any page), selecting **Go** from the **Language** drop-down list, then choosing one or more projects to query from those displayed in the **Project** drop-down list.
#. Copy the following query into the text box in the query console:
34
+
#. In the quick query tab, delete ``select ""`` and paste the following query beneath the import statement ``import go``.
43
35
44
36
.. code-block:: ql
45
37
46
-
import go
47
-
48
38
from Method m, Variable recv, Write w, Field f
49
39
where
50
40
recv = m.getReceiver() and
51
41
w.writesField(recv.getARead(), f, _) and
52
42
not recv.getType() instanceof PointerType
53
43
select w, "This update to " + f + " has no effect, because " + recv + " is not a pointer."
54
44
55
-
LGTM checks whether your query compiles and, if all is well, the **Run** button changes to green to indicate that you can go ahead and run the query.
56
-
57
-
#. Click **Run**.
58
-
59
-
The name of the project you are querying, and the ID of the most recently analyzed commit to the project, are listed below the query box. To the right of this is an icon that indicates the progress of the query operation:
The query will take a few moments to return results. When the query completes, the results are displayed below the project name. The query results are listed in two columns, corresponding to the two expressions in the ``select`` clause of the query. The first column corresponds to ``w``, which is the location in the source code where the receiver ``recv`` is modified. The second column is the alert message.
50
+
If any matching code is found, click a link in the ``w`` column to open the file and highlight the matching location.
An ellipsis (…) at the bottom of the table indicates that the entire list is not displayed—click it to show more results.
79
-
80
-
#. If any matching code is found, click a link in the ``w`` column to view it in the code viewer.
81
-
82
-
The matching ``w`` is highlighted with a yellow background in the code viewer. If any code in the file also matches a query from the standard query library for that language, you will see a red alert message at the appropriate point within the code.
0 commit comments