From dcd80d7052391c92c095a4085931c12d246f0520 Mon Sep 17 00:00:00 2001 From: Peer Sommerlund Date: Fri, 18 Jul 2025 09:46:45 +0200 Subject: [PATCH 1/2] refactor: Remove unused fields --- src/graph.rs | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/graph.rs b/src/graph.rs index 23a5a31..77db2bd 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -34,10 +34,6 @@ pub struct GitGraph { pub indices: HashMap, /// All detected branches and tags, including merged and deleted pub all_branches: Vec, - /// Indices of all real (still existing) branches in `all_branches` - pub branches: Vec, - /// Indices of all tags in `all_branches` - pub tags: Vec, /// The current HEAD pub head: HeadInfo, } @@ -155,37 +151,11 @@ impl GitGraph { } } - let branches = all_branches - .iter() - .enumerate() - .filter_map(|(idx, br)| { - if !br.is_merged && !br.is_tag { - Some(idx) - } else { - None - } - }) - .collect(); - - let tags = all_branches - .iter() - .enumerate() - .filter_map(|(idx, br)| { - if !br.is_merged && br.is_tag { - Some(idx) - } else { - None - } - }) - .collect(); - Ok(GitGraph { repository, commits: filtered_commits, indices: filtered_indices, all_branches, - branches, - tags, head, }) } From 78081dafe33f453b78fcf8bfa792e8856ff8ce13 Mon Sep 17 00:00:00 2001 From: Peer Sommerlund Date: Fri, 18 Jul 2025 07:53:58 +0200 Subject: [PATCH 2/2] TODO Enable cognitive complexity. Some of the functions are quite long and complex. This change adds some Clippy warnings that will find them. The warnings can be enabled temporarily while working on refactoring. They should be enabled permanently once refactoring is completed. --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 428d5bf..1e044dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,15 @@ //! 2. Lay out the graph structure according to the branching model (See [graph]) //! 3. Render the layout to text or SVG (See [mod@print]) +/* TODO git-graph has some complex functions, which make it hard to +understand and modify the code. The code should be made simpler +so the following warnings can be enabled without triggering. + +// Configure clippy to look for complex functions +#![warn(clippy::cognitive_complexity)] +#![warn(clippy::too_many_lines)] +*/ + use git2::Repository; use std::path::Path;