Skip to content

Commit e16e825

Browse files
hyperpolymathclaude
andcommitted
fix: unbreak rust-ci Test job (clippy 1.95 + missing fields)
`cargo clippy --all-targets --all-features -- -D warnings` and `cargo test` were both red on main: * clippy 1.95.0 surfaced new lints across lib/tests/bench: unnecessary_map_or, manual_range_contains, unnecessary_sort_by, needless_range_loop, type_complexity, new_without_default, redundant_closure, redundant_pattern_matching, useless_vec, len_zero, const_is_empty, format_in_format_args. * `criterion::black_box` is deprecated in favour of `std::hint::black_box`. * `tests/panll_tests.rs` + `tests/report_tests.rs` constructed `CrashReport` without the (non-default) `schema_version` field that was added in v2.5; `benches/scan_bench.rs` constructed `ProgramStatistics` without `safe_unwrap_calls`. All edits are semantic identities: sort_by → sort_by_key + Reverse, needless range-loop → enumerate-over-iter, fn-pointer column → type alias, MitigationRegistry::new() → Default impl forwarding, `(200..300).contains(&status)` for HTTP status check, `is_some_and` in place of `map_or(false, ...)`, etc. The `tests/seam_contract_tests.rs` fmt collapses on lines 433/490 overlap with PR #36 (same fix) — second to land will be a no-op. Estate guardrail: no Python, no PMPL-1.0, signed commit, MSRV-safe identities only (no new API surface, no feature changes). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent caa407f commit e16e825

14 files changed

Lines changed: 47 additions & 37 deletions

File tree

benches/scan_bench.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
//!
66
//! Measures: language detection, pattern matching, full analysis pipeline.
77
8-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
8+
use criterion::{criterion_group, criterion_main, Criterion};
99
use panic_attack::types::Language;
10+
use std::hint::black_box;
1011

1112
/// Benchmark language detection from file extension
1213
fn bench_language_detect(c: &mut Criterion) {
@@ -223,6 +224,7 @@ fn bench_statistics_calculation(c: &mut Criterion) {
223224
unsafe_blocks: 5,
224225
panic_sites: 0,
225226
unwrap_calls: 50,
227+
safe_unwrap_calls: 0,
226228
allocation_sites: 12,
227229
io_operations: 4,
228230
threading_constructs: 3,

src/assail/analyzer.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3966,7 +3966,7 @@ impl Analyzer {
39663966

39673967
// Detect function definitions
39683968
if line.trim().starts_with("fn ") && !line.trim().starts_with("fn test") {
3969-
if let Some(func_name) = line.trim().split_whitespace().nth(1) {
3969+
if let Some(func_name) = line.split_whitespace().nth(1) {
39703970
let func_name = func_name.split('(').next().unwrap_or(func_name);
39713971
current_function = func_name.to_string();
39723972
function_calls
@@ -5174,12 +5174,11 @@ impl Analyzer {
51745174
}
51755175
}
51765176

5177-
Language::Erlang => {
5178-
if content.contains("-behaviour(gen_server)")
5179-
|| content.contains("-behaviour(supervisor)")
5180-
{
5181-
frameworks.insert(Framework::OTP);
5182-
}
5177+
Language::Erlang
5178+
if (content.contains("-behaviour(gen_server)")
5179+
|| content.contains("-behaviour(supervisor)")) =>
5180+
{
5181+
frameworks.insert(Framework::OTP);
51835182
}
51845183

51855184
Language::Go => {
@@ -6007,7 +6006,7 @@ func main() {
60076006
&& wp
60086007
.location
60096008
.as_deref()
6010-
.map_or(false, |loc| loc.contains("node_modules"))
6009+
.is_some_and(|loc| loc.contains("node_modules"))
60116010
})
60126011
.collect();
60136012

src/assemblyline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ pub fn run_with_cache(
432432
.count();
433433

434434
// Sort by weak point count descending (riskiest repos first)
435-
results.sort_by(|a, b| b.weak_point_count.cmp(&a.weak_point_count));
435+
results.sort_by_key(|r| std::cmp::Reverse(r.weak_point_count));
436436

437437
// Apply filters
438438
if config.findings_only {

src/bridge/lockfile.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ use std::path::Path;
1717
/// order. All successful parses are merged into a single list. Errors from
1818
/// individual parsers are logged as warnings and skipped so one malformed
1919
/// lockfile does not abort triage of the whole project.
20+
type LockfileParser = fn(&Path) -> Result<Vec<LockedDependency>>;
21+
2022
pub fn discover_and_parse(dir: &Path) -> Vec<LockedDependency> {
2123
let mut all = Vec::new();
2224

23-
let candidates: &[(&str, fn(&Path) -> Result<Vec<LockedDependency>>)] = &[
25+
let candidates: &[(&str, LockfileParser)] = &[
2426
("Cargo.lock", parse_cargo_lock),
2527
("mix.lock", parse_mix_lock),
2628
("package-lock.json", parse_package_lock_json),
@@ -66,7 +68,7 @@ pub fn parse_cargo_lock(path: &Path) -> Result<Vec<LockedDependency>> {
6668
if let (Some(name), Some(version)) = (current_name.take(), current_version.take()) {
6769
if current_source
6870
.as_ref()
69-
.map_or(false, |s| s.contains("registry"))
71+
.is_some_and(|s| s.contains("registry"))
7072
{
7173
deps.push(LockedDependency {
7274
name,
@@ -94,7 +96,7 @@ pub fn parse_cargo_lock(path: &Path) -> Result<Vec<LockedDependency>> {
9496
if let (Some(name), Some(version)) = (current_name, current_version) {
9597
if current_source
9698
.as_ref()
97-
.map_or(false, |s| s.contains("registry"))
99+
.is_some_and(|s| s.contains("registry"))
98100
{
99101
deps.push(LockedDependency {
100102
name,

src/bridge/reachability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn check_reachability(project_dir: &Path, crate_name: &str) -> Result<Reacha
5454
}
5555

5656
let path = entry.path();
57-
if path.extension().map_or(true, |ext| ext != "rs") {
57+
if path.extension().is_none_or(|ext| ext != "rs") {
5858
continue;
5959
}
6060

src/bridge/registry.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ pub struct MitigationRegistry {
6868
pub entries: Vec<MitigationEntry>,
6969
}
7070

71+
impl Default for MitigationRegistry {
72+
fn default() -> Self {
73+
Self::new()
74+
}
75+
}
76+
7177
impl MitigationRegistry {
7278
/// Create an empty registry.
7379
pub fn new() -> Self {

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,8 +2250,8 @@ fn run_main() -> Result<()> {
22502250
println!("Run `panic-attack bridge triage --register` to populate.");
22512251
} else {
22522252
println!(
2253-
"{:<12} {:<20} {:<15} {:<15} {}",
2254-
"ID", "ADVISORY", "PACKAGE", "STATUS", "ACTION"
2253+
"{:<12} {:<20} {:<15} {:<15} ACTION",
2254+
"ID", "ADVISORY", "PACKAGE", "STATUS"
22552255
);
22562256
println!("{}", "-".repeat(80));
22572257
for entry in &registry.entries {

src/mass_panic/imaging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn build_image(report: &AssemblylineReport) -> SystemImage {
198198
.into_iter()
199199
.map(|(name, count)| CategoryCount { name, count })
200200
.collect();
201-
cats.sort_by(|a, b| b.count.cmp(&a.count));
201+
cats.sort_by_key(|c| std::cmp::Reverse(c.count));
202202
cats
203203
} else {
204204
Vec::new()

src/storage/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ pub fn push_hexad_http(hexad: &PanicAttackHexad, gateway_url: &str) -> Result<St
451451
let status = response.status().as_u16();
452452
let body = read_body(response);
453453

454-
if status >= 200 && status < 300 {
454+
if (200..300).contains(&status) {
455455
Ok(body)
456456
} else {
457457
Err(anyhow!("VeriSimDB returned {}: {}", status, body))
@@ -580,16 +580,16 @@ pub fn push_hexad_http_with_retry(hexad: &PanicAttackHexad, gateway_url: &str) -
580580
std::time::Duration::from_secs(2),
581581
std::time::Duration::from_secs(4),
582582
];
583-
let max_attempts: usize = 3;
583+
let max_attempts = delays.len();
584584
let mut last_err: Option<anyhow::Error> = None;
585585

586-
for attempt in 0..max_attempts {
586+
for (attempt, delay) in delays.iter().enumerate() {
587587
match push_hexad_http(hexad, gateway_url) {
588588
Ok(body) => return Ok(body),
589589
Err(e) => {
590590
last_err = Some(e);
591591
if attempt < max_attempts - 1 {
592-
std::thread::sleep(delays[attempt]);
592+
std::thread::sleep(*delay);
593593
}
594594
}
595595
}
@@ -632,7 +632,7 @@ pub fn push_hexads_batch(hexads: &[PanicAttackHexad], gateway_url: &str) -> Resu
632632
results.push(body);
633633
}
634634
Ok(results)
635-
} else if status >= 200 && status < 300 {
635+
} else if (200..300).contains(&status) {
636636
Ok(vec![read_body(response)])
637637
} else {
638638
let body = read_body(response);
@@ -669,7 +669,7 @@ pub fn query_hexads(gateway_url: &str, limit: usize) -> Result<Vec<PanicAttackHe
669669
let status = response.status().as_u16();
670670
let body = read_body(response);
671671

672-
if status >= 200 && status < 300 {
672+
if (200..300).contains(&status) {
673673
let hexads: Vec<PanicAttackHexad> = serde_json::from_str(&body)
674674
.map_err(|e| anyhow!("Failed to parse VeriSimDB response: {}", e))?;
675675
Ok(hexads)
@@ -708,7 +708,7 @@ pub fn check_gateway(gateway_url: &str) -> bool {
708708
let is_healthy = match builder.call() {
709709
Ok(resp) => {
710710
let s = resp.status().as_u16();
711-
s >= 200 && s < 300
711+
(200..300).contains(&s)
712712
}
713713
Err(_) => false,
714714
};

tests/aspect_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ fn aspect_parallel_analysis_correctness() {
227227
.collect();
228228

229229
// Using rayon parallel iterator (same as assemblyline)
230-
let _results: Vec<_> = files.par_iter().map(|path| assail::analyze(path)).collect();
230+
let _results: Vec<_> = files.par_iter().map(assail::analyze).collect();
231231

232232
// Should complete without data races or panics
233233
// (In practice, rayon + Rust's type system ensure this)

0 commit comments

Comments
 (0)