Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jb-intellinet committed Dec 15, 2023
1 parent e71cc92 commit ae844cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 1 addition & 4 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ extern crate pta_parser;
use log::{info, warn, as_error, error};

// TODO: how to isolate pest so clients can just use lib (w/o requiring pest as here)
use pest::{*, iterators::Pair};
use pta_ledger::ledger_builder::LedgerBuilder;
use pta_parser::{LedgerParser, Rule};
use pta_types::{FilePosition, RawTransaction, ParserInfo };



Expand All @@ -30,7 +27,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(ledger) => {
info!("String length from input: {}", ledger.len());
match bldr.from_string(&ledger) {
Ok(parsed) => {
Ok(_parsed) => {
info!("Successfully parsed into ParsedLedger");
return Ok(());
},
Expand Down
23 changes: 15 additions & 8 deletions pta-ledger/src/ledger_builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::error::Error;

use log::{info, warn, as_error};

Expand Down Expand Up @@ -41,7 +40,6 @@ impl LedgerBuilder {


fn handle_pair(self: &Self, pair: Pair<'_, Rule>) -> Result<(), Box<dyn std::error::Error>> {
let parsed = ParsedLedger::default();

match pair.as_rule() {
Rule::comment => {
Expand Down Expand Up @@ -127,13 +125,13 @@ fn handle_ledger_rule(pair: & Pair<Rule>) -> Result<(), Box<dyn std::error::Erro
return Ok(());
}


fn handle_posting_basic(xn: &mut raw_transaction::RawTransaction, pair: &Pair<Rule>) -> Result<(), Box<dyn std::error::Error>> {
#[allow(dead_code)] // TODO: REMOVE allow dead code
fn handle_posting_basic(_xn: &mut raw_transaction::RawTransaction, pair: &Pair<Rule>) -> Result<(), Box<dyn std::error::Error>> {

match LedgerParser::parse(Rule::posting_basic, pair.as_span().as_str()) {
Ok(posting) => {
Ok(_posting) => {
info!("handling posting_basic");
// handle_posting_basic(xn, posting);
// handle_posting_basic(xn, posting); TODO: fix
}

Err(e) => {
Expand All @@ -146,7 +144,7 @@ fn handle_posting_basic(xn: &mut raw_transaction::RawTransaction, pair: &Pair<Ru
return Ok(());
}

fn handle_trans_header(xn: &mut raw_transaction::RawTransaction, pair: &Pair<Rule>) -> Result<(), Box<dyn std::error::Error>> {
fn handle_trans_header(_: &mut raw_transaction::RawTransaction, _: &Pair<Rule>) -> Result<(), Box<dyn std::error::Error>> {
info!("handling trans_header...");

return Ok(());
Expand All @@ -167,7 +165,16 @@ fn handle_trans_block(xn: &mut raw_transaction::RawTransaction, pair: &Pair<Rule
Ok(hdr) => {
for pair in hdr.into_iter() {
info!("attempt handle_trans_header on {}", pair.as_span().as_str());
handle_trans_header(xn, &pair);
match handle_trans_header(xn, &pair) {
Ok(()) => {
// TODO: REVIEW: should anything happen here?
}

Err(e) => {
warn!(err = e; "handle_trans_header failed");
return Err(e);
}
}

}
// for p in &pair.into_inner() {
Expand Down

0 comments on commit ae844cc

Please sign in to comment.