Skip to content

Commit

Permalink
Clippy appeased
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwiebe committed Jul 27, 2022
1 parent 0d81604 commit 84abf55
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 262 deletions.
3 changes: 1 addition & 2 deletions masq_lib/src/test_utils/ui_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ impl UiConnection {
Err(UiMessageError::PayloadError(message_body)) => {
let payload_error = message_body
.payload
.err()
.expect("PayloadError message body contained no payload error");
.expect_err("PayloadError message body contained no payload error");
ReceiveResult::TransactionError(payload_error)
}
Err(e) => ReceiveResult::MarshalError((incoming_msg, e)),
Expand Down
4 changes: 3 additions & 1 deletion node/src/entry_dns/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::packet_facade::ResourceRecord;
use masq_lib::logger::Logger;
use std::convert::From;
use std::convert::TryFrom;
use std::fmt::Write as _;
use std::net::SocketAddr;
use std::net::{Ipv4Addr, Ipv6Addr};
use std::time::Instant;
Expand Down Expand Up @@ -124,7 +125,8 @@ fn write_log(from: &RequestRecord, to: &ResponseRecord, addr: &SocketAddr, logge
Ok(c) => <&'static str>::from(c),
Err(_) => UNKNOWN,
};
query_list += &format!(
let _ = write!(
query_list,
"{}/{}/{}",
RecordType::from(query.get_query_type()),
class_string,
Expand Down
17 changes: 9 additions & 8 deletions node/src/neighborhood/dot_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use crate::sub_lib::cryptde::PublicKey;
use crate::sub_lib::node_addr::NodeAddr;
use std::fmt::Write as _;

pub trait DotRenderable {
fn render(&self) -> String;
Expand All @@ -25,17 +26,17 @@ pub struct NodeRenderable {
impl DotRenderable for NodeRenderable {
fn render(&self) -> String {
let mut result = String::new();
result.push_str(&format!("\"{}\"", self.public_key));
result.push_str(&self.render_label());
let _ = write!(result, "\"{}\"", self.public_key);
let _ = write!(result, "{}", &self.render_label());
if !self.is_present {
result.push_str(" [shape=none]")
let _ = write!(result, " [shape=none]");
} else if self.known_target {
result.push_str(" [shape=box]")
let _ = write!(result, " [shape=box]");
}
if self.known_source {
result.push_str(" [style=filled]")
let _ = write!(result, " [style=filled]");
}
result.push(';');
let _ = write!(result, ";");
result
}
}
Expand Down Expand Up @@ -77,15 +78,15 @@ pub struct EdgeRenderable {
impl DotRenderable for EdgeRenderable {
fn render(&self) -> String {
let mut result = String::new();
result.push_str(&format!("\"{}\" -> \"{}\";", self.from, self.to));
let _ = write!(result, "\"{}\" -> \"{}\";", self.from, self.to);
result
}
}

pub fn render_dot_graph(renderables: Vec<Box<dyn DotRenderable>>) -> String {
let mut result = String::from("digraph db {");
for renderable in renderables {
result.push_str(&format!(" {}", renderable.render()))
let _ = write!(result, " {}", renderable.render());
}
result.push_str(" }");
result
Expand Down
53 changes: 35 additions & 18 deletions node/src/neighborhood/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::convert::{TryFrom, TryInto};
use std::fmt::Debug;
use std::fmt::Error;
use std::fmt::Formatter;
use std::fmt::Write as _;
use std::net::{IpAddr, SocketAddr};

#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -97,37 +98,53 @@ impl TryFrom<&Value> for GossipNodeRecord {
impl GossipNodeRecord {
fn to_human_readable(&self) -> String {
let mut human_readable = String::new();
human_readable.push_str("\nGossipNodeRecord {");
let _ = write!(human_readable, "\nGossipNodeRecord {{");
match NodeRecordInner_0v1::try_from(self) {
Ok(nri) => {
human_readable.push_str("\n\tinner: NodeRecordInner_0v1 {");
human_readable.push_str(&format!("\n\t\tpublic_key: {:?},", &nri.public_key));
human_readable.push_str(&format!("\n\t\tnode_addr_opt: {:?},", self.node_addr_opt));
human_readable
.push_str(&format!("\n\t\tearning_wallet: {:?},", nri.earning_wallet));
human_readable.push_str(&format!("\n\t\trate_pack: {:?},", nri.rate_pack));
human_readable.push_str(&format!(
let _ = write!(human_readable, "\n\tinner: NodeRecordInner_0v1 {{");
let _ = write!(human_readable, "\n\t\tpublic_key: {:?},", &nri.public_key);
let _ = write!(
human_readable,
"\n\t\tnode_addr_opt: {:?},",
self.node_addr_opt
);
let _ = write!(
human_readable,
"\n\t\tearning_wallet: {:?},",
nri.earning_wallet
);
let _ = write!(human_readable, "\n\t\trate_pack: {:?},", nri.rate_pack);
let _ = write!(
human_readable,
"\n\t\tneighbors: {:?},",
nri.neighbors
.clone()
.into_iter()
.collect::<Vec<PublicKey>>()
));
human_readable.push_str(&format!("\n\t\tversion: {:?},", nri.version));
human_readable.push_str("\n\t},");
);
let _ = write!(human_readable, "\n\t\tversion: {:?},", nri.version);
let _ = write!(human_readable, "\n\t}},");
}
Err(_e) => {
let _ = write!(human_readable, "\n\tinner: <non-deserializable>");
}
Err(_e) => human_readable.push_str("\n\tinner: <non-deserializable>"),
};
human_readable.push_str(&format!("\n\tnode_addr_opt: {:?},", self.node_addr_opt));
human_readable.push_str(&format!(
let _ = write!(
human_readable,
"\n\tnode_addr_opt: {:?},",
self.node_addr_opt
);
let _ = write!(
human_readable,
"\n\tsigned_data:\n{:?}",
self.signed_data.as_slice().hex_dump()
));
human_readable.push_str(&format!(
);
let _ = write!(
human_readable,
"\n\tsignature:\n{:?}",
self.signature.as_slice().hex_dump()
));
human_readable.push_str("\n}");
);
let _ = write!(human_readable, "\n}}");
human_readable
}
}
Expand Down
Loading

0 comments on commit 84abf55

Please sign in to comment.