diff --git a/src/converter.rs b/src/converter.rs index 38398dd..b722bc6 100644 --- a/src/converter.rs +++ b/src/converter.rs @@ -1,10 +1,10 @@ pub mod to_nav; pub mod from_nav; -use crate::runtime::rtree::rnode::{RNode, RNodeId}; -use crate::runtime::rtree::RuntimeTree; -use crate::runtime::{RtOk, RtResult}; -use crate::tree::project::Project; + + +use crate::runtime::{RtResult}; + /// The trait is a simple and generic converter interface. Predominantly is used to handle runtime tree. diff --git a/src/converter/from_nav.rs b/src/converter/from_nav.rs index c4c20da..f2d270d 100644 --- a/src/converter/from_nav.rs +++ b/src/converter/from_nav.rs @@ -3,14 +3,14 @@ use quick_xml::events::{BytesStart, Event}; use quick_xml::reader::Reader; use crate::converter::Converter; use crate::read_file; -use crate::runtime::rtree::builder::{RtNodeBuilder, RtTreeBuilder}; -use crate::runtime::rtree::RuntimeTree; + + use crate::runtime::{RtResult, RuntimeError}; -use crate::runtime::args::{RtArgs, RtArgument, RtValue}; +use crate::runtime::args::{RtArgument, RtValue}; use crate::runtime::builder::ros_nav::{find_ros_action, RosAction, RosParam}; -use crate::runtime::rtree::rnode::RNodeName; + use crate::tree::parser::ast::arg::MesType; -use crate::tree::project::Project; + #[cfg(windows)] const LINE_ENDING: &'static str = "\r\n"; @@ -50,7 +50,7 @@ impl Converter for FromNav2 { let mut reader = self.reader(); let mut res = String::new(); // let mut stack = Vec::new(); - let mut indent = 0; + let indent = 0; loop { match reader.read_event() { Ok(Event::Eof) => break, diff --git a/src/converter/to_nav.rs b/src/converter/to_nav.rs index 0b8e776..10c8761 100644 --- a/src/converter/to_nav.rs +++ b/src/converter/to_nav.rs @@ -1,14 +1,14 @@ -use std::collections::{HashMap, HashSet}; + use std::fs::File; -use std::io::{Cursor, LineWriter, Write}; -use std::path::{Path, PathBuf}; +use std::io::{LineWriter}; +use std::path::{PathBuf}; use quick_xml::events::{BytesEnd, BytesStart, Event}; use quick_xml::Writer; use crate::converter::{Converter}; use crate::runtime::rtree::RuntimeTree; use crate::runtime::{RtOk, RtResult, RuntimeError}; use crate::runtime::args::{RtArgument, RtValue}; -use crate::runtime::builder::ros_nav::{find_ros_action, RosAction}; +use crate::runtime::builder::ros_nav::{find_ros_action}; use crate::runtime::rtree::rnode::{DecoratorType, FlowType, RNode, RNodeId}; enum State { @@ -57,7 +57,7 @@ impl<'a> ToRosNavConverter<'a> { Self { tree, xml } } /// Write the terminal node into the specific format. The terminal node is the node that has no children by contract (actions) - fn write_terminal(&self, w: &mut Writer>, id: RNodeId, node: &RNode) -> RtOk { + fn write_terminal(&self, w: &mut Writer>, _id: RNodeId, node: &RNode) -> RtOk { let action = node.name() .and_then(|n| n.name().ok()) .and_then(|name| find_ros_action(name)) @@ -71,7 +71,7 @@ impl<'a> ToRosNavConverter<'a> { } // Write the opening for an interior node into the specific format. /// The interior node is the node that has children by contract (flows) - fn write_interior_start(&self, w: &mut Writer>, id: RNodeId, node: &RNode) -> RtOk { + fn write_interior_start(&self, w: &mut Writer>, _id: RNodeId, node: &RNode) -> RtOk { match node { RNode::Flow(FlowType::Root, n, _, _) => { let mut root = BytesStart::new("root"); @@ -130,7 +130,7 @@ impl<'a> ToRosNavConverter<'a> { Ok(()) } /// Write the closing for an interior node into the specific format. - fn write_interior_end(&self, w: &mut Writer>, id: RNodeId, node: &RNode) -> RtOk { + fn write_interior_end(&self, w: &mut Writer>, _id: RNodeId, node: &RNode) -> RtOk { match node { RNode::Flow(FlowType::Root, _, _, _) => { w.write_event(Event::End(BytesEnd::new("BehaviorTree")))?; diff --git a/src/runtime/action/builtin/daemon.rs b/src/runtime/action/builtin/daemon.rs index 3dca4af..83f8080 100644 --- a/src/runtime/action/builtin/daemon.rs +++ b/src/runtime/action/builtin/daemon.rs @@ -1,8 +1,8 @@ -use crate::runtime::action::{Impl, recover, Tick}; +use crate::runtime::action::{Impl, Tick}; use crate::runtime::args::RtArgs; use crate::runtime::context::TreeContextRef; use crate::runtime::{RuntimeError, TickResult}; -use crate::runtime::RuntimeError::RecoveryToFailure; + use crate::tracer::Event; diff --git a/src/runtime/action/builtin/data.rs b/src/runtime/action/builtin/data.rs index c6a059e..5b55a02 100644 --- a/src/runtime/action/builtin/data.rs +++ b/src/runtime/action/builtin/data.rs @@ -239,18 +239,18 @@ mod tests { use crate::runtime::action::Impl; use crate::runtime::args::{RtArgs, RtArgument, RtValue}; use crate::runtime::blackboard::{BBValue, BlackBoard}; - use crate::runtime::context::{TreeContext, TreeContextRef}; + use crate::runtime::context::{TreeContextRef}; use crate::runtime::trimmer::TrimmingQueue; use crate::runtime::{RuntimeError, TickResult}; use crate::tracer::Tracer; - use log::Level::Trace; - use std::collections::HashMap; + + use std::sync::{Arc, Mutex}; use crate::runtime::env::RtEnv; #[test] fn lock_unlock() { - let mut lock_action = LockUnlockBBKey::Lock; + let lock_action = LockUnlockBBKey::Lock; let r = lock_action.tick( RtArgs(vec![RtArgument::new( @@ -298,7 +298,7 @@ mod tests { #[test] fn store_tick() { - let mut store_tick = super::StoreTick; + let store_tick = super::StoreTick; let bb = Arc::new(Mutex::new(BlackBoard::default())); diff --git a/src/runtime/action/builtin/http.rs b/src/runtime/action/builtin/http.rs index 0a90022..d871a09 100644 --- a/src/runtime/action/builtin/http.rs +++ b/src/runtime/action/builtin/http.rs @@ -61,7 +61,7 @@ mod tests { use crate::runtime::trimmer::TrimmingQueue; use crate::runtime::TickResult; use crate::tracer::Tracer; - use itertools::Itertools; + use std::sync::{Arc, Mutex}; use wiremock::matchers::{method, path}; use wiremock::{Mock, MockServer, ResponseTemplate}; @@ -74,7 +74,7 @@ mod tests { let port = env.runtime.block_on(async { let mock_server = MockServer::start().await; - let mut resp = ResponseTemplate::new(200); + let resp = ResponseTemplate::new(200); let resp = resp.set_body_string("OK"); Mock::given(method("GET")) @@ -85,7 +85,7 @@ mod tests { mock_server.address().port() }); - let mut action = HttpGet; + let action = HttpGet; let bb = Arc::new(Mutex::new(BlackBoard::default())); let r = action.tick( diff --git a/src/runtime/action/builtin/remote.rs b/src/runtime/action/builtin/remote.rs index 2a3bec4..9600d86 100644 --- a/src/runtime/action/builtin/remote.rs +++ b/src/runtime/action/builtin/remote.rs @@ -1,8 +1,8 @@ use crate::runtime::action::{Impl, ImplRemote, Tick}; use crate::runtime::args::{RtArgs, RtArgument}; -use crate::runtime::context::{TreeContextRef, TreeRemoteContextRef}; -use crate::runtime::{to_fail, RuntimeError, RuntimeError::*, TickResult}; -use hyper::body::HttpBody; +use crate::runtime::context::{TreeRemoteContextRef}; +use crate::runtime::{to_fail, TickResult}; + use hyper::client::HttpConnector; use hyper::{body, Body, Client, Method, Request}; use serde::{Deserialize, Serialize}; @@ -136,12 +136,12 @@ mod tests { #[test] fn smoke() { - let mut env = RtEnv::try_new().unwrap(); + let env = RtEnv::try_new().unwrap(); let port = env.runtime.block_on(async { let mock_server = MockServer::start().await; - let mut resp = ResponseTemplate::new(200); + let resp = ResponseTemplate::new(200); let resp = resp.set_body_json(json!("Success")); Mock::given(method("POST")) @@ -152,9 +152,9 @@ mod tests { mock_server.address().port() }); - let mut action = RemoteHttpAction::new(format!("http://localhost:{}/action", port)); + let action = RemoteHttpAction::new(format!("http://localhost:{}/action", port)); - let bb = Arc::new(Mutex::new(BlackBoard::default())); + let _bb = Arc::new(Mutex::new(BlackBoard::default())); let r = action.tick(RtArgs(vec![]), TreeRemoteContextRef::new(1, port, Arc::new(Mutex::new(env)))); assert_eq!(r, Ok(TickResult::success())); diff --git a/src/runtime/args.rs b/src/runtime/args.rs index d28443a..d831e6c 100644 --- a/src/runtime/args.rs +++ b/src/runtime/args.rs @@ -11,10 +11,10 @@ use crate::tree::parser::ast::call::Call; use crate::tree::parser::ast::message::{Message, Number}; use crate::tree::{cerr, TreeError}; use itertools::Itertools; -use serde::de::{Error, MapAccess, SeqAccess, Visitor}; -use serde::{Deserialize, Deserializer, Serialize}; + +use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::fmt::{Display, format, Formatter}; +use std::fmt::{Display, Formatter}; /// Just a Key class for the arguments that represents the key in BB pub type RtAKey = String; diff --git a/src/runtime/args/transform.rs b/src/runtime/args/transform.rs index 67a75e2..adfccbf 100644 --- a/src/runtime/args/transform.rs +++ b/src/runtime/args/transform.rs @@ -1,4 +1,4 @@ -use crate::runtime::args::{RtArgs, RtArgument, RtValue, RtValueNumber}; +use crate::runtime::args::{RtArgs, RtArgument, RtValue}; use crate::runtime::rtree::rnode::DecoratorType; use crate::tree::parser::ast::arg::{ Argument, ArgumentRhs, Arguments, ArgumentsType, Param, Params, diff --git a/src/runtime/builder.rs b/src/runtime/builder.rs index 0bb705d..b688342 100644 --- a/src/runtime/builder.rs +++ b/src/runtime/builder.rs @@ -6,7 +6,7 @@ pub mod ros_nav; pub mod ros_core; use crate::get_pb; -use crate::runtime::action::builtin::remote::RemoteHttpAction; + use crate::runtime::action::keeper::{ActionImpl, ActionKeeper}; use crate::runtime::action::{Action, ActionName, Impl, ImplAsync, ImplRemote}; use crate::runtime::blackboard::BlackBoard; @@ -14,7 +14,7 @@ use crate::runtime::builder::custom_builder::CustomForesterBuilder; use crate::runtime::builder::file_builder::FileForesterBuilder; use crate::runtime::builder::text_builder::TextForesterBuilder; use crate::runtime::env::RtEnv; -use crate::runtime::forester::serv::HttpServ; + use crate::runtime::forester::{serv, Forester}; use crate::runtime::rtree::builder::RtNodeBuilder; use crate::runtime::rtree::rnode::RNodeId; @@ -22,11 +22,11 @@ use crate::runtime::rtree::{RuntimeTree, RuntimeTreeStarter}; use crate::runtime::{RtOk, RtResult, RuntimeError}; use crate::tracer::Tracer; use crate::tree::project::{FileName, TreeName}; -use serde::Serialize; + use std::collections::HashMap; use std::path::PathBuf; use std::sync::{Arc, Mutex}; -use crate::runtime::env::daemon::{DaemonFn, DaemonName, Daemon}; +use crate::runtime::env::daemon::{DaemonName, Daemon}; use crate::runtime::env::daemon::context::DaemonContext; /// The builder to create a Forester instance diff --git a/src/runtime/builder/ros_core.rs b/src/runtime/builder/ros_core.rs index 926b19a..72706ac 100644 --- a/src/runtime/builder/ros_core.rs +++ b/src/runtime/builder/ros_core.rs @@ -1,6 +1,6 @@ -use std::collections::HashMap; -use std::fmt::{Display, Formatter}; -use itertools::Itertools; + + + use crate::runtime::action::{Action, ActionName}; use crate::runtime::{RtResult, RuntimeError}; use crate::runtime::ros::OneTimeSender; diff --git a/src/runtime/context.rs b/src/runtime/context.rs index c23e254..eca7546 100644 --- a/src/runtime/context.rs +++ b/src/runtime/context.rs @@ -1,7 +1,7 @@ use crate::runtime::action::Tick; use crate::runtime::args::{RtArgs, RtValue}; use crate::runtime::blackboard::{BBRef, BlackBoard}; -use crate::runtime::env::{RtEnv, RtEnvRef}; +use crate::runtime::env::{RtEnvRef}; use crate::runtime::forester::flow::REASON; use crate::runtime::rtree::rnode::RNodeId; use crate::runtime::trimmer::{TrimmingQueue, TrimmingQueueRef}; diff --git a/src/runtime/env.rs b/src/runtime/env.rs index 91d03f6..1f2e28c 100644 --- a/src/runtime/env.rs +++ b/src/runtime/env.rs @@ -9,7 +9,7 @@ use std::sync::{Arc, Mutex}; use std::sync::atomic::AtomicBool; use itertools::Itertools; use tokio::runtime::{Builder, Runtime}; -use tokio::select; + use tokio::task::JoinError; use tokio::task::JoinHandle; use tokio_util::sync::CancellationToken; diff --git a/src/runtime/env/daemon.rs b/src/runtime/env/daemon.rs index 5949b66..1794bc1 100644 --- a/src/runtime/env/daemon.rs +++ b/src/runtime/env/daemon.rs @@ -3,9 +3,9 @@ pub mod task; use std::future::Future; use std::pin::Pin; -use std::sync::{Arc, Mutex}; -use std::sync::atomic::{AtomicBool, Ordering}; -use tokio::sync::oneshot::Receiver; +use std::sync::{Arc}; +use std::sync::atomic::{AtomicBool}; + use tokio_util::sync::CancellationToken; use crate::runtime::env::daemon::context::DaemonContext; diff --git a/src/runtime/env/daemon/context.rs b/src/runtime/env/daemon/context.rs index 39b4978..1c1c5be 100644 --- a/src/runtime/env/daemon/context.rs +++ b/src/runtime/env/daemon/context.rs @@ -23,7 +23,7 @@ impl From for DaemonContext { } } }impl From for DaemonContext { - fn from(mut value: TreeContextRef) -> Self { + fn from(value: TreeContextRef) -> Self { DaemonContext { bb: value.bb(), tracer: value.tracer(), diff --git a/src/runtime/env/daemon/task.rs b/src/runtime/env/daemon/task.rs index fb9948c..e472a15 100644 --- a/src/runtime/env/daemon/task.rs +++ b/src/runtime/env/daemon/task.rs @@ -1,9 +1,9 @@ use std::sync::atomic::Ordering::Relaxed; -use tokio::sync::oneshot::Sender; + use tokio::task::JoinHandle; use tokio_util::sync::CancellationToken; use crate::runtime::env::daemon::{DaemonName, StopFlag}; -use crate::runtime::{RtOk, RuntimeError}; +use crate::runtime::{RtOk}; pub enum DaemonTask { Unnamed(JoinHandle<()>, DaemonStopSignal), diff --git a/src/runtime/forester.rs b/src/runtime/forester.rs index a4a0d72..1514519 100644 --- a/src/runtime/forester.rs +++ b/src/runtime/forester.rs @@ -20,7 +20,7 @@ use crate::runtime::{trimmer, RtOk, RtResult, RuntimeError}; use crate::tracer::{Event, Tracer}; use log::debug; use std::sync::{Arc, Mutex}; -use tokio::sync::oneshot::Sender; + use tokio::task::JoinHandle; /// The entry point to process execution. diff --git a/src/runtime/forester/decorator.rs b/src/runtime/forester/decorator.rs index 59de3c4..c5ef01c 100644 --- a/src/runtime/forester/decorator.rs +++ b/src/runtime/forester/decorator.rs @@ -1,5 +1,5 @@ use crate::runtime::args::{RtArgs, RtArgument, RtValue, RtValueNumber}; -use crate::runtime::context::{RNodeState, TreeContext, TreeContextRef}; +use crate::runtime::context::{RNodeState, TreeContext}; use crate::runtime::forester::flow::{run_with, LEN, REASON}; use crate::runtime::rtree::rnode::DecoratorType; use crate::runtime::{RtResult, RuntimeError, TickResult}; diff --git a/src/runtime/forester/flow.rs b/src/runtime/forester/flow.rs index a98d049..66a87e0 100644 --- a/src/runtime/forester/flow.rs +++ b/src/runtime/forester/flow.rs @@ -248,7 +248,7 @@ pub fn monitor( ))) } FlowType::Parallel => { - let mut cursor = read_cursor(tick_args.clone())?; + let cursor = read_cursor(tick_args.clone())?; let new_args = replace_child_state( tick_args.with(P_CURSOR, RtValue::int(cursor)), cursor as usize, @@ -277,7 +277,7 @@ pub enum FlowDecision { } fn replace_child_state(args: RtArgs, idx: usize, v: i64) -> RtArgs { - let mut args = args; + let args = args; let mut elems = read_children_state(args.clone()); debug!(target:"params in child", "prev : [{args}], idx:{idx}, new state: {v}"); elems[idx] = v; diff --git a/src/runtime/forester/serv.rs b/src/runtime/forester/serv.rs index caae387..ae82d19 100644 --- a/src/runtime/forester/serv.rs +++ b/src/runtime/forester/serv.rs @@ -2,9 +2,9 @@ mod routes; use crate::runtime::blackboard::BlackBoard; use crate::runtime::builder::ServerPort; -use crate::tracer::{Event, Tracer}; +use crate::tracer::{Tracer}; use axum::routing::{get, post}; -use axum::{Json, Router}; +use axum::{Router}; use crate::runtime::forester::serv::routes::*; use crate::runtime::{RtOk, RtResult, RuntimeError}; @@ -17,7 +17,7 @@ use hyper::{Body, Client}; use serde::{Deserialize, Serialize}; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; -use tokio::runtime::Runtime; + use tokio::sync::oneshot::Sender; use tokio::task::JoinHandle; use crate::runtime::env::RtEnv; @@ -46,7 +46,7 @@ pub struct ServInfo { } impl ServInfo { - pub fn stop(mut self) -> Result<(), ()> { + pub fn stop(self) -> Result<(), ()> { self.stop_cmd.send(()) } } diff --git a/src/runtime/forester/serv/routes.rs b/src/runtime/forester/serv/routes.rs index f84a373..db4735a 100644 --- a/src/runtime/forester/serv/routes.rs +++ b/src/runtime/forester/serv/routes.rs @@ -1,4 +1,4 @@ -use crate::runtime::action::builtin::remote::RemoteActionRequest; + use crate::runtime::args::RtValue; use crate::runtime::forester::serv::{err_handler, CustomEvent, HttpServ}; use crate::runtime::RuntimeError; diff --git a/src/runtime/ros.rs b/src/runtime/ros.rs index f9fa243..821e6c9 100644 --- a/src/runtime/ros.rs +++ b/src/runtime/ros.rs @@ -2,17 +2,17 @@ // ros2 launch rosbridge_server rosbridge_websocket_launch.xml pub mod client; -use std::fmt::format; -use std::sync::atomic::Ordering; -use serde::Deserialize; -use serde_json::Deserializer; -use tungstenite::{connect, Message}; -use url::Url; -use blackboard::utils::push_to_arr; + + + + + + + use crate::runtime::action::{Impl, Tick}; use crate::runtime::args::{RtArgs, RtValue}; use crate::runtime::context::TreeContextRef; -use crate::runtime::{blackboard, ros, RtResult, RuntimeError, TickResult}; +use crate::runtime::{RtResult, RuntimeError, TickResult}; use crate::runtime::blackboard::BBKey; use crate::runtime::env::daemon::context::DaemonContext; use crate::runtime::env::daemon::{Daemon, DaemonFn, StopFlag}; @@ -100,7 +100,7 @@ impl SubscriberDaemon { } impl DaemonFn for SubscriberDaemon { - fn perform(&mut self, ctx: DaemonContext, signal: StopFlag) { + fn perform(&mut self, _ctx: DaemonContext, _signal: StopFlag) { // loop { // if signal.load(Ordering::Relaxed) { // break; diff --git a/src/runtime/ros/client.rs b/src/runtime/ros/client.rs index 9270769..ab614bd 100644 --- a/src/runtime/ros/client.rs +++ b/src/runtime/ros/client.rs @@ -49,7 +49,7 @@ impl SubscribeCfg { .ok_or(RuntimeError::fail("the compression is not string".to_string()))?); } _ => { - return Err(RuntimeError::fail((format!("the key {} is not supported", k)))); + return Err(RuntimeError::fail(format!("the key {} is not supported", k))); } } } @@ -119,8 +119,8 @@ impl Serialize for RosCommand { cmd.serialize_field("topic", t)?; cmd.end() } - RosCommand::Subscribe(t, cfg) => { - let mut cfg_count = cfg.count(); + RosCommand::Subscribe(_t, cfg) => { + let cfg_count = cfg.count(); let mut cmd = serializer.serialize_struct("Command", cfg_count + 1)?; cmd.serialize_field("op", "subscribe")?; diff --git a/src/runtime/rtree.rs b/src/runtime/rtree.rs index 2475d9e..7cd5218 100644 --- a/src/runtime/rtree.rs +++ b/src/runtime/rtree.rs @@ -138,7 +138,7 @@ impl RuntimeTree { Call::HoInvocation(key) => { debug!(target:"tree[construct]", "found ho invocation with id {id} in parent {parent_id}"); let (p_id, parent_args, parent_params) = - builder.get_chain_skip_lambda(&parent_id)?.get_tree(); + builder.get_chain_skip_lambda(&parent_id)?.get_tree(); let call = builder.find_ho_call(&parent_id, &key)?; if call.is_lambda() || call.is_decorator() { builder.push_front(id, call, p_id, file_name.clone()); @@ -284,7 +284,7 @@ mod tests { use crate::runtime::rtree::rnode::RNodeName::{Lambda, Name}; use crate::runtime::rtree::RuntimeTree; use crate::tree::project::Project; - use std::collections::{HashMap, HashSet}; + use std::collections::{HashSet}; use itertools::Itertools; use crate::tests::turn_on_logs; diff --git a/src/runtime/rtree/builder.rs b/src/runtime/rtree/builder.rs index 25ecbd8..489d5b7 100644 --- a/src/runtime/rtree/builder.rs +++ b/src/runtime/rtree/builder.rs @@ -179,10 +179,10 @@ mod tests { use crate::runtime::args::*; use crate::runtime::rtree::builder::*; use crate::runtime::rtree::rnode::RNodeName; - use crate::tree::project::Project; - use crate::visualizer::Visualizer; - use crate::{action, arg, args, decorator, flow, node_name, rt_num, rt_str}; - use std::path::PathBuf; + + + use crate::{action, arg, args, decorator, flow, node_name, rt_num}; + #[test] fn smoke() { @@ -202,11 +202,11 @@ mod tests { .iter() .map(|(id, node)| { let node = match node { - RNode::Leaf(n, args) => "action".to_string(), - RNode::Flow(t, n, args, children) => { + RNode::Leaf(_n, _args) => "action".to_string(), + RNode::Flow(t, _n, _args, _children) => { format!("{t}") } - RNode::Decorator(t, args, child) => { + RNode::Decorator(t, _args, _child) => { format!("{t}") } }; diff --git a/src/runtime/rtree/rnode.rs b/src/runtime/rtree/rnode.rs index e06e457..c673f44 100644 --- a/src/runtime/rtree/rnode.rs +++ b/src/runtime/rtree/rnode.rs @@ -1,5 +1,5 @@ use crate::runtime::args::RtArgs; -use crate::runtime::{RtResult, RuntimeError, TickResult}; +use crate::runtime::{RtResult, RuntimeError}; use crate::tree::parser::ast::TreeType; use crate::tree::{cerr, TreeError}; diff --git a/src/runtime/trimmer/task.rs b/src/runtime/trimmer/task.rs index 923222e..04b0d73 100644 --- a/src/runtime/trimmer/task.rs +++ b/src/runtime/trimmer/task.rs @@ -1,6 +1,6 @@ use crate::runtime::trimmer::{TreeSnapshot, TrimRequest}; use crate::runtime::RtResult; -use std::fmt::Debug; + /// The task to trim the tree. pub enum TrimTask { diff --git a/src/runtime/trimmer/validator.rs b/src/runtime/trimmer/validator.rs index ffd685b..adbef28 100644 --- a/src/runtime/trimmer/validator.rs +++ b/src/runtime/trimmer/validator.rs @@ -1,4 +1,4 @@ -use crate::runtime::trimmer::{RequestBody, TreeSnapshot, TrimRequest}; +use crate::runtime::trimmer::{RequestBody, TreeSnapshot}; /// Validation function. Takes all validators and go through them. /// The validators are typically works on the following tasks: diff --git a/src/tests.rs b/src/tests.rs index 7634f7a..5f1f764 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -14,7 +14,7 @@ mod import; mod params; mod daemons; -use crate::runtime::builder::file_builder::FileForesterBuilder; + use crate::runtime::builder::ForesterBuilder; use log::LevelFilter; use std::path::PathBuf; @@ -36,7 +36,7 @@ pub fn test_folder(path_in: &str) -> PathBuf { } pub fn fb(folder: &str) -> ForesterBuilder { - let mut root = test_folder(folder); + let root = test_folder(folder); let mut fb = ForesterBuilder::from_fs(); fb.main_file("main.tree".to_string()); diff --git a/src/tests/actions.rs b/src/tests/actions.rs index 6044260..92bd92b 100644 --- a/src/tests/actions.rs +++ b/src/tests/actions.rs @@ -4,7 +4,7 @@ use crate::tests::fb; #[test] fn builtin_actions() { - let mut fb = fb("actions/builtin"); + let fb = fb("actions/builtin"); let mut f = fb.build().unwrap(); let result = f.run(); @@ -13,7 +13,7 @@ fn builtin_actions() { #[test] fn lock_unlock() { - let mut fb = fb("actions/lock_unlock"); + let fb = fb("actions/lock_unlock"); let mut f = fb.build().unwrap(); let result = f.run(); @@ -25,13 +25,13 @@ fn lock_unlock() { #[test] fn builtin_http_get() { - let mut fb = fb("actions/simple_http"); + let fb = fb("actions/simple_http"); let mut f = fb.build().unwrap(); assert_eq!(f.run(), Ok(TickResult::success())); } #[test] fn builtin_test() { - let mut fb = fb("actions/builtin_test"); + let fb = fb("actions/builtin_test"); let mut f = fb.build().unwrap(); assert_eq!(f.run(), Ok(TickResult::success())); } @@ -39,7 +39,7 @@ fn builtin_test() { #[test] #[ignore] fn mix_test() { - let mut fb = fb("actions/mix_test"); + let fb = fb("actions/mix_test"); let mut f = fb.build().unwrap(); assert_eq!(f.run(), Ok(TickResult::success())); } diff --git a/src/tests/actions_re.rs b/src/tests/actions_re.rs index 2a84563..273a054 100644 --- a/src/tests/actions_re.rs +++ b/src/tests/actions_re.rs @@ -3,7 +3,7 @@ use crate::runtime::action::{Impl, ImplRemote}; use crate::runtime::args::{RtArgs, RtArgument, RtValue}; use crate::runtime::blackboard::BlackBoard; use crate::runtime::builder::ServerPort; -use crate::runtime::context::{TreeContextRef, TreeRemoteContextRef}; +use crate::runtime::context::{TreeRemoteContextRef}; use crate::runtime::env::RtEnv; use crate::runtime::forester::serv::start; use crate::runtime::TickResult; @@ -40,12 +40,12 @@ fn smoke_serv() { #[test] fn remote_smoke() { turn_on_logs(); - let mut env = RtEnv::try_new().unwrap(); + let env = RtEnv::try_new().unwrap(); let port = env.runtime.block_on(async { let mock_server = MockServer::start().await; - let mut resp = ResponseTemplate::new(200); + let resp = ResponseTemplate::new(200); let resp = resp.set_body_json(json!("Success")); Mock::given(method("POST")) @@ -76,11 +76,11 @@ fn remote_smoke() { #[test] fn remote_in_tree() { turn_on_logs(); - let mut env = RtEnv::try_new().unwrap(); + let env = RtEnv::try_new().unwrap(); let port = env.runtime.block_on(async { let mock_server = MockServer::start().await; - let mut resp = ResponseTemplate::new(200); + let resp = ResponseTemplate::new(200); let resp = resp.set_body_json(json!("Success")); Mock::given(method("POST")) diff --git a/src/tests/args.rs b/src/tests/args.rs index 40d7cb4..2f296a6 100644 --- a/src/tests/args.rs +++ b/src/tests/args.rs @@ -1,15 +1,15 @@ -use crate::runtime::action::builtin::data::GenerateData; -use crate::runtime::action::builtin::ReturnResult; -use crate::runtime::action::{Action, Impl, Tick}; + + +use crate::runtime::action::{Impl, Tick}; use crate::runtime::args::{RtArgs, RtArgument, RtValue}; -use crate::runtime::context::{TreeContext, TreeContextRef}; +use crate::runtime::context::{TreeContextRef}; use crate::runtime::rtree::rnode::DecoratorType; use crate::runtime::rtree::RuntimeTree; use crate::runtime::{RuntimeError, TickResult}; -use crate::tests::{fb, test_folder, turn_on_logs}; -use crate::tracer::{Tracer, TracerConfig}; +use crate::tests::{fb}; + use crate::tree::project::Project; -use crate::visualizer::Visualizer; + #[test] fn pointers() { @@ -50,7 +50,7 @@ fn inter_args_func() { #[test] fn inter_args_lambda() { - let mut project = Project::build_from_text( + let project = Project::build_from_text( r#" root main test("test") sequence test(a:string) sequence { t(a) } @@ -75,7 +75,7 @@ impl t(k:string); #[test] fn inter_args() { - let mut project = Project::build_from_text( + let project = Project::build_from_text( r#" root main test("test") sequence test(a:string) t(a) @@ -149,7 +149,7 @@ impl t(k:num); #[test] fn inter_args_pointers() { - let mut project = Project::build_from_text( + let project = Project::build_from_text( r#" import "std::actions" root main { diff --git a/src/tests/daemons.rs b/src/tests/daemons.rs index ddc02ad..78dc7f7 100644 --- a/src/tests/daemons.rs +++ b/src/tests/daemons.rs @@ -7,7 +7,7 @@ use crate::runtime::args::{RtArgs, RtValue}; use crate::runtime::context::TreeContextRef; use crate::runtime::env::daemon::{AsyncDaemonFn, Daemon, DaemonFn, StopFlag}; use crate::runtime::env::daemon::context::DaemonContext; -use crate::runtime::{blackboard, RtOk, TickResult}; +use crate::runtime::{blackboard, TickResult}; use crate::tests::{fb, turn_on_logs}; struct Test; @@ -22,7 +22,7 @@ impl DaemonFn for Test { } impl Impl for Test { - fn tick(&self, args: RtArgs, ctx: TreeContextRef) -> Tick { + fn tick(&self, _args: RtArgs, ctx: TreeContextRef) -> Tick { std::thread::sleep(std::time::Duration::from_millis(500)); if ctx.current_tick() < 4 { Ok(TickResult::running()) @@ -53,7 +53,7 @@ fn smoke() { struct TestAction; impl Impl for TestAction { - fn tick(&self, args: RtArgs, ctx: TreeContextRef) -> Tick { + fn tick(&self, _args: RtArgs, ctx: TreeContextRef) -> Tick { std::thread::sleep(std::time::Duration::from_millis(100)); let arc = ctx.bb(); let mut bb = arc.lock()?; diff --git a/src/tests/decorator.rs b/src/tests/decorator.rs index bb44b6c..3374352 100644 --- a/src/tests/decorator.rs +++ b/src/tests/decorator.rs @@ -1,6 +1,6 @@ use crate::runtime::action::builtin::data::{GenerateData, StoreData}; -use crate::runtime::action::builtin::ReturnResult; -use crate::runtime::action::Action; + + use crate::runtime::args::RtValue; use crate::runtime::TickResult; use crate::tests::{fb, turn_on_logs}; @@ -112,7 +112,7 @@ fn repeat_reactive() { } #[test] fn repeat_failure() { - let mut fb = fb("decorators/repeat_failure"); + let fb = fb("decorators/repeat_failure"); let mut f = fb.build().unwrap(); assert_eq!(f.run(), Ok(TickResult::failure("test".to_string()))); diff --git a/src/tests/flow.rs b/src/tests/flow.rs index 6b33563..a84c122 100644 --- a/src/tests/flow.rs +++ b/src/tests/flow.rs @@ -1,17 +1,17 @@ -use std::net::Incoming; + use crate::runtime::action::builtin::data::GenerateData; -use crate::runtime::action::builtin::ReturnResult; -use crate::runtime::action::{Action, Impl, Tick}; + +use crate::runtime::action::{Impl, Tick}; use crate::runtime::args::{RtArgs, RtValue}; -use crate::runtime::context::{TreeContext, TreeContextRef}; +use crate::runtime::context::{TreeContextRef}; use crate::runtime::TickResult; use crate::tests::{fb, test_folder, turn_on_logs}; -use crate::visualizer::Visualizer; + struct StoreTick; impl Impl for StoreTick { - fn tick(&self, args: RtArgs, ctx: TreeContextRef) -> Tick { + fn tick(&self, _args: RtArgs, ctx: TreeContextRef) -> Tick { let ts = ctx.current_tick(); ctx.bb() .lock() @@ -73,7 +73,7 @@ fn simple_sequence() { .unwrap(); assert_eq!(x, 1); - let buf = test_folder("flow/sequence/bb_dump.json"); + let _buf = test_folder("flow/sequence/bb_dump.json"); } #[test] diff --git a/src/tests/nav.rs b/src/tests/nav.rs index 02c841a..1998b1e 100644 --- a/src/tests/nav.rs +++ b/src/tests/nav.rs @@ -2,7 +2,7 @@ use crate::converter::Converter; use crate::converter::from_nav::FromNav2; use crate::read_file; use crate::runtime::rtree::RuntimeTree; -use crate::tests::{fb, test_folder}; +use crate::tests::{test_folder}; use crate::tree::project::Project; #[test] diff --git a/src/tests/params.rs b/src/tests/params.rs index e6d5026..6562209 100644 --- a/src/tests/params.rs +++ b/src/tests/params.rs @@ -1,12 +1,12 @@ use crate::runtime::action::{Impl, Tick}; -use crate::runtime::args::{RtArgs, RtValue}; +use crate::runtime::args::{RtArgs}; use crate::runtime::context::TreeContextRef; -use crate::runtime::{RuntimeError, TickResult}; -use crate::runtime::builder::ForesterBuilder; -use crate::tests::{fb, test_folder, turn_on_logs}; -use crate::tree::TreeError; -use crate::tree::TreeError::CompileError; -use crate::visualizer::Visualizer; +use crate::runtime::{TickResult}; + +use crate::tests::{fb, turn_on_logs}; + + + #[test] fn fail_types() { diff --git a/src/tests/rtree.rs b/src/tests/rtree.rs index b961256..898c7b0 100644 --- a/src/tests/rtree.rs +++ b/src/tests/rtree.rs @@ -1,18 +1,18 @@ #[cfg(test)] mod tests { - use crate::flow; + use crate::runtime::args::{RtArgs, RtArgument, RtValue}; - use crate::runtime::rtree::builder::RtTreeBuilder; + use crate::runtime::rtree::rnode::FlowType::{RSequence, Root, Sequence}; use crate::runtime::rtree::rnode::RNodeName::Name; use crate::runtime::rtree::rnode::{FlowType, RNode, RNodeName}; use crate::runtime::rtree::RuntimeTree; - use crate::runtime::trimmer::task::TrimTask::RtTree; + use crate::tree::parser::ast::call::{Call, Calls}; use crate::tree::parser::ast::TreeType; use crate::tree::project::Project; - use crate::visualizer::Visualizer; - use graphviz_rust::attributes::arrowhead::vee; + + use std::collections::HashMap; use std::path::PathBuf; use std::vec; diff --git a/src/tests/simulator.rs b/src/tests/simulator.rs index 21039da..86b7dbf 100644 --- a/src/tests/simulator.rs +++ b/src/tests/simulator.rs @@ -6,14 +6,14 @@ use crate::simulator::builder::SimulatorBuilder; use crate::simulator::config::{ Action, BbConfig, HttpServ, SimProfile, SimProfileConfig, TracerSimConfig, }; -use crate::simulator::Simulator; + use crate::tests::{test_folder, turn_on_logs}; use axum::http::StatusCode; use axum::response::IntoResponse; use axum::routing::{get, post}; use axum::{Json, Router, ServiceExt}; use forester_http::client::ForesterHttpClient; -use graphviz_rust::attributes::quadtree::fast; + use serde_json::json; use std::collections::HashMap; use std::io::Write; diff --git a/src/tests/tracer.rs b/src/tests/tracer.rs index 3dc7a59..1012e90 100644 --- a/src/tests/tracer.rs +++ b/src/tests/tracer.rs @@ -1,14 +1,14 @@ -use crate::runtime::action::builtin::data::{GenerateData, StoreTick}; -use crate::runtime::action::{Action, Impl, Tick}; +use crate::runtime::action::builtin::data::{GenerateData}; +use crate::runtime::action::{Impl, Tick}; use crate::runtime::args::{RtArgs, RtValue}; -use crate::runtime::context::{TreeContext, TreeContextRef}; +use crate::runtime::context::{TreeContextRef}; use crate::runtime::TickResult; use crate::tests::{fb, test_folder}; use crate::tracer; -use crate::tracer::{Event, Tracer, TracerConfig}; -use std::alloc::System; +use crate::tracer::{Tracer, TracerConfig}; + use std::fs; -use std::time::SystemTime; + #[test] fn smoke() { @@ -191,7 +191,7 @@ fn custom_state() { struct CT; impl Impl for CT { - fn tick(&self, args: RtArgs, ctx: TreeContextRef) -> Tick { + fn tick(&self, _args: RtArgs, ctx: TreeContextRef) -> Tick { let i = ctx .bb() .lock() @@ -249,7 +249,7 @@ fn file() { struct CT; impl Impl for CT { - fn tick(&self, args: RtArgs, ctx: TreeContextRef) -> Tick { + fn tick(&self, _args: RtArgs, ctx: TreeContextRef) -> Tick { let i = ctx .bb() .lock() diff --git a/src/tests/trimmer.rs b/src/tests/trimmer.rs index c8ae53f..0545d44 100644 --- a/src/tests/trimmer.rs +++ b/src/tests/trimmer.rs @@ -1,20 +1,20 @@ use crate::action; -use crate::runtime::action::{Action, Impl, Tick}; +use crate::runtime::action::{Impl}; use crate::runtime::args::RtArgs; use crate::runtime::builder::ForesterBuilder; -use crate::runtime::context::TreeContextRef; + use crate::runtime::rtree::builder::{RtNodeBuilder, RtTreeBuilder}; use crate::runtime::rtree::rnode::RNodeName; -use crate::runtime::rtree::RuntimeTree; + use crate::runtime::trimmer::task::{RtTreeTrimTask, TrimTask}; use crate::runtime::trimmer::{RequestBody, TreeSnapshot, TrimRequest}; use crate::runtime::{RtResult, TickResult}; use crate::simulator::actions::SimAction; use crate::tests::{test_folder, turn_on_logs}; use crate::tracer::{Tracer, TracerConfig}; -use crate::visualizer::Visualizer; + use crate::*; -use std::time::Duration; + #[test] fn smoke() { diff --git a/src/tests/vizualizer.rs b/src/tests/vizualizer.rs index d522be3..406749c 100644 --- a/src/tests/vizualizer.rs +++ b/src/tests/vizualizer.rs @@ -2,14 +2,14 @@ use crate::runtime::rtree::RuntimeTree; use crate::tests::test_folder; use crate::tree::project::Project; use crate::visualizer::Visualizer; -use graphviz_rust::dot_generator::*; -use graphviz_rust::dot_structures::*; -use std::path::PathBuf; + + + #[test] #[ignore] fn manual() { - let mut project_root = test_folder("plain_project").clone(); + let project_root = test_folder("plain_project").clone(); let mut graph = project_root.clone(); let project = Project::build("main.tree".to_string(), project_root).unwrap(); diff --git a/src/tree/parser/ast/arg.rs b/src/tree/parser/ast/arg.rs index 374f460..45ceb2f 100644 --- a/src/tree/parser/ast/arg.rs +++ b/src/tree/parser/ast/arg.rs @@ -5,7 +5,7 @@ use crate::tree::parser::ast::Key; use crate::tree::{cerr, TreeError}; use itertools::Itertools; use serde::{Deserialize, Serialize}; -use std::fmt::{Display, format, Formatter, Write}; +use std::fmt::{Display, Formatter, Write}; /// Just a pair of name and type /// This is a representation of a tree parameter diff --git a/src/tree/parser/ast/call.rs b/src/tree/parser/ast/call.rs index 14499eb..fd6bc0f 100644 --- a/src/tree/parser/ast/call.rs +++ b/src/tree/parser/ast/call.rs @@ -1,7 +1,7 @@ use crate::tree::parser::ast::arg::Arguments; use crate::tree::parser::ast::{Key, TreeType}; use serde::{Deserialize, Serialize}; -use std::fmt::{Debug, Display, Formatter}; +use std::fmt::{Debug, Formatter}; /// A call to a tree #[derive(Clone, PartialEq, Deserialize, Serialize)] diff --git a/src/tree/parser/tests/definition.rs b/src/tree/parser/tests/definition.rs index 482e3ed..679221e 100644 --- a/src/tree/parser/tests/definition.rs +++ b/src/tree/parser/tests/definition.rs @@ -3,9 +3,9 @@ use crate::tree::parser::ast::call::{Call, Calls}; use crate::tree::parser::ast::message::{Message, Number}; use crate::tree::parser::ast::*; use crate::tree::parser::Parser; -use parsit::error::ParseError; + use parsit::test::parser_test::*; -use std::collections::HashMap; + #[test] fn definition() { diff --git a/src/tree/parser/tests/file.rs b/src/tree/parser/tests/file.rs index 1bf7e38..3922ae7 100644 --- a/src/tree/parser/tests/file.rs +++ b/src/tree/parser/tests/file.rs @@ -2,10 +2,10 @@ use crate::tree::parser::ast::arg::{Argument, Arguments, MesType, Param, Params} use crate::tree::parser::ast::call::{Call, Calls}; use crate::tree::parser::ast::*; use crate::tree::parser::Parser; -use crate::tree::project::file::File; -use parsit::error::ParseError; + + use parsit::test::parser_test::*; -use std::collections::HashMap; + #[test] fn file() { diff --git a/src/tree/parser/tests/import.rs b/src/tree/parser/tests/import.rs index 1d77b42..930fe2a 100644 --- a/src/tree/parser/tests/import.rs +++ b/src/tree/parser/tests/import.rs @@ -1,8 +1,8 @@ use crate::tree::parser::ast::*; use crate::tree::parser::Parser; -use parsit::error::ParseError; + use parsit::test::parser_test::*; -use std::collections::HashMap; + #[test] fn import() { diff --git a/src/tree/parser/tests/message.rs b/src/tree/parser/tests/message.rs index 5e8ffac..1c26ee8 100644 --- a/src/tree/parser/tests/message.rs +++ b/src/tree/parser/tests/message.rs @@ -1,7 +1,7 @@ use crate::tree::parser::ast::message::{Message, Number, StringLit}; -use crate::tree::parser::ast::*; + use crate::tree::parser::Parser; -use parsit::test::parser_test::{expect, expect_or_env}; +use parsit::test::parser_test::{expect}; use std::collections::HashMap; #[test] diff --git a/src/tree/parser/tests/params.rs b/src/tree/parser/tests/params.rs index 4af2b60..d6e6583 100644 --- a/src/tree/parser/tests/params.rs +++ b/src/tree/parser/tests/params.rs @@ -1,5 +1,5 @@ use crate::tree::parser::ast::arg::{MesType, Param, Params}; -use crate::tree::parser::ast::*; + use crate::tree::parser::Parser; use parsit::test::parser_test::expect; diff --git a/src/tree/project.rs b/src/tree/project.rs index 5489e61..edbad62 100644 --- a/src/tree/project.rs +++ b/src/tree/project.rs @@ -178,7 +178,7 @@ impl<'a> Project { fn file_to_str(root: PathBuf, file: FileName) -> Result { if file.contains("::"){ - let mut parts:Vec<_> = file.split("::").collect(); + let parts:Vec<_> = file.split("::").collect(); if parts.len() != 2{ return Err(TreeError::IOError(format!("invalid file name: {}", file))) }else { diff --git a/src/visualizer.rs b/src/visualizer.rs index 68de264..3a16b54 100644 --- a/src/visualizer.rs +++ b/src/visualizer.rs @@ -1,10 +1,10 @@ mod statements; -use crate::{get_pb, runtime_tree_default}; +use crate::{runtime_tree_default}; use crate::runtime::rtree::rnode::{RNode, RNodeId}; use crate::runtime::rtree::RuntimeTree; -use crate::tree::project::Project; + use crate::tree::TreeError; use crate::visualizer::statements::ToStmt; use graphviz_rust::cmd::{CommandArg, Format};