Skip to content

Commit 0def31a

Browse files
committed
Update Go article
1 parent c66569b commit 0def31a

File tree

8 files changed

+33
-48
lines changed

8 files changed

+33
-48
lines changed

docs/codeql/codeql-language-guides/basic-query-for-cpp-code.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ Further reading
127127

128128
.. |image-quick-query| image:: ../images/codeql-for-visual-studio-code/quick-query-tab-cpp.png
129129

130-
.. |expression| replace:: ``ifstmt``
130+
.. |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.

docs/codeql/codeql-language-guides/basic-query-for-csharp-code.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ Further reading
131131

132132
.. |image-quick-query| image:: ../images/codeql-for-visual-studio-code/quick-query-tab-csharp.png
133133

134-
.. |expression| replace:: ``ifstmt``
134+
.. |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.

docs/codeql/codeql-language-guides/basic-query-for-go-code.rst

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
Basic query for Go code
44
=======================
55

6-
Learn to write and run a simple CodeQL query using LGTM.
6+
Learn to write and run a simple CodeQL query using Visual Studio Code with the CodeQL extension.
7+
8+
.. include:: ../reusables/vs-code-basic-instructions/setup-to-run-queries.rst
79

810
About the query
911
---------------
@@ -22,64 +24,35 @@ This is problematic because the receiver argument is passed by value, not by ref
2224
2325
For further information on using methods on values or pointers in Go, see the `Go FAQ <https://golang.org/doc/faq#methods_on_values_or_pointers>`__.
2426

25-
Running the query
26-
-----------------
27-
28-
#. In the main search box on LGTM.com, search for the project you want to query. For tips, see `Searching <https://lgtm.com/help/lgtm/searching>`__.
29-
30-
#. Click the project in the search results.
31-
32-
#. Click **Query this project**.
33-
34-
This opens the query console. (For information about using this, see `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.)
35-
36-
.. pull-quote::
27+
.. include:: ../reusables/vs-code-basic-instructions/find-database.rst
3728

38-
Note
29+
Running a quick query
30+
---------------------
3931

40-
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.
32+
.. include:: ../reusables/vs-code-basic-instructions/run-quick-query-1.rst
4133

42-
#. 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``.
4335

4436
.. code-block:: ql
4537
46-
import go
47-
4838
from Method m, Variable recv, Write w, Field f
4939
where
5040
recv = m.getReceiver() and
5141
w.writesField(recv.getARead(), f, _) and
5242
not recv.getType() instanceof PointerType
5343
select w, "This update to " + f + " has no effect, because " + recv + " is not a pointer."
5444
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:
60-
61-
.. image:: ../images/query-progress.png
62-
:align: center
63-
64-
.. pull-quote::
45+
.. include:: ../reusables/vs-code-basic-instructions/run-quick-query-2.rst
6546

66-
Note
47+
.. image:: ../images/codeql-for-visual-studio-code/basic-go-query-results-1.png
48+
:align: center
6749

68-
Your query is always run against the most recently analyzed commit to the selected project.
50+
If any matching code is found, click a link in the ``w`` column to view it in the code viewer.
6951

70-
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.
52+
.. image:: ../images/codeql-for-visual-studio-code/basic-go-query-results-2.png
53+
:align: center
7154

72-
➤ `Example query results <https://lgtm.com/query/6221190009056970603/>`__
73-
74-
.. pull-quote::
75-
76-
Note
77-
78-
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.
55+
.. include:: ../reusables/vs-code-basic-instructions/note-store-quick-query.rst
8356

8457
About the query structure
8558
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -144,10 +117,20 @@ To exclude these values:
144117

145118
There are now fewer results because value methods that return their receiver variable are no longer reported.
146119

147-
➤ `See this in the query console <https://lgtm.com/query/9110448975027954322/>`__
148-
149120
Further reading
150121
---------------
151122

152123
.. include:: ../reusables/go-further-reading.rst
153124
.. include:: ../reusables/codeql-ref-tools-further-reading.rst
125+
126+
.. Article-specific substitutions for the reusables used in docs/codeql/reusables/vs-code-basic-instructions
127+
128+
.. |language-text| replace:: Go
129+
130+
.. |language-code| replace:: ``go``
131+
132+
.. |example-url| replace:: https://github.com/go-gorm/gorm
133+
134+
.. |image-quick-query| image:: ../images/codeql-for-visual-studio-code/quick-query-tab-go.png
135+
136+
.. |result-col-1| replace:: The first column corresponds to ``w``, which is the location in the source code where the receiver ``recv`` is modified.

docs/codeql/codeql-language-guides/basic-query-for-java-code.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
Basic query for Java and Kotlin code
44
====================================
55

6-
Learn to write and run a simple CodeQL query using LGTM.
6+
Learn to write and run a simple CodeQL query using Visual Studio Code with the CodeQL extension.
7+
8+
.. include:: ../reusables/vs-code-basic-instructions/setup-to-run-queries.rst
79

810
About the query
911
---------------
241 KB
Loading
271 KB
Loading
65.7 KB
Loading

docs/codeql/reusables/vs-code-basic-instructions/run-quick-query-2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
The query will take a few moments to return results. When the query completes, the results are displayed in a CodeQL Query Results window, alongside the query window.
66

7-
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 |expression| and is linked to the location in the source code of the project where |expression| occurs. The second column is the alert message.
7+
The query results are listed in two columns, corresponding to the expressions in the ``select`` clause of the query. |result-col-1| The second column is the alert message.

0 commit comments

Comments
 (0)