From 52aaa615389091e84fc2bab6f6d182736ec91d5a Mon Sep 17 00:00:00 2001 From: junderw Date: Thu, 8 Dec 2022 21:36:23 +0900 Subject: [PATCH] fix: clippy lints --- common/src/errors.rs | 1 + common/src/types.rs | 2 ++ plugin/src/commands/mod.rs | 2 +- plugin/src/errors.rs | 6 +++--- plugin/src/plugin.rs | 4 ++-- plugin_macros/src/lib.rs | 17 +++++++---------- rpc/src/lightningrpc.rs | 5 +++-- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/common/src/errors.rs b/common/src/errors.rs index 9e37201..dac2a33 100644 --- a/common/src/errors.rs +++ b/common/src/errors.rs @@ -77,6 +77,7 @@ impl error::Error for Error { } } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] /// A JSONRPCv2.0 spec compilant error object pub struct RpcError { diff --git a/common/src/types.rs b/common/src/types.rs index 5568581..aee7421 100644 --- a/common/src/types.rs +++ b/common/src/types.rs @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize}; use crate::errors::{Error, RpcError}; +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] /// A standard JSONRPC request object pub struct Request<'f, T: Serialize> { @@ -20,6 +21,7 @@ pub struct Request<'f, T: Serialize> { pub jsonrpc: &'f str, } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Debug, Clone, PartialEq, Deserialize)] /// A standard JSONRPC response object pub struct Response { diff --git a/plugin/src/commands/mod.rs b/plugin/src/commands/mod.rs index ce1ceab..c3abaf8 100644 --- a/plugin/src/commands/mod.rs +++ b/plugin/src/commands/mod.rs @@ -39,7 +39,7 @@ pub trait RPCCommandClone { fn clone_box(&self) -> Box>; } -impl<'a, F, T: Clone> RPCCommandClone for F +impl RPCCommandClone for F where F: 'static + RPCCommand + Clone, { diff --git a/plugin/src/errors.rs b/plugin/src/errors.rs index fd5d52a..89da939 100644 --- a/plugin/src/errors.rs +++ b/plugin/src/errors.rs @@ -18,11 +18,11 @@ impl PluginError { where Self: Sized, { - return PluginError { + PluginError { code, msg: msg.to_string(), - data: data.to_owned(), - }; + data, + } } } diff --git a/plugin/src/plugin.rs b/plugin/src/plugin.rs index a983091..de24658 100644 --- a/plugin/src/plugin.rs +++ b/plugin/src/plugin.rs @@ -52,7 +52,7 @@ where impl<'a, T: 'a + Clone> Plugin { pub fn new(state: T, dynamic: bool) -> Self { - return Plugin { + Plugin { state, option: HashSet::new(), rpc_method: HashMap::new(), @@ -63,7 +63,7 @@ impl<'a, T: 'a + Clone> Plugin { dynamic, conf: None, on_init: None, - }; + } } pub fn on_init(&'a mut self, callback: &'static OnInit) -> Self { diff --git a/plugin_macros/src/lib.rs b/plugin_macros/src/lib.rs index 52275f1..5ae6875 100644 --- a/plugin_macros/src/lib.rs +++ b/plugin_macros/src/lib.rs @@ -92,8 +92,7 @@ pub fn rpc_method(attr: TokenStream, item: TokenStream) -> TokenStream { _ => panic!("The macros is applied over a not function declaration"), }; let rpc_call = generate_method_call(¯o_args, fn_dec); - let res = generate_rpc_method(&item, &rpc_call).parse().unwrap(); - res + generate_rpc_method(&item, &rpc_call).parse().unwrap() } // helper method to generator the RPCCall struct and make the code more readable and cleaner. @@ -154,11 +153,10 @@ fn generate_rpc_method(item: &TokenStream, method_call: &RPCCall) -> String { method_call.description, method_call.description, method_call.usage, - item.to_string(), + item, method_call.struct_name, - method_call.to_string(), + method_call, ) - .to_owned() } /// procedural macros to generate the code to register a RPC method created with the @@ -210,7 +208,7 @@ pub fn add_plugin_rpc(items: TokenStream) -> TokenStream { input[0], input[2] .to_string() - .replace("\"", "") + .replace('"', "") .as_str() .to_case(Case::Pascal) ) @@ -317,11 +315,10 @@ fn generate_notification_method(item: &TokenStream, method_call: &RPCNotificatio method_call.struct_name, method_call.struct_name, method_call.original_name, - item.to_string(), + item, method_call.struct_name, - method_call.to_string(), + method_call, ) - .to_owned() } /// procedural macros to generate the code to register a RPC method created with the @@ -370,7 +367,7 @@ pub fn plugin_register_notification(items: TokenStream) -> TokenStream { input[0], input[2] .to_string() - .replace("\"", "") + .replace('"', "") .as_str() .to_case(Case::Pascal) ) diff --git a/rpc/src/lightningrpc.rs b/rpc/src/lightningrpc.rs index de4c360..b5dd5fc 100644 --- a/rpc/src/lightningrpc.rs +++ b/rpc/src/lightningrpc.rs @@ -74,7 +74,7 @@ impl LightningRPC { /// Return feerate estimates, either satoshi-per-kw ({style} perkw) or satoshi-per-kb ({style} /// perkb). pub fn feerates(&self, style: &str) -> Result { - self.call("feerates", requests::FeeRates { style: style }) + self.call("feerates", requests::FeeRates { style }) } /// Show node {id} (or all, if no {id}), in our local network view. @@ -225,7 +225,7 @@ impl LightningRPC { self.call( "pay", requests::Pay { - bolt11: bolt11, + bolt11, msatoshi: options.msatoshi, description: options.description, riskfactor: options.riskfactor, @@ -305,6 +305,7 @@ impl LightningRPC { /// specified search from {fromid} otherwise use this node as source. Randomize the route with /// up to {fuzzpercent} (0.0 -> 100.0, default 5.0) using {seed} as an arbitrary-size string /// seed. + #[allow(clippy::too_many_arguments)] pub fn getroute( &self, id: &str,