Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Kotlin (beta) content #11384

Draft
wants to merge 1 commit into
base: codeql-cli-2.11.4
Choose a base branch
from

Conversation

subatoi
Copy link
Contributor

@subatoi subatoi commented Nov 22, 2022

Note that the content design plan noted possible additions to https://codeql.github.com/docs/codeql-cli/extractor-options/; I could not find a suitable place

The CodeQL CLI includes autobuilders for C/C++, C#, Go, and Java code. CodeQL
.. include:: ../reusables/kotlin-beta-note.rst

The CodeQL CLI includes autobuilders for C/C++, C#, Go, Java and Kotlin code. CodeQL
Copy link
Contributor Author

@subatoi subatoi Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need an example build command for Kotlin for this section?

Writing CodeQL queries in Kotlin versus Java
--------------------------------------------

When writing Kotlin-specific elements (such as a `WhenExpr`) you’ll need to use Kotlin-specific CodeQL classes, but writing queries for Kotlin and Java is largely the same. The two make use of the same libraries such as DataFlow, TaintTracking, or SSA, and the same classes such as `MethodAccess` or `Class`.
Copy link
Contributor Author

@subatoi subatoi Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make a final check: we shouldn't mention any specific libraries for Kotlin (here or anywhere else)? I'm inferring 'no' from this content and from https://github.com/github/docs-strategy/pull/1494/files#r1025069569

@@ -5,6 +5,8 @@ Analyzing data flow in Java

You can use CodeQL to track the flow of data through a Java program to its use.

.. include:: ../reusables/kotlin-java-differences.rst
Copy link
Contributor Author

@subatoi subatoi Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. include:: ../reusables/kotlin-java-differences.rst
.. include:: ../reusables/kotlin-beta-note.rst
.. include:: ../reusables/kotlin-java-differences.rst

@@ -7,6 +7,8 @@ CodeQL has a large selection of classes for representing the abstract syntax tre

.. include:: ../reusables/abstract-syntax-tree.rst

.. include:: ../reusables/kotlin-java-differences.rst
Copy link
Contributor Author

@subatoi subatoi Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. include:: ../reusables/kotlin-java-differences.rst
.. include:: ../reusables/kotlin-beta-note.rst
.. include:: ../reusables/kotlin-java-differences.rst

@yo-h yo-h requested a review from a team Nov 22, 2022
Copy link
Contributor

@intrigus-lgtm intrigus-lgtm left a comment

Not an official committer, so feel free to ignore my review.


.. pull-quote:: Enabling Kotlin support

To enable Kotlin support, you should enable `java` as a language.
Copy link
Contributor

@intrigus-lgtm intrigus-lgtm Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?
If yes, it sounds a bit unintuitive that you have to enable java to enable Kotlin IMHO.

Copy link
Contributor

@igfoo igfoo Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes: Due to how common it is for Kotlin code to call Java code and vice versa within a single project, we treat them as essentially 2 compilers for the same language. This also means that the CodeQL libraries and queries can be shared between the two which, as they are very similar underneath, saves a lot of duplication. This is similar to how javascript and typescript are treated by CodeQL as a single language, as well as the C family (standard C and C++ in their various versions, as well as Microsoft and GNU extensions to those languages).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants