Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cedfdeb
Enable Clippy's pedantic lints
paldepind Nov 11, 2026
b3552c5
Fix all results of the Clippy lint `cloned_instead_of_copied`
paldepind Nov 10, 2026
5ae3fa9
Fix all results of the Clippy lint `implicit_clone`
paldepind Nov 10, 2026
e3c310e
Fix all results of the Clippy lint `single_match_else`
paldepind Nov 10, 2026
7941191
Fix all results of the Clippy lint `uninlined_format_args`
paldepind Nov 10, 2026
71ef28c
Fix all results of the Clippy lint `map_unwrap_or`
paldepind Nov 10, 2026
fd386a1
Fix all results of the Clippy lint `manual_string_new`
paldepind Nov 11, 2026
bac4c43
Fix all results of the Clippy lint `needless_continue`
paldepind Nov 11, 2026
c522fd2
Fix all results of the Clippy lint `match_same_arms`
paldepind Nov 11, 2026
e98c562
Fix all results of the Clippy lint `unnecessary_literal_bound`
paldepind Nov 11, 2026
17db5e1
Fix all results of the Clippy lint `elidable_lifetime_names`
paldepind Nov 11, 2026
b03995f
Fix all results of the Clippy lint `doc_markdown`
paldepind Nov 11, 2026
6b00a37
Fix all results of the Clippy lint `unnecessary_join`
paldepind Nov 11, 2026
c287799
Fix all results of the Clippy lint `needless_raw_string_hashes`
paldepind Nov 11, 2026
52e9f50
Fix all results of the Clippy lint `non_std_lazy_statics`
paldepind Nov 11, 2026
ae96ca1
Fix all results of the Clippy lint `manual_assert`
paldepind Nov 11, 2026
925a390
Fix all results of the Clippy lint `trivially_copy_pass_by_ref`
paldepind Nov 11, 2026
9e71fdb
Fix all results of the Clippy lint `flat_map_option`
paldepind Nov 11, 2026
5ef41d3
Fix all results of the Clippy lint `ref_option`
paldepind Nov 11, 2026
3154453
Fix all results of the Clippy lint `semicolon_if_nothing_returned`
paldepind Nov 11, 2026
207cc35
Fix all results of the Clippy lint `unnecessary_semicolon`
paldepind Nov 11, 2026
d1f084a
Fix all results of the Clippy lint `return_self_not_must_use`
paldepind Nov 11, 2026
43105fb
Fix all results of the Clippy lint `match_wildcard_for_single_variants`
paldepind Nov 11, 2026
a8a1559
Fix all results of the Clippy lint `assigning_clones`
paldepind Nov 11, 2026
187a969
Fix all results of the Clippy lint `needless_pass_by_value`
paldepind Nov 11, 2026
dfb6712
Fix all results of the Clippy lint `format_push_string`
paldepind Nov 11, 2026
c772de8
Ignore all results of the Clippy lint `too_many_lines`
paldepind Nov 11, 2026
6f3da0d
Fix all results of the Clippy lint `single_char_pattern`
paldepind Nov 11, 2026
7a3af00
Fix all results of the Clippy lint `unused_self`
paldepind Nov 11, 2026
f9fa4d2
Fix all results of the Clippy lint `explicit_into_iter_loop`
paldepind Nov 11, 2026
c5edcc8
Fix all results of the Clippy lint `unnecessary_debug_formatting`
paldepind Nov 11, 2026
733f0a4
Fix all results of the Clippy lint `missing_fields_in_debug`
paldepind Nov 11, 2026
65ef484
Fix all results of the Clippy lint `unreadable_literal`
paldepind Nov 11, 2026
96b6fb0
Fix all results of the Clippy lint `struct_field_names`
paldepind Nov 11, 2026
4957f2c
Fix all results of the Clippy lint `default_trait_access`
paldepind Nov 11, 2026
9d4873f
Ignore all results of the Clippy lint `unicode_not_nfc`
paldepind Nov 11, 2026
f10e095
Fix all results of the Clippy lint `items_after_statements`
paldepind Nov 11, 2026
6df1ef1
Allow select Clippy rules
paldepind Nov 11, 2026
28482d5
Remove unused `lazy_static` dependency
paldepind Nov 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,24 @@ exclude = [

[workspace.lints.clippy]
all = { level = "warn", priority = -1 }
explicit_iter_loop = "warn"
manual_let_else = "warn"
pedantic = { level = "warn", priority = -1 }

# Allowlist of pedantic rules that we've observed to be of questionable value
missing_errors_doc = "allow"
missing_panics_doc = "allow"
must_use_candidate = "allow"
implicit_hasher = "allow"
if_not_else = "allow"
# This lint has a lot of results in generated code.
unnecessary_wraps = "allow"
# Spelling out the full method name can often be tedious.
# E.g., `|v| v.as_slice()` vs `vec::Vec::as_slice`
redundant_closure_for_method_calls = "allow"
# The next three are only false positives and questionable results
cast_possible_truncation = "allow"
cast_possible_wrap = "allow"
cast_sign_loss = "allow"
# False positives
struct_excessive_bools = "allow"
# False positives for things like "matches" and "matched"
similar_names = "allow"
1 change: 0 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ use_repo(
"vendor_rs__globset-0.4.18",
"vendor_rs__itertools-0.14.0",
"vendor_rs__itertools-0.15.0",
Comment thread
paldepind marked this conversation as resolved.
Resolved
"vendor_rs__lazy_static-1.5.1",
"vendor_rs__mustache-0.9.0",
"vendor_rs__num-traits-0.2.19",
"vendor_rs__num_cpus-1.17.0",
Expand Down
2 changes: 2 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Names that do not need to be backtick quoted within documentation comments.
doc-valid-idents = ["CodeQL", ".."]
16 changes: 12 additions & 4 deletions cpp/extractor/bmn/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ fn get_compiler_override(
&clang_cpp_compiler,
)
.ok_or(anyhow!(
"Could not find clang compilers: {clang_c_compiler:?}, {clang_cpp_compiler:?}"
"Could not find clang compilers: {}, {}",
clang_c_compiler.display(),
clang_cpp_compiler.display()
))
} else if override_instruction == "gnu" {
// These can be just a command name, e.g. "gcc-18", or a full path, e.g.
Expand All @@ -529,17 +531,23 @@ fn get_compiler_override(
let gnu_cpp_compiler =
environment::get_required_os(environment::CODEQL_EXTRACTOR_CPP_BMN_COMPILER_GNU_CPP)?;
find_posix(telemetry, Compiler::Gnu, &gnu_c_compiler, &gnu_cpp_compiler).ok_or(anyhow!(
"Could not find gnu compilers: {gnu_c_compiler:?}, {gnu_cpp_compiler:?}"
"Could not find gnu compilers: {}, {}",
gnu_c_compiler.display(),
gnu_cpp_compiler.display()
))
} else if override_instruction == "msvc" {
// These can be just a command name, e.g. "cl", or a full path, e.g.
// "c:\msvc\cl.exe"
let msvc_compiler =
environment::get_required_os(environment::CODEQL_EXTRACTOR_CPP_BMN_COMPILER_MSVC)?;
use_cl(&msvc_compiler).ok_or(anyhow!("Could not find msvc compiler: {msvc_compiler:?}"))
use_cl(&msvc_compiler).ok_or(anyhow!(
"Could not find msvc compiler: {}",
msvc_compiler.display()
))
} else {
Err(anyhow!(
"Unsupported compiler override instruction: {override_instruction:?}"
"Unsupported compiler override instruction: {}",
override_instruction.display()
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/extractor/bmn/src/dependency_installation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn run_command(command: &mut Command) -> anyhow::Result<()> {
} else {
OsString::from("Failed to read output")
};
Err(anyhow!("\"{command_name}\" failed: {error:?}"))
Err(anyhow!("\"{command_name}\" failed: {}", error.display()))
}
Err(e) => Err(anyhow!("Error waiting for process \"{command_name}\": {e}")),
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/extractor/bmn/src/file_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ fn relativize_path(path: PathBuf) -> Result<PathBuf> {
Ok(PathBuf::from_iter(sliced))
}
_ => Err(anyhow!(
"Path cannot start with .. or the drive prefix: {path:?}"
"Path cannot start with .. or the drive prefix: {}",
path.display()
)),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ fn execute_command_with_args_get_stderr(cmd: &OsStr, args: &[&str]) -> Result<Ve
match Command::new(cmd).args(args).stdin(Stdio::piped()).output() {
Ok(output) if output.status.success() => Ok(output.stderr),
_ => Err(anyhow!(
"Error invoking the compiler {cmd:?} to get the default include folders."
"Error invoking the compiler {} to get the default include folders.",
cmd.display()
)),
}
}
Expand Down Expand Up @@ -597,7 +598,7 @@ End of search list."#;
assert_true!(output.is_err());
assert_eq!(
output.unwrap_err().to_string(),
format!("Error invoking the compiler {cmd:?} to get the default include folders.")
"Error invoking the compiler command-not-existing to get the default include folders."
);
}

Expand All @@ -608,7 +609,7 @@ End of search list."#;
assert_true!(result.is_err());
assert_eq!(
result.unwrap_err().to_string(),
format!("Error invoking the compiler {cmd:?} to get the default include folders.")
"Error invoking the compiler command-not-existing to get the default include folders."
);
}
}
4 changes: 2 additions & 2 deletions cpp/extractor/bmn/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ fn get_extractor_executable() -> Result<PathBuf> {
let extractor = PathBuf::from_iter([&root_dir, "tools", &platform, &binary_name]);
if !extractor.exists() {
Err(anyhow::anyhow!(
"Extractor executable not found at: {:?}",
extractor
"Extractor executable not found at: {}",
extractor.display()
))
} else {
Ok(extractor)
Expand Down
42 changes: 32 additions & 10 deletions cpp/extractor/bmn/src/package_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,27 @@ pub fn get_package_database() -> anyhow::Result<PackageDatabase> {
{
if !path.exists() {
return Err(anyhow!(
"Local deptrace database path specified but file does not exist: {path:?}.",
"Local deptrace database path specified but file does not exist: {}.",
path.display()
));
}
debug!(
"Using local deptrace database from {}: {path:?}",
environment::CODEQL_EXTRACTOR_CPP_LOCAL_DEPTRACE_DB,
);
fs::read_to_string(&path)
.map_err(|e| anyhow!("Failed to read local deptrace database from {path:?}: {e}"))?
fs::read_to_string(&path).map_err(|e| {
anyhow!(
"Failed to read local deptrace database from {}: {e}",
path.display()
)
})?
} else {
let archive_file_path = get_deptrace_db_zip_path()?;
extract_content_from_zip(&archive_file_path).map_err(|e| {
anyhow!("Failed to extract package database from {archive_file_path:?}: {e}")
anyhow!(
"Failed to extract package database from {}: {e}",
archive_file_path.display()
)
})?
};
PackageDatabase::from_deptrace_content(&content)
Expand Down Expand Up @@ -213,17 +221,31 @@ fn infer_os_version_name() -> Option<OsReleaseInfo> {
/// as a string.
fn extract_content_from_zip(archive_zip_name: &Path) -> anyhow::Result<String> {
let inner_file_name = "deptrace-db.txt";
let file = File::open(archive_zip_name)
.map_err(|e| anyhow!("Could not open archive zip name {archive_zip_name:?}: {e}"))?;
let mut archive = ZipArchive::new(file)
.map_err(|e| anyhow!("Could not read zip archive {archive_zip_name:?}: {e}"))?;
let file = File::open(archive_zip_name).map_err(|e| {
anyhow!(
"Could not open archive zip name {}: {e}",
archive_zip_name.display()
)
})?;
let mut archive = ZipArchive::new(file).map_err(|e| {
anyhow!(
"Could not read zip archive {}: {e}",
archive_zip_name.display()
)
})?;
let mut zipped_file = archive.by_name(inner_file_name).map_err(|e| {
anyhow!("Could not find {inner_file_name} in archive {archive_zip_name:?}: {e}")
anyhow!(
"Could not find {inner_file_name} in archive {}: {e}",
archive_zip_name.display()
)
})?;

let mut buffer = String::new();
zipped_file.read_to_string(&mut buffer).map_err(|e| {
anyhow!("Could not read {inner_file_name} from archive {archive_zip_name:?}: {e}")
anyhow!(
"Could not read {inner_file_name} from archive {}: {e}",
archive_zip_name.display()
)
})?;

Ok(buffer)
Expand Down
12 changes: 0 additions & 12 deletions misc/bazel/3rdparty/rust_workspace_deps/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions misc/bazel/3rdparty/rust_workspace_deps/crates.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

15 changes: 0 additions & 15 deletions misc/bazel/3rdparty/rust_workspace_deps/lazy_static/BUILD.bazel

This file was deleted.

1 change: 0 additions & 1 deletion ql/buramu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
workspace = true

[dependencies]
lazy_static = "1.4.0"
chrono = "0.4.37"
rayon = "1.9.0"
regex = "1.10.4"
12 changes: 5 additions & 7 deletions ql/buramu/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use lazy_static::lazy_static;
use rayon::prelude::*;
use regex::Regex;
use std::collections::HashMap;
use std::sync::LazyLock;
use std::{io::BufRead, process::Command};

// A map from filenames to lists of line numbers (for just the lines with deprecations)
Expand Down Expand Up @@ -53,7 +53,7 @@ fn get_blame_dates_for_filedeprecation(file: &str, linenos: &[String]) -> LastMo
let mut command = Command::new("git");
command.arg("blame");
for lineno in linenos {
command.arg("-L").arg(format!("{},{}", lineno, lineno));
command.arg("-L").arg(format!("{lineno},{lineno}"));
}
command.arg(file);
let output = command.output().expect("failed to execute process");
Expand All @@ -69,10 +69,8 @@ fn get_blame_dates_for_filedeprecation(file: &str, linenos: &[String]) -> LastMo
blame_dates
}

lazy_static! {
static ref BLAME_RE: Regex =
Regex::new("(\\d{4}-\\d{2}-\\d{2}).*[+-]\\d{4}\\s+(\\d+)\\)").unwrap();
}
static BLAME_RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new("(\\d{4}-\\d{2}-\\d{2}).*[+-]\\d{4}\\s+(\\d+)\\)").unwrap());

fn get_last_modified(line: &str) -> LastModifiedLine {
let caps = BLAME_RE.captures(line).unwrap();
Expand All @@ -97,7 +95,7 @@ fn main() {
.par_iter()
.map(|(file, linenos)| (file, get_blame_dates_for_filedeprecation(file, linenos)));
deprecations.for_each(|(file, linenos_and_dates)| {
println!("file: {}", file);
println!("file: {file}");
for (date, linenos) in &linenos_and_dates {
println!(" last_modified: {} {}", date, linenos.join(" "));
}
Expand Down
1 change: 0 additions & 1 deletion ruby/extractor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
rayon = "1.12.0"
regex = "1.13.1"
encoding = "0.2"
lazy_static = "1.5.1"
serde_json = "1.0.154"

codeql-extractor = { path = "../../shared/tree-sitter-extractor" }
Loading
Loading