Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

data-douser
Copy link

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.

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.
Copy link

@Copilot Copilot AI left a 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 the isSink 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.

}

from Config config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink)
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The Go dataflow template uses an outdated API pattern. Line 22 is missing the override keyword for the isSink predicate, and the template should use the newer module-based configuration pattern consistent with other language templates.

Suggested change
where config.hasFlowPath(source, sink)
from DataFlow::Config::PathNode source, DataFlow::Config::PathNode sink
where DataFlow::Config.hasFlowPath(source, sink)

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

Copilot detected a code snippet with 50+ occurrences. See search results for more details.

Matched Code Snippet
="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
    <PackageReference Include="NUnit" Version="3.13.3" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
    <PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
    <PackageReference Include="coverlet.collector" Version="3.1.2" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\src\

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,14 @@
/**
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

Copilot detected a code snippet with 2 occurrences. See search results for more details.

Matched Code Snippet
@id {{language}}/{{query_pack_name}}/{{query_name}}
 * @name {{query_name}}
 * @description {{description}}
 * @kind problem
 * @precision medium
 * @problem.severity error
 * @tags {{query_pack_name}}
 */

 import {{ql_language_import}}

 from Expr e
 select e, "Replace

Copilot uses AI. Check for mistakes.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant