From e9202024d798f5722580dfe7811c8acea5431298 Mon Sep 17 00:00:00 2001
From: Avi Weinstock <aweinstock314@gmail.com>
Date: Tue, 8 Jun 2021 15:08:14 -0400
Subject: [PATCH] Run clippy for graphviz target in CI and add instructions on
 how to consume the output.

---
 .gitlab/CI/check.gitlab-ci.yml    | 2 +-
 common/src/bin/recipe_graphviz.rs | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.gitlab/CI/check.gitlab-ci.yml b/.gitlab/CI/check.gitlab-ci.yml
index 60f0e8425f..51f306d8e8 100644
--- a/.gitlab/CI/check.gitlab-ci.yml
+++ b/.gitlab/CI/check.gitlab-ci.yml
@@ -6,7 +6,7 @@ code-quality:
   script:
     - ln -s /dockercache/target target
     - rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly
-    - cargo clippy --all-targets --locked  --features="bin_csv,bin_bot,asset_tweak" -- -D warnings
+    - cargo clippy --all-targets --locked  --features="bin_csv,bin_graphviz,bin_bot,asset_tweak" -- -D warnings
     - cargo fmt --all -- --check
 
 security:
diff --git a/common/src/bin/recipe_graphviz.rs b/common/src/bin/recipe_graphviz.rs
index 2feb0540ca..b7fb176207 100644
--- a/common/src/bin/recipe_graphviz.rs
+++ b/common/src/bin/recipe_graphviz.rs
@@ -15,10 +15,9 @@ fn main() {
     let mut graph = Graph::new();
     let mut nodes = HashMap::new();
     let mut add_node = |graph: &mut Graph<_, _>, node: &str| {
-        nodes
+        *nodes
             .entry(node.to_owned())
             .or_insert_with(|| graph.add_node(node.to_owned()))
-            .clone()
     };
     for (_, recipe) in recipes.iter() {
         let output = recipe.output.0.item_definition_id();
@@ -40,6 +39,8 @@ fn main() {
             graph.add_edge(in_node, out_node, ());
         }
     }
+    // you can render the dot file as a png with `dot -Tpng recipe_graph.dot >
+    // recipe_graph.png` or interactively view it with `xdot recipe_graph.dot`
     let mut f = File::create("recipe_graph.dot").unwrap();
     writeln!(f, "digraph {{").unwrap();
     writeln!(f, "rankdir = \"LR\"").unwrap();