-
Notifications
You must be signed in to change notification settings - Fork 2
Update --language
support for new-query
subcommand
#28
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
base: main
Are you sure you want to change the base?
Conversation
Updates the `qlt query generate new-query` subcommand in order to support the equivalent set of `--language` options as the `qlt test init` subcommand. Adds unit tests to ensure that template vars (i.e. language) are defined (i.e. not empty) for subcommand templates.
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
Updates the qlt query generate new-query
subcommand to support the same language options as the qlt test init
subcommand by adding Python and Ruby language support. This includes adding template files for both languages and ensuring proper template variable resolution.
- Adds Python language support to
FromOptionString
method - Extends supported languages array to include C#, Go, Java, Python, and Ruby
- Adds comprehensive unit tests to validate template existence and proper variable substitution
Reviewed Changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/CodeQLToolkit.Shared/Utils/Language.cs |
Adds Python language option parsing support |
src/CodeQLToolkit.Features/Query/Scaffolding/QueryScaffoldFeature.cs |
Expands supported languages to include all CodeQL languages |
src/CodeQLToolkit.Features/Query/Scaffolding/Targets/NewQueryScaffoldTarget.cs |
Fixes template variable resolution by adding missing ql_language parameter |
Template files | Adds complete template sets for Python, Ruby, Java, Go, and C# languages |
Test files | Adds comprehensive unit tests for template validation and variable substitution |
Comments suppressed due to low confidence (3)
src/CodeQLToolkit.Features/Templates/Query/go/new-dataflow-query.liquid:1
- The Go dataflow template uses an outdated API pattern. Line 22 is missing the
override
keyword for theisSink
predicate, and the template should use the newer module-based configuration pattern consistent with other language templates.
/**
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/CodeQLToolkit.Features/Templates/Query/go/new-dataflow-query.liquid
Outdated
Show resolved
Hide resolved
Fixes an error where cloning the `github/codeql` repo would fail when the local environment had a git config for automatically rewriting the URL scheme (to SSH) for any `git clone` task.
Refactors the 'query generate new-query' subcommand of the CodeQLToolkit.Core (qlt) CLI in order to: - Update the version of CodeQL used to 'v2.22.4' (current latest); - Support generating new queries for all currently supported languages; - Add support for generating `@kind path-problem` (dataflow) queries; - Create scripts for end-to-end testing of the `new-query` subcommand; - Create a new actions workflow for automated verification and testing of queries generated via `qlt query generate new-query`; - Ensure that (liquid) template rendering fails if a required template var is unset. Adds unit tests to ensure template vars are not empty.
Fixes to templates used to generate new queries languages such as: - cpp - csharp - go - java - ruby
This PR has more changes to more files than would generally be desired. |
Purpose
This main purpose of this PR is to improve the
qlt query generate new-query
subcommand in order to support the equivalent set of--language
options as theqlt test init
subcommand.Summary
This PR also introduces several other improvements and updates to the CodeQL Toolkit project, focusing on modernizing dependencies, enhancing CI validation, and expanding unit test coverage. The most significant changes include updating all CodeQL pack and CLI versions to the latest releases, adding a new internal GitHub Actions workflow for validating CLI outputs across multiple languages, and introducing a robust shell script for running and validating unit tests. Additionally, the solution file now includes a new test project for feature-level testing.
Outline of Changes
Automation and Testing Improvements:
.github/workflows/internal-validate-cli-outputs.yml
workflow to automate generation, validation, and end-to-end testing of thenew-query
CLI across multiple languages.scripts/run-unit-tests.sh
for running and validating CodeQL unit tests for generated queries, with improved logging and argument parsing.Dependency and Configuration Updates:
codeql-pack.lock.yml
andqlpack.yml
files in the example C++ packs (customizations
,stuff
,stuff2
) to use the latest CodeQL pack versions (e.g.,codeql/cpp-all
to5.4.1
) and incremented pack versions. [1] [2] [3] [4] [5] [6] [7]example/qlt.conf.json
to reference newer CodeQL CLI and standard library versions (2.22.4
).Solution Structure:
CodeQLToolkit.Features.Tests
project toCodeQLToolkit.sln
and configured it for build and solution folder placement. [1] [2] [3]