Skip to content

Commit

Permalink
fix: clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
junderw committed Dec 12, 2022
1 parent f1bfdca commit 52aaa61
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions common/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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<T> {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub trait RPCCommandClone<T: Clone> {
fn clone_box(&self) -> Box<dyn RPCCommand<T>>;
}

impl<'a, F, T: Clone> RPCCommandClone<T> for F
impl<F, T: Clone> RPCCommandClone<T> for F
where
F: 'static + RPCCommand<T> + Clone,
{
Expand Down
6 changes: 3 additions & 3 deletions plugin/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ impl PluginError {
where
Self: Sized,
{
return PluginError {
PluginError {
code,
msg: msg.to_string(),
data: data.to_owned(),
};
data,
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions plugin/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ where

impl<'a, T: 'a + Clone> Plugin<T> {
pub fn new(state: T, dynamic: bool) -> Self {
return Plugin {
Plugin {
state,
option: HashSet::new(),
rpc_method: HashMap::new(),
Expand All @@ -63,7 +63,7 @@ impl<'a, T: 'a + Clone> Plugin<T> {
dynamic,
conf: None,
on_init: None,
};
}
}

pub fn on_init(&'a mut self, callback: &'static OnInit<T>) -> Self {
Expand Down
17 changes: 7 additions & 10 deletions plugin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&macro_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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
)
Expand Down
5 changes: 3 additions & 2 deletions rpc/src/lightningrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<responses::FeeRates, Error> {
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.
Expand Down Expand Up @@ -225,7 +225,7 @@ impl LightningRPC {
self.call(
"pay",
requests::Pay {
bolt11: bolt11,
bolt11,
msatoshi: options.msatoshi,
description: options.description,
riskfactor: options.riskfactor,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 52aaa61

Please sign in to comment.