mock_gen 0.1.23

Interface and mock generator for C++ classes
use csv::ReaderBuilder;
use serde::Deserialize;

use crate::utils::lizard::lizard_types::LizardFunctionMetrics;

pub fn parse_lizard_csv(csv_content: &str, target_function: &str) -> Option<LizardFunctionMetrics> {
    println!("Parsing CSV content for function: {}", csv_content);
    // Create a CSV reader without headers
    let mut rdr = ReaderBuilder::new()
        .has_headers(false) // <-- no headers
        .from_reader(csv_content.as_bytes());

    for result in rdr.deserialize() {
        let record: LizardFunctionMetrics = match result {
            Ok(rec) => rec,
            Err(e) => {
                eprintln!("Error deserializing record: {}", e);
                continue;
            }
        };

        if record.function_name == target_function {
            return Some(record);
        }
    }

    None
}