Skip to content

Commit a47d803

Browse files
authored
fix: resolve clippy warnings breaking CI on master (#85)
1 parent b4536eb commit a47d803

File tree

10 files changed

+30
-27
lines changed

10 files changed

+30
-27
lines changed

benches/filter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn generate_test_file(path: &Path, target_size_mb: usize) -> (u64, usize) {
133133
line_count % 1000,
134134
);
135135

136-
let line = if line_count % 3 == 0 {
136+
let line = if line_count.is_multiple_of(3) {
137137
format!(
138138
r#"{{"level":"{}","message":"{}","service":"{}","timestamp":"{}","request_id":"req-{:06}","duration_ms":{},"extra_field_1":"value_{}","extra_field_2":"another_value_{}"}}
139139
"#,
@@ -206,6 +206,7 @@ fn collect_matches(rx: std::sync::mpsc::Receiver<FilterProgress>) -> (usize, usi
206206

207207
struct FilterBenchCase {
208208
name: &'static str,
209+
#[allow(clippy::type_complexity)]
209210
run: Box<dyn Fn(&Path) -> (usize, usize)>,
210211
}
211212

benches/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn generate_test_file(path: &Path, target_size_mb: usize) -> (u64, usize) {
148148
);
149149

150150
// Alternate between JSON and logfmt to test both parsers
151-
let line = if line_count % 3 == 0 {
151+
let line = if line_count.is_multiple_of(3) {
152152
format!(
153153
r#"{{"level":"{}","message":"{}","service":"{}","timestamp":"{}","request_id":"req-{:06}","duration_ms":{},"extra_field_1":"value_{}","extra_field_2":"another_value_{}"}}
154154
"#,

examples/bench_compression.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn main() -> Result<()> {
7777
frame_buffer.push('\n');
7878
line_count += 1;
7979

80-
if line_count % frame_size as u64 == 0 {
80+
if line_count.is_multiple_of(frame_size as u64) {
8181
let original = frame_buffer.len() as u64;
8282
let compressed = compress_lz4(frame_buffer.as_bytes());
8383
let compressed_len = compressed.len() as u64;
@@ -87,7 +87,7 @@ fn main() -> Result<()> {
8787
frame_count += 1;
8888

8989
// Progress every 100 frames
90-
if frame_count % 100 == 0 {
90+
if frame_count.is_multiple_of(100) {
9191
let ratio = total_original as f64 / total_compressed as f64;
9292
println!(
9393
" Processed {} frames ({} lines) - Ratio: {:.2}x",

src/filter/query/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ mod ast;
2424
mod filter;
2525
mod parser;
2626

27-
// Re-export all public types for backward compatibility
28-
pub use ast::{
29-
Aggregation, AggregationType, ExcludePattern, FieldFilter, FilterQuery, Operator, Parser,
30-
};
27+
// Re-export public types used outside this module
28+
pub use ast::{Aggregation, FilterQuery, Parser};
3129
pub use filter::QueryFilter;
32-
pub use parser::{parse_query, QueryParseError};
30+
pub use parser::parse_query;
31+
32+
// Re-export types only used in tests
33+
#[cfg(test)]
34+
pub use ast::{AggregationType, ExcludePattern, FieldFilter, Operator};
3335

3436
// Re-export from shared parsing module
3537
pub use crate::parsing::{extract_json_field, parse_logfmt};

src/history.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn history_file_path() -> Option<PathBuf> {
1717
pub fn load_history() -> Vec<FilterHistoryEntry> {
1818
#[cfg(test)]
1919
{
20-
return Vec::new();
20+
Vec::new()
2121
}
2222

2323
#[cfg(not(test))]
@@ -37,7 +37,6 @@ pub fn save_history(history: &[FilterHistoryEntry]) {
3737
#[cfg(test)]
3838
{
3939
let _ = history;
40-
return;
4140
}
4241

4342
#[cfg(not(test))]

src/index/healing_tests.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl HealingFixture {
8484
}
8585

8686
fn open_reader(&self) -> FileReader {
87-
FileReader::new(&self.log_path()).unwrap()
87+
FileReader::new(self.log_path()).unwrap()
8888
}
8989

9090
fn assert_lines(&self, reader: &mut FileReader, expected: &[String]) {
@@ -378,8 +378,8 @@ fn detect_symlink_retarget() {
378378
let log2 = dir.path().join("real2.log");
379379
let link = dir.path().join("current.log");
380380

381-
fs::write(&log1, &make_lines(10)).unwrap();
382-
fs::write(&log2, &make_lines_offset(100, 10)).unwrap();
381+
fs::write(&log1, make_lines(10)).unwrap();
382+
fs::write(&log2, make_lines_offset(100, 10)).unwrap();
383383

384384
std::os::unix::fs::symlink(&log1, &link).unwrap();
385385
let idx_dir = index_dir_for_log(&link);
@@ -398,7 +398,7 @@ fn detect_symlink_retarget() {
398398
#[test]
399399
fn detect_index_dir_is_regular_file() {
400400
let fix = HealingFixture::new(&make_lines(5));
401-
fs::write(&fix.idx_dir(), "not a directory").unwrap();
401+
fs::write(fix.idx_dir(), "not a directory").unwrap();
402402

403403
let reader = fix.open_reader();
404404
assert!(!reader.has_columnar_offsets());
@@ -1081,7 +1081,7 @@ fn manual_edit_same_length_between_checkpoints_must_be_detected() {
10811081
content.push_str(&format!("line {:04}\n", i)); // fixed-width: "line 0005\n" = 10 bytes
10821082
}
10831083
let fix = HealingFixture::new(&content);
1084-
let meta = fix.build_index_with_interval(10);
1084+
let _meta = fix.build_index_with_interval(10);
10851085

10861086
// Edit line 5: "line 0005" → "LINE 0005" (same length)
10871087
let edited = content.replace("line 0005", "LINE 0005");
@@ -1107,7 +1107,7 @@ fn manual_edit_same_length_between_checkpoints_must_be_detected() {
11071107
#[test]
11081108
fn manual_edit_changes_line_length_must_invalidate_index() {
11091109
let fix = HealingFixture::new(&make_lines(20));
1110-
let meta = fix.build_index_with_interval(10);
1110+
let _meta = fix.build_index_with_interval(10);
11111111

11121112
// Replace line 5 with a longer version
11131113
let original = fs::read_to_string(fix.log_path()).unwrap();
@@ -1143,7 +1143,7 @@ fn manual_edit_changes_line_length_must_invalidate_index() {
11431143
#[test]
11441144
fn manual_insert_lines_in_middle_must_invalidate_index() {
11451145
let fix = HealingFixture::new(&make_lines(20));
1146-
let meta = fix.build_index_with_interval(10);
1146+
let _meta = fix.build_index_with_interval(10);
11471147

11481148
// Insert 3 lines after line 5
11491149
let original = fs::read_to_string(fix.log_path()).unwrap();
@@ -1333,8 +1333,8 @@ fn overwrite_beginning_same_size_must_be_detected() {
13331333

13341334
// Overwrite first 20 bytes with zeros (corrupts first two lines)
13351335
let mut data = fs::read(fix.log_path()).unwrap();
1336-
for i in 0..20 {
1337-
data[i] = 0;
1336+
for byte in data.iter_mut().take(20) {
1337+
*byte = 0;
13381338
}
13391339
fs::write(fix.log_path(), &data).unwrap();
13401340

@@ -1345,7 +1345,7 @@ fn overwrite_beginning_same_size_must_be_detected() {
13451345
);
13461346

13471347
// Reader must not return garbage via columnar path
1348-
let mut reader = fix.open_reader();
1348+
let reader = fix.open_reader();
13491349
assert!(
13501350
!reader.has_columnar_offsets(),
13511351
"reader must fall back to sparse after detecting corruption"

src/index/meta.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ mod tests {
234234
let path = dir.path().join("truncated_meta");
235235

236236
// Write only 32 bytes (less than META_SIZE)
237-
std::fs::write(&path, &[0u8; 32]).unwrap();
237+
std::fs::write(&path, [0u8; 32]).unwrap();
238238
let err = IndexMeta::read_from(&path).unwrap_err();
239239
assert!(err.to_string().contains("too small"));
240240
}

src/index/reader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,9 @@ mod tests {
446446
// Write offsets column
447447
let mut offsets = ColumnWriter::<u64>::create(idx_dir.join("offsets")).unwrap();
448448
let mut offset = 0u64;
449-
for i in 0..line_count {
449+
for line in lines.iter().take(line_count) {
450450
offsets.push(offset).unwrap();
451-
offset += lines[i].len() as u64 + 1; // +1 for newline
451+
offset += line.len() as u64 + 1; // +1 for newline
452452
}
453453
drop(offsets);
454454

@@ -521,7 +521,7 @@ mod tests {
521521
.append(true)
522522
.open(&log_path)
523523
.unwrap();
524-
write!(f, "line four\n").unwrap();
524+
writeln!(f, "line four").unwrap();
525525
drop(f);
526526

527527
let stats = IndexReader::stats(&log_path);

src/reader/file_reader.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,14 @@ impl FileReader {
376376

377377
/// Whether this reader has loaded columnar offsets for O(1) line access.
378378
#[cfg(test)]
379+
#[allow(dead_code)] // Used by lib tests (healing_tests), not bin tests
379380
pub(crate) fn has_columnar_offsets(&self) -> bool {
380381
self.columnar_offsets.is_some()
381382
}
382383

383384
/// Number of lines covered by the columnar index.
384385
#[cfg(test)]
386+
#[allow(dead_code)] // Used by lib tests (healing_tests), not bin tests
385387
pub(crate) fn columnar_line_count(&self) -> usize {
386388
self.indexed_lines
387389
}

src/session.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn load_last_source(project_root: Option<&Path>) -> Option<String> {
4141
#[cfg(test)]
4242
{
4343
let _ = project_root;
44-
return None;
44+
None
4545
}
4646

4747
#[cfg(not(test))]
@@ -59,7 +59,6 @@ pub fn save_last_source(project_root: Option<&Path>, name: &str) {
5959
#[cfg(test)]
6060
{
6161
let _ = (project_root, name);
62-
return;
6362
}
6463

6564
#[cfg(not(test))]

0 commit comments

Comments
 (0)