From 178ca90f164710d791cb2db919a67cb74839707b Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Sat, 7 Sep 2024 20:15:40 +0200 Subject: [PATCH] - some warnign fixes --- src/csvparser.rs | 23 +++++++++-------------- src/gui.rs | 10 ++-------- src/pdfparser.rs | 2 +- src/pl.rs | 2 -- src/transactions.rs | 18 +++++++++--------- 5 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/csvparser.rs b/src/csvparser.rs index b8ba1f1..0ee7390 100644 --- a/src/csvparser.rs +++ b/src/csvparser.rs @@ -1,15 +1,10 @@ -pub use crate::logging::ResultExt; use nom::{ - branch::alt, bytes::complete::tag, bytes::complete::take, - character::{complete::alphanumeric1, is_digit}, error::Error, multi::many_m_n, number::complete::double, - sequence::delimited, sequence::tuple, - IResult, }; use polars::prelude::*; @@ -72,16 +67,16 @@ fn extract_cash(cashline: &str) -> Result { } fn extract_dividends_transactions(df: &DataFrame) -> Result { - let mut df_transactions = df - .select(&["Date", "Gross amount", "Withholding tax", "Currency"]) + let df_transactions = df + .select(["Date", "Gross amount", "Withholding tax", "Currency"]) .map_err(|_| "Error: Unable to select dividend data")?; Ok(df_transactions) } fn extract_sold_transactions(df: &DataFrame) -> Result { - let mut df_transactions = df - .select(&[ + let df_transactions = df + .select([ "Date acquired", "Date sold", "Cost basis", @@ -96,8 +91,8 @@ fn extract_sold_transactions(df: &DataFrame) -> Result fn extract_investment_gains_and_costs_transactions( df: &DataFrame, ) -> Result { - let mut df_transactions = df - .select(&["Date", "Type", "Total Amount"]) + let df_transactions = df + .select(["Date", "Type", "Total Amount"]) .map_err(|_| "Error: Unable to select description")?; let intrest_rate_mask = df_transactions @@ -292,13 +287,13 @@ pub fn parse_revolut_transactions( let mut dividend_transactions: Vec<(String, crate::Currency, crate::Currency)> = vec![]; let mut sold_transactions: Vec<(String, String, crate::Currency, crate::Currency)> = vec![]; - let mut dates: Vec = vec![]; + let dates: Vec; let mut acquired_dates: Vec = vec![]; let mut sold_dates: Vec = vec![]; let mut costs: Vec = vec![]; let mut gross: Vec = vec![]; - let mut incomes: Vec = vec![]; - let mut taxes: Vec = vec![]; + let incomes: Vec; + let taxes: Vec; //let mut rdr = csv::Reader::from_path(csvtoparse).map_err(|_| "Error: opening CSV")?; let mut rdr = csv::ReaderBuilder::new() .flexible(true) diff --git a/src/gui.rs b/src/gui.rs index 40f51b9..861754e 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -7,14 +7,10 @@ pub mod gui { browser::MultiBrowser, button::Button, dialog, - enums::{CallbackTrigger, Color, Event, Font, FrameType, Key, Shortcut}, + enums::{Event, Font, FrameType, Key}, frame::Frame, group::Pack, - input::MultilineInput, - menu, - menu::Choice, prelude::*, - text, text::{TextBuffer, TextDisplay}, window, }; @@ -221,8 +217,6 @@ pub mod gui { wind.make_resizable(true); - let (s, r) = app::channel::(); - let mut uberpack = Pack::new(0, 0, WIND_SIZE_X as i32, WIND_SIZE_Y as i32, ""); let mut pack = Pack::new(0, 0, WIND_SIZE_X as i32, WIND_SIZE_Y / 2 as i32, ""); @@ -233,7 +227,7 @@ pub mod gui { let mut frame1 = Frame::new(0, 0, DOCUMENTS_COL_WIDTH, 30, "Documents"); frame1.set_frame(FrameType::EngravedFrame); - let mut browser = Rc::new(RefCell::new(MultiBrowser::new( + let browser = Rc::new(RefCell::new(MultiBrowser::new( 0, 30, DOCUMENTS_COL_WIDTH, diff --git a/src/pdfparser.rs b/src/pdfparser.rs index 462d40e..af82407 100644 --- a/src/pdfparser.rs +++ b/src/pdfparser.rs @@ -430,7 +430,7 @@ fn process_transaction( sequence: &mut std::collections::VecDeque>, transaction_type: TransactionType, ) -> Result { - let mut state = ParserState::ProcessingTransaction(transaction_type.clone()); + let state; let possible_obj = sequence.pop_front(); match possible_obj { // Move executed parser objects into Vector diff --git a/src/pl.rs b/src/pl.rs index fcbc723..a0ec5ea 100644 --- a/src/pl.rs +++ b/src/pl.rs @@ -1,7 +1,5 @@ use serde::{Deserialize, Serialize}; -pub use crate::logging::ResultExt; - pub struct PL {} type ReqwestClient = reqwest::blocking::Client; diff --git a/src/transactions.rs b/src/transactions.rs index 9a3e1e2..e3c79c0 100644 --- a/src/transactions.rs +++ b/src/transactions.rs @@ -15,12 +15,12 @@ pub fn verify_interests_transactions(transactions: &Vec<(String, T)>) -> Resu } }; - let transaction_year = chrono::NaiveDate::parse_from_str(&transaction_date, "%m/%d/%y") + let transaction_year = chrono::NaiveDate::parse_from_str(transaction_date, "%m/%d/%y") .map_err(|_| format!("Unable to parse transaction date: \"{transaction_date}\""))? .year(); let mut verification: Result<(), String> = Ok(()); trans.try_for_each(|(tr_date, _)| { - let tr_year = chrono::NaiveDate::parse_from_str(&tr_date, "%m/%d/%y") + let tr_year = chrono::NaiveDate::parse_from_str(tr_date, "%m/%d/%y") .map_err(|_| format!("Unable to parse transaction date: \"{tr_date}\""))? .year(); if tr_year != transaction_year { @@ -28,7 +28,7 @@ pub fn verify_interests_transactions(transactions: &Vec<(String, T)>) -> Resu verification = Err(msg.to_owned()); } Ok::<(), String>(()) - }); + })?; verification } @@ -45,12 +45,12 @@ pub fn verify_dividends_transactions( } }; - let transaction_year = chrono::NaiveDate::parse_from_str(&transaction_date, "%m/%d/%y") + let transaction_year = chrono::NaiveDate::parse_from_str(transaction_date, "%m/%d/%y") .map_err(|_| format!("Unable to parse transaction date: \"{transaction_date}\""))? .year(); let mut verification: Result<(), String> = Ok(()); trans.try_for_each(|(tr_date, _, _)| { - let tr_year = chrono::NaiveDate::parse_from_str(&tr_date, "%m/%d/%y") + let tr_year = chrono::NaiveDate::parse_from_str(tr_date, "%m/%d/%y") .map_err(|_| format!("Unable to parse transaction date: \"{tr_date}\""))? .year(); if tr_year != transaction_year { @@ -58,7 +58,7 @@ pub fn verify_dividends_transactions( verification = Err(msg.to_owned()); } Ok::<(), String>(()) - }); + })?; verification } @@ -72,12 +72,12 @@ pub fn verify_transactions(transactions: &Vec<(String, String, T, T)>) -> Res } }; - let transaction_year = chrono::NaiveDate::parse_from_str(&transaction_date, "%m/%d/%y") + let transaction_year = chrono::NaiveDate::parse_from_str(transaction_date, "%m/%d/%y") .map_err(|_| format!("Unable to parse transaction date: \"{transaction_date}\""))? .year(); let mut verification: Result<(), String> = Ok(()); trans.try_for_each(|(_, tr_date, _, _)| { - let tr_year = chrono::NaiveDate::parse_from_str(&tr_date, "%m/%d/%y") + let tr_year = chrono::NaiveDate::parse_from_str(tr_date, "%m/%d/%y") .map_err(|_| format!("Unable to parse transaction date: \"{tr_date}\""))? .year(); if tr_year != transaction_year { @@ -85,7 +85,7 @@ pub fn verify_transactions(transactions: &Vec<(String, String, T, T)>) -> Res verification = Err(msg.to_owned()); } Ok::<(), String>(()) - }); + })?; verification }