Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
brockelmore committed Dec 9, 2023
1 parent 0b34761 commit 18ebcda
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
26 changes: 16 additions & 10 deletions crates/pyrometer/src/graph_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ impl GraphDot for Analyzer {

let g = &G { graph: &new_graph };
let children = g.children_exclude(node, 0, &[Edge::Context(ContextEdge::Subcontext)]);
let mut children_edges = g.edges_for_nodes(&children).into_iter().filter(|(_, _, e, _)| {
*e != Edge::Context(ContextEdge::InputVariable)
}).collect::<BTreeSet<_>>();
let mut children_edges = g
.edges_for_nodes(&children)
.into_iter()
.filter(|(_, _, e, _)| *e != Edge::Context(ContextEdge::InputVariable))
.collect::<BTreeSet<_>>();
children_edges.extend(
self.graph()
.edges_directed(node, Direction::Incoming)
Expand Down Expand Up @@ -167,7 +169,11 @@ impl GraphDot for Analyzer {
}
}
Node::ContextVar(_) => {
let mut children = g.children_exclude(*child, usize::MAX, &[Edge::Context(ContextEdge::InputVariable)]);
let mut children = g.children_exclude(
*child,
usize::MAX,
&[Edge::Context(ContextEdge::InputVariable)],
);
children.insert(*child);
children
.iter()
Expand Down Expand Up @@ -513,10 +519,10 @@ flowchart BT
)?)
}
Node::ContextVar(_) => None,
n => {
_n => {
handled_nodes.lock().unwrap().insert(*node);
Some(format!(
" {}(\"{}\")",//\n style {} stroke:{}",
" {}(\"{}\")", //\n style {} stroke:{}",
petgraph::graph::GraphIndex::index(node),
as_dot_str(*node, self).replace('\"', "\'"),
// petgraph::graph::GraphIndex::index(node),
Expand All @@ -540,7 +546,7 @@ flowchart BT
}
let from = from.index();
let to = to.index();
let edge_idx = edge.index();
let _edge_idx = edge.index();
Some(format!(
" {from:} -->|\"{:?}\"| {to:}", // class {to} linkSource{edge_idx}\n class {from} linkTarget{edge_idx}",
self.graph().edge_weight(edge).unwrap()
Expand Down Expand Up @@ -579,10 +585,10 @@ pub fn mermaid_node(
g: &impl GraphBackend,
indent: &str,
node: NodeIdx,
style: bool,
class: Option<&str>,
_style: bool,
_class: Option<&str>,
) -> String {
let mut node_str = format!(
let node_str = format!(
"{indent}{}(\"{}\")",
petgraph::graph::GraphIndex::index(&node),
as_dot_str(node, g).replace('\"', "\'"),
Expand Down
4 changes: 2 additions & 2 deletions crates/shared/src/graph_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ pub trait GraphDot: GraphLike {
temp_config_path.push(config_name);

let mut file = fs::File::create(temp_config_path.clone()).unwrap();
file.write_all(include_bytes!("./mermaidConfig.json")).unwrap();
file.write_all(include_bytes!("./mermaidConfig.json"))
.unwrap();

let temp_svg_filename: String = format!("{}/mermaid.svg", &temp_dir.to_string_lossy());


let mut file = fs::File::create(temp_path.clone()).unwrap();
file.write_all(self.mermaid_str().as_bytes()).unwrap();
Command::new("mmdc")
Expand Down
21 changes: 9 additions & 12 deletions crates/shared/src/search.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fmt::Debug;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::Debug;

use crate::{GraphLike, NodeIdx};
use petgraph::{graph::*, visit::EdgeRef, Direction};
Expand All @@ -19,7 +19,7 @@ where
pub trait Search: GraphLike
where
<Self as GraphLike>::Edge: PartialEq + Heirarchical + Copy + Debug,
<Self as GraphLike>::Node: Debug,
<Self as GraphLike>::Node: Debug,
{
fn search_for_ancestor(
&self,
Expand Down Expand Up @@ -390,16 +390,13 @@ where
seen.insert(start);
}

let edges = self.graph().edges_directed(start, Direction::Incoming).filter(|edge| {
!exclude_edges.contains(edge.weight())
});

let mut this_children: BTreeSet<NodeIdx> = edges
.clone()
.map(|edge| {
edge.source()
})
.collect();
let edges = self
.graph()
.edges_directed(start, Direction::Incoming)
.filter(|edge| !exclude_edges.contains(edge.weight()));

let mut this_children: BTreeSet<NodeIdx> =
edges.clone().map(|edge| edge.source()).collect();

this_children.extend(
edges
Expand Down

0 comments on commit 18ebcda

Please sign in to comment.