FIX: Make clippy happy

This commit is contained in:
Nicolás Hatcher
2025-06-29 10:23:32 +02:00
committed by Nicolás Hatcher Andrés
parent 46ea92966f
commit 0be7d9b85a
39 changed files with 200 additions and 224 deletions

View File

@@ -148,8 +148,8 @@ pub fn load_from_xlsx(file_name: &str, locale: &str, tz: &str) -> Result<Model,
/// Loads a [Model] from an `ic` file (a file in the IronCalc internal representation)
pub fn load_from_icalc(file_name: &str) -> Result<Model, XlsxError> {
let contents = fs::read(file_name)
.map_err(|e| XlsxError::IO(format!("Could not extract workbook name: {}", e)))?;
.map_err(|e| XlsxError::IO(format!("Could not extract workbook name: {e}")))?;
let workbook: Workbook = bitcode::decode(&contents)
.map_err(|e| XlsxError::IO(format!("Failed to decode file: {}", e)))?;
.map_err(|e| XlsxError::IO(format!("Failed to decode file: {e}")))?;
Model::from_workbook(workbook).map_err(XlsxError::Workbook)
}

View File

@@ -142,7 +142,7 @@ pub(super) fn load_styles<R: Read + std::io::Seek>(
}
"charset" => {}
_ => {
println!("Unexpected feature {:?}", feature);
println!("Unexpected feature {feature:?}");
}
}
}

View File

@@ -21,7 +21,7 @@ where
{
let attr_name = attr_name.into();
node.attribute(attr_name)
.ok_or_else(|| XlsxError::Xml(format!("Missing \"{:?}\" XML attribute", attr_name)))
.ok_or_else(|| XlsxError::Xml(format!("Missing \"{attr_name:?}\" XML attribute")))
}
pub(super) fn get_value_or_default(node: &Node, tag_name: &str, default: &str) -> String {
@@ -64,7 +64,7 @@ pub(super) fn get_color(node: Node) -> Result<Option<String>, XlsxError> {
// A boolean value indicating the color is automatic and system color dependent.
Ok(None)
} else {
println!("Unexpected color node {:?}", node);
println!("Unexpected color node {node:?}");
Ok(None)
}
}

View File

@@ -40,7 +40,7 @@ pub(super) fn load_workbook<R: Read + std::io::Seek>(
Some("visible") | None => SheetState::Visible,
Some("hidden") => SheetState::Hidden,
Some("veryHidden") => SheetState::VeryHidden,
Some(state) => return Err(XlsxError::Xml(format!("Unknown sheet state: {}", state))),
Some(state) => return Err(XlsxError::Xml(format!("Unknown sheet state: {state}"))),
};
sheets.push(Sheet {
name,

View File

@@ -81,7 +81,7 @@ fn parse_cell_reference(cell: &str) -> Result<(i32, i32), String> {
if let Some(r) = parse_reference_a1(cell) {
Ok((r.row, r.column))
} else {
Err(format!("Invalid cell reference: '{}'", cell))
Err(format!("Invalid cell reference: '{cell}'"))
}
}
@@ -91,17 +91,17 @@ fn parse_range(range: &str) -> Result<(i32, i32, i32, i32), String> {
if let Some(r) = parse_reference_a1(parts[0]) {
Ok((r.row, r.column, r.row, r.column))
} else {
Err(format!("Invalid range: '{}'", range))
Err(format!("Invalid range: '{range}'"))
}
} else if parts.len() == 2 {
match (parse_reference_a1(parts[0]), parse_reference_a1(parts[1])) {
(Some(left), Some(right)) => {
return Ok((left.row, left.column, right.row, right.column));
}
_ => return Err(format!("Invalid range: '{}'", range)),
_ => return Err(format!("Invalid range: '{range}'")),
}
} else {
return Err(format!("Invalid range: '{}'", range));
return Err(format!("Invalid range: '{range}'"));
}
}
@@ -390,7 +390,7 @@ fn get_cell_from_excel(
}
"d" => {
// Not implemented
println!("Invalid type (d) in {}!{}", sheet_name, cell_ref);
println!("Invalid type (d) in {sheet_name}!{cell_ref}");
Cell::ErrorCell {
ei: Error::NIMPL,
s: cell_style,
@@ -398,7 +398,7 @@ fn get_cell_from_excel(
}
"inlineStr" => {
// Not implemented
println!("Invalid type (inlineStr) in {}!{}", sheet_name, cell_ref);
println!("Invalid type (inlineStr) in {sheet_name}!{cell_ref}");
Cell::ErrorCell {
ei: Error::NIMPL,
s: cell_style,
@@ -408,8 +408,7 @@ fn get_cell_from_excel(
_ => {
// error
println!(
"Unexpected type ({}) in {}!{}",
cell_type, sheet_name, cell_ref
"Unexpected type ({cell_type}) in {sheet_name}!{cell_ref}"
);
Cell::ErrorCell {
ei: Error::ERROR,
@@ -444,15 +443,15 @@ fn get_cell_from_excel(
f: formula_index,
ei: get_error_by_english_name(error_name).unwrap_or(Error::ERROR),
s: cell_style,
o: format!("{}!{}", sheet_name, cell_ref),
o: format!("{sheet_name}!{cell_ref}"),
m: cell_value.unwrap_or("#ERROR!").to_string(),
}
}
"s" => {
// Not implemented
let o = format!("{}!{}", sheet_name, cell_ref);
let o = format!("{sheet_name}!{cell_ref}");
let m = Error::NIMPL.to_string();
println!("Invalid type (s) in {}!{}", sheet_name, cell_ref);
println!("Invalid type (s) in {sheet_name}!{cell_ref}");
Cell::CellFormulaError {
f: formula_index,
ei: Error::NIMPL,
@@ -471,8 +470,8 @@ fn get_cell_from_excel(
}
"d" => {
// Not implemented
println!("Invalid type (d) in {}!{}", sheet_name, cell_ref);
let o = format!("{}!{}", sheet_name, cell_ref);
println!("Invalid type (d) in {sheet_name}!{cell_ref}");
let o = format!("{sheet_name}!{cell_ref}");
let m = Error::NIMPL.to_string();
Cell::CellFormulaError {
f: formula_index,
@@ -484,9 +483,9 @@ fn get_cell_from_excel(
}
"inlineStr" => {
// Not implemented
let o = format!("{}!{}", sheet_name, cell_ref);
let o = format!("{sheet_name}!{cell_ref}");
let m = Error::NIMPL.to_string();
println!("Invalid type (inlineStr) in {}!{}", sheet_name, cell_ref);
println!("Invalid type (inlineStr) in {sheet_name}!{cell_ref}");
Cell::CellFormulaError {
f: formula_index,
ei: Error::NIMPL,
@@ -498,10 +497,9 @@ fn get_cell_from_excel(
_ => {
// error
println!(
"Unexpected type ({}) in {}!{}",
cell_type, sheet_name, cell_ref
"Unexpected type ({cell_type}) in {sheet_name}!{cell_ref}"
);
let o = format!("{}!{}", sheet_name, cell_ref);
let o = format!("{sheet_name}!{cell_ref}");
let m = Error::ERROR.to_string();
Cell::CellFormulaError {
f: formula_index,
@@ -886,7 +884,7 @@ pub(super) fn load_sheet<R: Read + std::io::Seek>(
Some(_) => {
// It's the mother cell. We do not use the ref attribute in IronCalc
let formula = fs[0].text().unwrap_or("").to_string();
let context = format!("{}!{}", sheet_name, cell_ref);
let context = format!("{sheet_name}!{cell_ref}");
let formula = from_a1_to_rc(
formula,
worksheets,
@@ -949,7 +947,7 @@ pub(super) fn load_sheet<R: Read + std::io::Seek>(
}
// Its a cell with a simple formula
let formula = fs[0].text().unwrap_or("").to_string();
let context = format!("{}!{}", sheet_name, cell_ref);
let context = format!("{sheet_name}!{cell_ref}");
let formula = from_a1_to_rc(
formula,
worksheets,
@@ -968,8 +966,7 @@ pub(super) fn load_sheet<R: Read + std::io::Seek>(
}
_ => {
return Err(XlsxError::Xml(format!(
"Invalid formula type {:?}.",
formula_type,
"Invalid formula type {formula_type:?}.",
)));
}
}