FIX: Forbid unwrap, expect and panic in the base code

This commit is contained in:
Nicolás Hatcher
2024-11-16 14:18:12 +01:00
committed by Nicolás Hatcher Andrés
parent bdd2c8fe04
commit 49ae2d8915
43 changed files with 341 additions and 128 deletions

View File

@@ -41,6 +41,7 @@ pub use crate::mock_time::get_milliseconds_since_epoch;
/// * Or mocked for tests
#[cfg(not(test))]
#[cfg(not(target_arch = "wasm32"))]
#[allow(clippy::expect_used)]
pub fn get_milliseconds_since_epoch() -> i64 {
use std::time::{SystemTime, UNIX_EPOCH};
SystemTime::now()
@@ -529,6 +530,7 @@ impl Model {
}
}
#[allow(clippy::expect_used)]
fn cell_reference_to_string(
&self,
cell_reference: &CellReferenceIndex,
@@ -544,6 +546,7 @@ impl Model {
/// Sets `result` in the cell given by `sheet` sheet index, row and column
/// Note that will panic if the cell does not exist
/// It will do nothing if the cell does not have a formula
#[allow(clippy::expect_used)]
fn set_cell_value(&mut self, cell_reference: CellReferenceIndex, result: &CalcResult) {
let CellReferenceIndex { sheet, column, row } = cell_reference;
let cell = &self.workbook.worksheets[sheet as usize].sheet_data[&row][&column];
@@ -875,6 +878,7 @@ impl Model {
.map_err(|_| format!("Invalid timezone: {}", workbook.settings.tz))?;
// FIXME: Add support for display languages
#[allow(clippy::expect_used)]
let language = get_language("en").expect("").clone();
let mut shared_strings = HashMap::new();
for (index, s) in workbook.shared_strings.iter().enumerate() {
@@ -1986,6 +1990,7 @@ impl Model {
#[cfg(test)]
mod tests {
#![allow(clippy::expect_used)]
use super::CellReferenceIndex as CellReference;
use crate::{test::util::new_empty_model, types::Cell};