style(parser): clear pre-existing clippy warnings

cargo clippy --all-targets -- -D warnings failed with 8 errors before the schema
refactor and was never part of CI. Clearing them so the gate is meaningful from
here on.

All behaviour-preserving: slice contains() over iter().any(), is_multiple_of()
over a modulo, a needless borrow in a test helper, and a doc-list indent.
process_mapped_row keeps its 8 parameters behind an allow attribute — the
signature mirrors the JS column map one-for-one, and bundling the indices into
a struct would hide that correspondence.

Kept separate from the schema change so that diff stays readable.
This commit is contained in:
tiennm99 committed 2026-08-13 11:16:51 +07:00
1 parent cd4b07f9cb
commit 82db8295bb
3 files changed
+10 -7

No files matched your search

@@ -7,7 +7,7 @@
/// ///
/// 1. `separate-scores` — header row[0]=="SBD" && row[2]=="TOAN" /// 1. `separate-scores` — header row[0]=="SBD" && row[2]=="TOAN"
/// Columns: SBD(0) HOTEN(1) TOAN(2) VAN(3) LY(4) HOA(5) SINH(6) SU(7) DIA(8) /// Columns: SBD(0) HOTEN(1) TOAN(2) VAN(3) LY(4) HOA(5) SINH(6) SU(7) DIA(8)
/// NGOAINGUTN(9) NGOAINGUTL(10) NGOAINGU-total(11) /// NGOAINGUTN(9) NGOAINGUTL(10) NGOAINGU-total(11)
/// → maps col 11 → tieng_anh; no ngay_sinh / ten_cum_thi / gioi_tinh / DIEM_THI /// → maps col 11 → tieng_anh; no ngay_sinh / ten_cum_thi / gioi_tinh / DIEM_THI
/// → JS: build-database.js:90–116 (processSeparateScoresRow) /// → JS: build-database.js:90–116 (processSeparateScoresRow)
/// ///
@@ -57,7 +57,7 @@ pub fn is_header_row_2016(row: &[Data]) -> bool {
return false; return false;
} }
let first = row[0].to_string().trim().to_uppercase(); let first = row[0].to_string().trim().to_uppercase();
KNOWN_HEADERS.iter().any(|h| *h == first.as_str()) KNOWN_HEADERS.contains(&first.as_str())
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -217,6 +217,9 @@ pub fn process_separate_scores_row(row: &[Data], patterns: &CompiledPatterns) ->
/// Mirrors `processMappedRow` at build-database.js:119–146. /// Mirrors `processMappedRow` at build-database.js:119–146.
/// Gender is normalised: only "Nam" or "Nữ" are kept; everything else → None. /// Gender is normalised: only "Nam" or "Nữ" are kept; everything else → None.
/// (build-database.js:132: `(rawGioiTinh === "Nam" || rawGioiTinh === "Nữ") ? rawGioiTinh : null`) /// (build-database.js:132: `(rawGioiTinh === "Nam" || rawGioiTinh === "Nữ") ? rawGioiTinh : null`)
// Mirrors the JS column map one-for-one; grouping the indices into a struct
// would obscure that correspondence for no benefit.
#[allow(clippy::too_many_arguments)]
pub fn process_mapped_row( pub fn process_mapped_row(
row: &[Data], row: &[Data],
sbd_idx: usize, sbd_idx: usize,
@@ -237,8 +240,8 @@ pub fn process_mapped_row(
// build-database.js:125–126: KNOWN_HEADERS.has(sbdUpper) || KNOWN_HEADERS.has(hoTenUpper) // build-database.js:125–126: KNOWN_HEADERS.has(sbdUpper) || KNOWN_HEADERS.has(hoTenUpper)
let sbd_upper = sbd.to_uppercase(); let sbd_upper = sbd.to_uppercase();
let ho_ten_upper = ho_ten.to_uppercase(); let ho_ten_upper = ho_ten.to_uppercase();
if KNOWN_HEADERS.iter().any(|h| *h == sbd_upper.as_str()) if KNOWN_HEADERS.contains(&sbd_upper.as_str())
|| KNOWN_HEADERS.iter().any(|h| *h == ho_ten_upper.as_str()) || KNOWN_HEADERS.contains(&ho_ten_upper.as_str())
{ {
return None; return None;
} }
+1 -1
View File
@@ -326,7 +326,7 @@ mod tests {
let s = "Toán: 8.5"; let s = "Toán: 8.5";
let scores = parse_scores(s, &p); let scores = parse_scores(s, &p);
assert_eq!(scores.get("toan"), Some(&8.5)); assert_eq!(scores.get("toan"), Some(&8.5));
assert!(scores.get("ngu_van").is_none()); assert!(!scores.contains_key("ngu_van"));
} }
#[test] #[test]
+2 -2
View File
@@ -125,7 +125,7 @@ fn write_xlsx(path: &Path, sheets: &[(String, Vec<XlsxRow>)]) {
ws.push_str(" </row>\n"); ws.push_str(" </row>\n");
} }
ws.push_str(" </sheetData>\n</worksheet>"); ws.push_str(" </sheetData>\n</worksheet>");
zip.start_file(&format!("xl/worksheets/sheet{}.xml", i + 1), opts) zip.start_file(format!("xl/worksheets/sheet{}.xml", i + 1), opts)
.unwrap(); .unwrap();
zip.write_all(ws.as_bytes()).unwrap(); zip.write_all(ws.as_bytes()).unwrap();
} }
@@ -165,7 +165,7 @@ fn header_row() -> XlsxRow {
fn data_row(idx: usize, scores: &str) -> XlsxRow { fn data_row(idx: usize, scores: &str) -> XlsxRow {
// Anonymised: name uses sequential pattern, SBD is purely synthetic // Anonymised: name uses sequential pattern, SBD is purely synthetic
let name = if idx % 2 == 0 { let name = if idx.is_multiple_of(2) {
format!("Nguyen Van Test {:03}", idx) format!("Nguyen Van Test {:03}", idx)
} else { } else {
format!("Tran Thi Test {:03}", idx) format!("Tran Thi Test {:03}", idx)