Skip to content

Commit 53edb8c

Browse files
committed
fix(clippy): resolve all lint errors for Rust 1.94 (round 2)
1 parent c9a6f31 commit 53edb8c

18 files changed

Lines changed: 43 additions & 44 deletions

File tree

core/src/composite_document_parser/extract/structured.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub(super) fn parse_ipynb(path: &Path) -> Result<ParsedDocument> {
8484
.with_ordinal(0)
8585
.with_attribute("record_type", "notebook-metadata");
8686
if !payload.is_empty() {
87-
if let Some(serialized) = serde_json::to_string(&payload).ok() {
87+
if let Ok(serialized) = serde_json::to_string(&payload) {
8888
block = block.with_structured_payload(serialized);
8989
}
9090
}
@@ -145,7 +145,7 @@ pub(super) fn parse_ipynb(path: &Path) -> Result<ParsedDocument> {
145145
.with_source("cells")
146146
.with_ordinal(idx + 1)
147147
.with_attribute("cell_type", cell_type);
148-
if let Some(serialized) = serde_json::to_string(&payload).ok() {
148+
if let Ok(serialized) = serde_json::to_string(&payload) {
149149
block = block.with_structured_payload(serialized);
150150
}
151151
doc.push(block);

core/src/composite_document_parser/extract/text.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn process_table_row_markers(text: &str, default_kind: DocumentBlockKind) -> Vec
164164
table_rows.clear();
165165
// Also flush any pending text
166166
if !current_text.trim().is_empty() {
167-
result.extend(chunk_to_blocks(&current_text.trim(), default_kind.clone()));
167+
result.extend(chunk_to_blocks(current_text.trim(), default_kind.clone()));
168168
current_text.clear();
169169
}
170170
// Process this non-table line
@@ -190,7 +190,7 @@ fn process_table_row_markers(text: &str, default_kind: DocumentBlockKind) -> Vec
190190

191191
// Flush remaining text
192192
if !current_text.trim().is_empty() {
193-
result.extend(chunk_to_blocks(&current_text.trim(), default_kind));
193+
result.extend(chunk_to_blocks(current_text.trim(), default_kind));
194194
}
195195

196196
result

core/src/composite_document_parser/format/container.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,15 @@ pub(super) fn parse_7z(path: &Path) -> Result<ParsedDocument> {
189189
);
190190
};
191191

192-
let entries = list_7z_entries(&binary, path)?;
192+
let entries = list_7z_entries(binary, path)?;
193193
let entry_count = entries.len();
194194
let mut extracted = Vec::new();
195195
for name in entries {
196196
let lower = name.to_ascii_lowercase();
197197
if !is_archive_entry_candidate(&lower) {
198198
continue;
199199
}
200-
let bytes = extract_7z_entry(&binary, path, &name)?;
200+
let bytes = extract_7z_entry(binary, path, &name)?;
201201
extracted.push((name, bytes));
202202
}
203203

@@ -599,15 +599,15 @@ fn parse_7z_bytes(name: &str, bytes: Vec<u8>, depth: usize) -> Result<ParsedDocu
599599
anyhow::bail!("no 7z/7zz/7za binary found on PATH");
600600
};
601601

602-
let entries = list_7z_entries(&binary, &path)?;
602+
let entries = list_7z_entries(binary, &path)?;
603603
let entry_count = entries.len();
604604
let mut extracted = Vec::new();
605605
for entry_name in entries {
606606
let lower = entry_name.to_ascii_lowercase();
607607
if !is_archive_entry_candidate(&lower) {
608608
continue;
609609
}
610-
let bytes = extract_7z_entry(&binary, &path, &entry_name)?;
610+
let bytes = extract_7z_entry(binary, &path, &entry_name)?;
611611
extracted.push((entry_name, bytes));
612612
}
613613

@@ -745,7 +745,7 @@ fn decode_text_bytes(bytes: &[u8]) -> Result<String> {
745745
return Ok(text.to_string());
746746
}
747747

748-
if bytes.len() >= 2 && bytes.len() % 2 == 0 {
748+
if bytes.len() >= 2 && bytes.len().is_multiple_of(2) {
749749
let utf16: Vec<u16> = bytes
750750
.chunks_exact(2)
751751
.map(|chunk| u16::from_le_bytes([chunk[0], chunk[1]]))

core/src/composite_document_parser/format/office.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ fn normalize_legacy_text(text: &str, kind: LegacyOfficeKind) -> String {
857857
}
858858

859859
fn decode_utf16le_text(bytes: &[u8]) -> Option<String> {
860-
if bytes.len() < 4 || bytes.len() % 2 != 0 {
860+
if bytes.len() < 4 || !bytes.len().is_multiple_of(2) {
861861
return None;
862862
}
863863

@@ -1472,7 +1472,7 @@ pub(super) fn infer_xlsb_row_major_rows(values: &[String]) -> Option<Vec<Vec<Str
14721472
let mut best: Option<(usize, Vec<Vec<String>>)> = None;
14731473

14741474
for column_count in 2..=max_columns {
1475-
if values.len() % column_count != 0 {
1475+
if !values.len().is_multiple_of(column_count) {
14761476
continue;
14771477
}
14781478

@@ -1503,7 +1503,7 @@ pub(super) fn infer_xlsb_column_major_rows(values: &[String]) -> Option<Vec<Vec<
15031503
let mut best: Option<(usize, Vec<Vec<String>>)> = None;
15041504

15051505
for column_count in 2..=max_columns {
1506-
if values.len() % column_count != 0 {
1506+
if !values.len().is_multiple_of(column_count) {
15071507
continue;
15081508
}
15091509
let rows_per_column = values.len() / column_count;

core/src/composite_document_parser/format/structured.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(super) fn parse_ics_string(
1919
normalize_text: fn(&str) -> String,
2020
tagged_fields_to_text: fn(&std::collections::BTreeMap<String, String>, &[&str]) -> String,
2121
) -> Result<ParsedDocument> {
22-
let lines = unfold_structured_text_lines(&raw);
22+
let lines = unfold_structured_text_lines(raw);
2323
let mut doc = ParsedDocument::new();
2424
doc.title = super::file_title(path);
2525

@@ -118,7 +118,7 @@ pub(super) fn parse_vcf_string(
118118
normalize_text: fn(&str) -> String,
119119
tagged_fields_to_text: fn(&std::collections::BTreeMap<String, String>, &[&str]) -> String,
120120
) -> Result<ParsedDocument> {
121-
let lines = unfold_structured_text_lines(&raw);
121+
let lines = unfold_structured_text_lines(raw);
122122
let mut doc = ParsedDocument::new();
123123
doc.title = super::file_title(path);
124124

core/src/composite_document_parser/mail/email.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub(super) fn push_mail_blocks(
110110
.with_source("message")
111111
.with_ordinal(ordinal)
112112
.with_attribute("record_type", "email-headers");
113-
if let Some(serialized) = serde_json::to_string(&payload).ok() {
113+
if let Ok(serialized) = serde_json::to_string(&payload) {
114114
block = block.with_structured_payload(serialized);
115115
}
116116
doc.push(block);

core/src/composite_document_parser/mail/msg.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub(super) fn parse_msg(path: &Path, normalize_text: fn(&str) -> String) -> Resu
127127
.with_source("msg")
128128
.with_ordinal(1)
129129
.with_attribute("record_type", "email-headers");
130-
if let Some(serialized) = serde_json::to_string(&payload).ok() {
130+
if let Ok(serialized) = serde_json::to_string(&payload) {
131131
block = block.with_structured_payload(serialized);
132132
}
133133
doc.push(block);
@@ -161,7 +161,7 @@ pub(super) fn parse_msg(path: &Path, normalize_text: fn(&str) -> String) -> Resu
161161
.with_ordinal(3)
162162
.with_attribute("record_type", "attachments")
163163
.with_attribute("attachment_count", attachments.len().to_string());
164-
if let Some(payload) = serde_json::to_string(&attachments).ok() {
164+
if let Ok(payload) = serde_json::to_string(&attachments) {
165165
block = block.with_structured_payload(payload);
166166
}
167167
doc.push(block);
@@ -551,8 +551,7 @@ fn select_subject(strings: &[String]) -> Option<String> {
551551
.iter()
552552
.find(|text| {
553553
let len = text.chars().count();
554-
len >= 4
555-
&& len <= 120
554+
(4..=120).contains(&len)
556555
&& text
557556
.chars()
558557
.next()

core/src/composite_document_parser/normalize/paged.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,12 @@ pub(super) fn append_page_lines(page: &str, extra_lines: &[String]) -> String {
317317
pub(super) fn remove_first_n_non_empty_lines(page: &str, count: usize) -> String {
318318
let mut removed = 0usize;
319319
page.lines()
320-
.filter_map(|line| {
320+
.filter(|line| {
321321
if removed < count && !line.trim().is_empty() {
322322
removed += 1;
323-
None
323+
false
324324
} else {
325-
Some(line)
325+
true
326326
}
327327
})
328328
.collect::<Vec<_>>()

core/src/composite_document_parser/ocr/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ fn parse_pdf(path: &Path) -> Result<String> {
399399
#[derive(Debug, Clone)]
400400
struct PositionedTextItem {
401401
page: usize,
402+
#[allow(dead_code)]
402403
y: f32,
403404
x: f32,
404405
text: String,

core/src/doc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) mod registry;
1111
pub use model::{
1212
DocumentBlock, DocumentBlockKind, DocumentBlockLocation, DocumentConfidence,
1313
DocumentExtractionMetadata, DocumentMetadata, DocumentProvenance, ExtractedDocument,
14-
ParsedDocument, StructuredElement, StructuredElementKind,
14+
ParsedDocument,
1515
};
1616
pub use parser::DocumentParser;
1717
pub use registry::DocumentParserRegistry;

0 commit comments

Comments
 (0)