-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: Add Basic query for Rust code doc #20561
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a "Basic query for Rust code" documentation page to help users learn how to write and run simple CodeQL queries for Rust. The documentation follows the established pattern used for other supported languages and provides a tutorial for creating a query that identifies redundant if
expressions.
- Adds comprehensive tutorial documentation for writing basic Rust CodeQL queries
- Updates the language guide index to include the new documentation page
- Uses consistent formatting and structure with existing language guide documentation
Reviewed Changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
docs/codeql/codeql-language-guides/codeql-for-rust.rst |
Updates the table of contents to include the new basic query tutorial |
docs/codeql/codeql-language-guides/basic-query-for-rust-code.rst |
Adds complete tutorial documentation for writing basic Rust CodeQL queries |
| | | ``.getStmtList()``: gets the list of things in the block. | | ||
| | | ``.getNumberOfStmtOrExpr() = 0``: requires that there are no statements or expressions in the block. | | ||
+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | ||
| ``select ifExpr, "This 'if' expression is redundant."`` | Defines what to report for each match. | Reports the resulting ``if`` expression with a string that explains the problem. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message refers to 'if' expression, but line 36 uses 'if' statement. The terminology should be consistent - use 'if' expression in both places since Rust treats if
as an expression.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, though it's line 36 that should be updated - they're if "expressions" in Rust.
Updated the doc.
I'll need to re-create the screenshots as well, but lets wait and see if any other changes are suggested first...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine words-wise, as far as I can tell looking at the rST
I'm not sure why the Sphinx build is failing... ideally we'd get it working, which would make reviewing more complete, but if that's not possible I think this is OK
I think I've fixed it now. I'll update the graphics next... |
Done. Ready for another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing that! I took a look in a browser and all looks good
Add "Basic query for Rust code" doc page, similar to the one we have for most other languages.