Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
An unresolved minor finding notes that the configuration log omits the input-file count, making empty or partial extractions harder to diagnose.
1 open issue
What changed in this PR
This PR aligns the Rust extractor with other CodeQL extractors by replacing @argfile expansion with an explicit --file-list option.
Changes:
- Update both launchers and read input paths directly from a newline-separated file.
- Return QL test sources separately from configuration and remove input-specific macro handling.
- Remove
argfileand its unused transitive dependencies from Cargo and Bazel metadata.
| File | Description |
|---|---|
rust/tools/index-files.sh |
Pass the file list through --file-list. |
rust/tools/index-files.cmd |
Use --file-list in the Windows launcher. |
rust/extractor/src/qltest.rs |
Return source paths instead of mutating configuration. |
rust/extractor/src/main.rs |
Read input paths from the configured file list. |
rust/extractor/src/config.rs |
Replace positional inputs with a file-list option. |
rust/extractor/macros/src/lib.rs |
Remove special handling for input paths. |
rust/extractor/Cargo.toml |
Remove the argfile dependency. |
MODULE.bazel |
Remove the argfile repository import. |
misc/bazel/3rdparty/tree_sitter_extractors_deps/crates.bzl |
Remove unused dependency and repository definitions. |
misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.os_str_bytes-7.2.0.bazel |
Delete unused transitive-dependency build metadata. |
misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.fs-err-3.3.0.bazel |
Delete unused transitive-dependency build metadata. |
misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.bazel |
Remove argfile aliases. |
misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.argfile-1.0.0.bazel |
Delete generated argfile build metadata. |
misc/bazel/3rdparty/tree_sitter_extractors_deps/argfile/BUILD.bazel |
Delete the unversioned dependency alias. |
misc/bazel/3rdparty/tree_sitter_extractors_deps/argfile-1.0.0/BUILD.bazel |
Delete the versioned dependency alias. |
Cargo.lock |
Remove argfile and its unused transitive dependencies. |
Review effort: Max
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35193a30-9bd2-4372-a2e5-65422a7779cf
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35193a30-9bd2-4372-a2e5-65422a7779cf
38712e6 to
08eff93
Compare
argfile dependency and read file list manually
andersfugmann
left a comment
There was a problem hiding this comment.
Code change looks good. Approvied.
Tbh, I'm torn. I understand the motivation to simplify the argument parsing (and reducing lines of code), but I actually think it's more elegant to accept the @<file> as an alternative way to provide arguments to a command line tool. If the argument is that we should unify the extractors, I'd prefer to adopt support for @<file> throughout.
I'm not strong on this, but recommend seeking input from #semmle_dev before merging.
| } else { | ||
| Vec::new() | ||
| }; | ||
| let start = Instant::now(); |
There was a problem hiding this comment.
Not directly related to this PR, but should this not be at the very top of main?
There was a problem hiding this comment.
Yes, that would make more sense. I've moved it up there.
| use std::collections::HashSet; | ||
| use std::fs::File; | ||
| use std::hash::RandomState; | ||
| use std::io::{self, BufRead, BufReader}; |
There was a problem hiding this comment.
Yes, but it's very hard to see. It's a trait and importing it puts its methods in scope and one of its methods is used.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 68782cf6-b72d-4197-95b1-5c6003baf543 # Conflicts: # rust/extractor/src/main.rs
I think this would make sense if the extractor binary was often invoked "by hand" on the command line. But in practice I don't think we ever do that (I've never done it at least). Hence, I think it's more important to move towards alignment with the other Rust-based extractors and to keep the code simple. I've merged |

The
index-files.shfile in the extractors for Ruby, Ql, and Unified all pass the filename with the list of files to extract like this--file-list "$1".However, in
index-files.shin the Rust extractor we pass it like@"$1". The@is syntax to pass arguments by filename (I'm not sure what the origin of this notation is, but it's a somewhat well-known notation). We handle the@by a dependency argfile.The only thing we gain from introducing this dependency, using
@(that I was not familiar with), deviating from the other extractors, and special casing in theextractor_cli_configmacro, is that we don't have to read the named file ourselves.I don't think that's worth it, so this PR removes the
argfiledependency and reads and parses the file manually (like the other extractors do). This gives closer alignment with the other extractors and less complexity. Furthermore, it turns out that, all things considered, this is in fact fewer lines of code than what we had with the dependency.The dependency removal and generated Cargo/Bazel metadata are in the first commit. The code changes are in the second commit.