Skip to content

Commit 104b5ab

Browse files
cursoragentscript3r
andcommitted
Refactor: Use Path instead of PathBuf in test helpers
Co-authored-by: script3r <[email protected]>
1 parent bf70764 commit 104b5ab

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

crates/cli/tests/anchors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use scanner_core::*;
22
use std::fs;
3-
use std::path::PathBuf;
3+
use std::path::{Path, PathBuf};
44
use std::sync::Arc;
55
use std::time::{SystemTime, UNIX_EPOCH};
66

7-
fn write_file(dir: &PathBuf, rel: &str, contents: &str) {
7+
fn write_file(dir: &Path, rel: &str, contents: &str) {
88
let path = dir.join(rel);
99
if let Some(parent) = path.parent() {
1010
fs::create_dir_all(parent).unwrap();

crates/cli/tests/filtering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use scanner_core::*;
22
use std::fs;
3-
use std::path::PathBuf;
3+
use std::path::{Path, PathBuf};
44
use std::sync::Arc;
55
use std::time::{SystemTime, UNIX_EPOCH};
66

7-
fn write_file(dir: &PathBuf, rel: &str, contents: &str) {
7+
fn write_file(dir: &Path, rel: &str, contents: &str) {
88
let path = dir.join(rel);
99
if let Some(parent) = path.parent() {
1010
fs::create_dir_all(parent).unwrap();

crates/scanner-core/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,13 +1016,11 @@ impl PatternDetector {
10161016
last_api = Some((m.start(), re.as_str().to_string()));
10171017
}
10181018
}
1019-
if api_hits > 0 {
1020-
if first_symbol.is_empty() {
1021-
if let Some((pos, sym)) = last_api.clone() {
1022-
first_span = index.to_line_col(pos);
1023-
first_symbol = sym;
1024-
first_snippet = extract_line(stripped_s, pos);
1025-
}
1019+
if api_hits > 0 && first_symbol.is_empty() {
1020+
if let Some((pos, sym)) = last_api.clone() {
1021+
first_span = index.to_line_col(pos);
1022+
first_symbol = sym;
1023+
first_snippet = extract_line(stripped_s, pos);
10261024
}
10271025
}
10281026
// Require anchor only if patterns define any; always require at least one API hit

0 commit comments

Comments
 (0)