From 2227eb36d6b278746392bb9f910385515e58bdbc Mon Sep 17 00:00:00 2001 From: Tim Oram Date: Mon, 19 Feb 2024 10:00:34 -0330 Subject: Reenable the unused lint, and cleanup unused --- src/application.rs | 2 +- src/components/choice/tests.rs | 6 +- src/components/search_bar/tests.rs | 6 +- src/config/theme.rs | 2 +- src/display.rs | 1 + src/git/errors.rs | 4 + src/git/repository.rs | 207 +++++++++++---------- src/input/event_provider.rs | 2 +- src/input/standard_event.rs | 1 + src/input/thread/state.rs | 1 - src/main.rs | 10 +- src/modules/confirm_rebase.rs | 2 +- src/modules/external_editor/argument_tokenizer.rs | 2 - src/modules/external_editor/tests.rs | 9 +- src/modules/insert/tests.rs | 8 +- src/modules/list/search.rs | 2 +- src/modules/list/tests/abort_and_rebase.rs | 2 +- src/modules/list/tests/activate.rs | 5 +- src/modules/list/tests/change_action.rs | 2 +- src/modules/list/tests/edit_mode.rs | 2 +- src/modules/list/tests/external_editor.rs | 2 +- src/modules/list/tests/help.rs | 2 +- src/modules/list/tests/insert_line.rs | 2 +- src/modules/list/tests/movement.rs | 3 +- src/modules/list/tests/normal_mode.rs | 9 +- src/modules/list/tests/read_event.rs | 17 +- src/modules/list/tests/remove_lines.rs | 2 +- src/modules/list/tests/render.rs | 2 +- src/modules/list/tests/search.rs | 2 +- src/modules/list/tests/show_commit.rs | 2 +- src/modules/list/tests/swap_lines.rs | 2 +- src/modules/list/tests/toggle_break.rs | 7 +- src/modules/list/tests/toggle_option.rs | 1 - src/modules/list/tests/undo_redo.rs | 2 +- src/modules/list/tests/visual_mode.rs | 24 ++- src/process/artifact.rs | 5 +- src/process/results.rs | 50 +++-- src/process/tests.rs | 6 +- src/runtime/notifier.rs | 4 +- src/runtime/runtime.rs | 16 +- src/runtime/status.rs | 2 + src/search/interrupter.rs | 3 +- src/test_helpers.rs | 3 +- .../assertions/assert_rendered_output.rs | 21 ++- src/test_helpers/assertions/assert_results.rs | 11 +- src/test_helpers/builders/commit.rs | 5 - src/test_helpers/builders/commit_diff.rs | 3 - src/test_helpers/builders/file_status.rs | 4 - src/test_helpers/builders/reference.rs | 1 - src/test_helpers/create_commit.rs | 2 - src/test_helpers/create_event_reader.rs | 1 - src/test_helpers/mocks/crossterm.rs | 3 +- src/test_helpers/shared/replace_invisibles.rs | 7 - src/test_helpers/testers/module.rs | 2 - src/test_helpers/testers/threadable.rs | 1 - src/test_helpers/with_temp_bare_repository.rs | 1 - src/test_helpers/with_view_state.rs | 2 - src/tests.rs | 2 +- 58 files changed, 222 insertions(+), 288 deletions(-) diff --git a/src/application.rs b/src/application.rs index 0a9fa56..60190a4 100644 --- a/src/application.rs +++ b/src/application.rs @@ -194,7 +194,7 @@ mod tests { use super::*; use crate::{ display::Size, - input::{Event, KeyCode, KeyEvent, KeyModifiers}, + input::{KeyCode, KeyEvent, KeyModifiers}, module::Modules, runtime::{Installer, RuntimeError}, test_helpers::{ diff --git a/src/components/choice/tests.rs b/src/components/choice/tests.rs index b2019e5..8f1dbd2 100644 --- a/src/components/choice/tests.rs +++ b/src/components/choice/tests.rs @@ -1,11 +1,7 @@ use rstest::rstest; use super::*; -use crate::{ - assert_rendered_output, - input::StandardEvent, - test_helpers::{assertions::assert_rendered_output::AssertRenderOptions, with_view_state}, -}; +use crate::{assert_rendered_output, input::StandardEvent, test_helpers::with_view_state}; #[derive(Clone, Debug, PartialEq)] enum TestAction { diff --git a/src/components/search_bar/tests.rs b/src/components/search_bar/tests.rs index 7d2e44c..1727f0d 100644 --- a/src/components/search_bar/tests.rs +++ b/src/components/search_bar/tests.rs @@ -1,7 +1,11 @@ use claims::{assert_none, assert_some_eq}; use super::*; -use crate::{assert_rendered_output, view::ViewData}; +use crate::{ + assert_rendered_output, + test_helpers::assertions::assert_rendered_output::AssertRenderOptions, + view::ViewData, +}; fn create_view_data(search_bar: &SearchBar) -> ViewData { let view_line = search_bar.build_view_line(); diff --git a/src/config/theme.rs b/src/config/theme.rs index 97da2f2..3310aa4 100644 --- a/src/config/theme.rs +++ b/src/config/theme.rs @@ -138,7 +138,7 @@ mod tests { use super::*; use crate::{ - config::{ConfigErrorCause, InvalidColorError}, + config::InvalidColorError, test_helpers::{invalid_utf, with_git_config}, }; diff --git a/src/display.rs b/src/display.rs index 658fe35..1a6bf49 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,3 +1,4 @@ +#![cfg_attr(test, allow(dead_code, unused_imports))] //! Git Interactive Rebase Tool - Display Module //! //! # Description diff --git a/src/git/errors.rs b/src/git/errors.rs index ae88772..df789a7 100644 --- a/src/git/errors.rs +++ b/src/git/errors.rs @@ -13,6 +13,7 @@ use thiserror::Error; pub(crate) enum RepositoryLoadKind { /// Repository was loaded from the path provided through an environment variable Environment, + #[cfg(test)] /// Repository was loaded from a direct path Path, } @@ -21,6 +22,7 @@ impl Display for RepositoryLoadKind { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match *self { Self::Environment => write!(f, "environment"), + #[cfg(test)] Self::Path => write!(f, "path"), } } @@ -29,6 +31,7 @@ impl Display for RepositoryLoadKind { /// Git errors #[derive(Error, Debug, PartialEq)] #[non_exhaustive] +#[allow(clippy::enum_variant_names)] pub(crate) enum GitError { /// The repository could not be loaded #[error("Could not open repository from {kind}")] @@ -47,6 +50,7 @@ pub(crate) enum GitError { cause: git2::Error, }, /// The configuration could not be loaded + #[cfg(test)] #[error("Could not load configuration")] ReferenceNotFound { /// The internal cause of the load error. diff --git a/src/git/repository.rs b/src/git/repository.rs index d415d82..0ed9ddc 100644 --- a/src/git/repository.rs +++ b/src/git/repository.rs @@ -1,22 +1,11 @@ use std::{ fmt::{Debug, Formatter}, - path::{Path, PathBuf}, sync::Arc, }; -use git2::{Oid, Signature}; use parking_lot::Mutex; -use crate::git::{ - Commit, - CommitDiff, - CommitDiffLoader, - CommitDiffLoaderOptions, - Config, - GitError, - Reference, - RepositoryLoadKind, -}; +use crate::git::{CommitDiff, CommitDiffLoader, CommitDiffLoaderOptions, Config, GitError, RepositoryLoadKind}; /// A light cloneable, simple wrapper around the `git2::Repository` struct #[derive(Clone)] @@ -43,22 +32,6 @@ impl Repository { }) } - /// Attempt to open an already-existing repository at `path`. - /// - /// # Errors - /// Will result in an error if the repository cannot be opened. - pub(crate) fn open_from_path(path: &Path) -> Result { - let repository = git2::Repository::open(path).map_err(|e| { - GitError::RepositoryLoad { - kind: RepositoryLoadKind::Path, - cause: e, - } - })?; - Ok(Self { - repository: Arc::new(Mutex::new(repository)), - }) - } - /// Load the git configuration for the repository. /// /// # Errors @@ -93,78 +66,6 @@ impl Repository { .map_err(|e| GitError::CommitLoad { cause: e })? .remove(0)) } - - /// Find a reference by the reference name. - /// - /// # Errors - /// Will result in an error if the reference cannot be found. - pub(crate) fn find_reference(&self, reference: &str) -> Result { - let repo = self.repository.lock(); - let git2_reference = repo - .find_reference(reference) - .map_err(|e| GitError::ReferenceNotFound { cause: e })?; - Ok(Reference::from(&git2_reference)) - } - - /// Find a commit by a reference name. - /// - /// # Errors - /// Will result in an error if the reference cannot be found or is not a commit. - pub(crate) fn find_commit(&self, reference: &str) -> Result { - let repo = self.repository.lock(); - let git2_reference = repo - .find_reference(reference) - .map_err(|e| GitError::ReferenceNotFound { cause: e })?; - Commit::try_from(&git2_reference) - } - - pub(crate) fn repo_path(&self) -> PathBuf { - self.repository.lock().path().to_path_buf() - } - - pub(crate) fn head_id(&self, head_name: &str) -> Result { - let repo = self.repository.lock(); - let ref_name = format!("refs/heads/{head_name}"); - let revision = repo.revparse_single(ref_name.as_str())?; - Ok(revision.id()) - } - - pub(crate) fn commit_id_from_ref(&self, reference: &str) -> Result { - let repo = self.repository.lock(); - let commit = repo.find_reference(reference)?.peel_to_commit()?; - Ok(commit.id()) - } - - pub(crate) fn add_path_to_index(&self, path: &Path) -> Result<(), git2::Error> { - let repo = self.repository.lock(); - let mut index = repo.index()?; - index.add_path(path) - } - - pub(crate) fn remove_path_from_index(&self, path: &Path) -> Result<(), git2::Error> { - let repo = self.repository.lock(); - let mut index = repo.index()?; - index.remove_path(path) - } - - pub(crate) fn create_commit_on_index( - &self, - reference: &str, - author: &Signature<'_>, - committer: &Signature<'_>, - message: &str, - ) -> Result<(), git2::Error> { - let repo = self.repository.lock(); - let tree = repo.find_tree(repo.index()?.write_tree()?)?; - let head = repo.find_reference(reference)?.peel_to_commit()?; - _ = repo.commit(Some("HEAD"), author, committer, message, &tree, &[&head])?; - Ok(()) - } - - #[cfg(test)] - pub(crate) fn repository(&self) -> Arc> { - Arc::clone(&self.repository) - } } impl From for Repository { @@ -183,10 +84,112 @@ impl Debug for Repository { } } +#[cfg(test)] +mod tests { + use std::{ + path::{Path, PathBuf}, + sync::Arc, + }; + + use git2::{Oid, Signature}; + use parking_lot::Mutex; + + use crate::git::{Commit, GitError, Reference, Repository, RepositoryLoadKind}; + + impl Repository { + /// Attempt to open an already-existing repository at `path`. + /// + /// # Errors + /// Will result in an error if the repository cannot be opened. + pub(crate) fn open_from_path(path: &Path) -> Result { + let repository = git2::Repository::open(path).map_err(|e| { + GitError::RepositoryLoad { + kind: RepositoryLoadKind::Path, + cause: e, + } + })?; + Ok(Self { + repository: Arc::new(Mutex::new(repository)), + }) + } + + /// Find a reference by the reference name. + /// + /// # Errors + /// Will result in an error if the reference cannot be found. + pub(crate) fn find_reference(&self, reference: &str) -> Result { + let repo = self.repository.lock(); + let git2_reference = repo + .find_reference(reference) + .map_err(|e| GitError::ReferenceNotFound { cause: e })?; + Ok(Reference::from(&git2_reference)) + } + + /// Find a commit by a reference name. + /// + /// # Errors + /// Will result in an error if the reference cannot be found or is not a commit. + pub(crate) fn find_commit(&self, reference: &str) -> Result { + let repo = self.repository.lock(); + let git2_reference = repo + .find_reference(reference) + .map_err(|e| GitError::ReferenceNotFound { cause: e })?; + Commit::try_from(&git2_reference) + } + + pub(crate) fn repo_path(&self) -> PathBuf { + self.repository.lock().path().to_path_buf() + } + + pub(crate) fn head_id(&self, head_name: &str) -> Result { + let repo = self.repository.lock(); + let ref_name = format!("refs/heads/{head_name}"); + let revision = repo.revparse_single(ref_name.as_str())?; + Ok(revision.id()) + } + + pub(crate) fn commit_id_from_ref(&self, reference: &str) -> Result { + let repo = self.repository.lock(); + let commit = repo.find_reference(reference)?.peel_to_commit()?; + Ok(commit.id()) + } + + pub(crate) fn add_path_to_index(&self, path: &Path) -> Result<(), git2::Error> { + let repo = self.repository.lock(); + let mut index = repo.index()?; + index.add_path(path) + } + + pub(crate) fn remove_path_from_index(&self, path: &Path) -> Result<(), git2::Error> { + let repo = self.repository.lock(); + let mut index = repo.index()?; + index.remove_path(path) + } + + pub(crate) fn create_commit_on_index( + &self, + reference: &str, + author: &Signature<'_>, + committer: &Signature<'_>, + message: &str, + ) -> Result<(), git2::Error> { + let repo = self.repository.lock(); + let tree = repo.find_tree(repo.index()?.write_tree()?)?; + let head = repo.find_reference(reference)?.peel_to_commit()?; + _ = repo.commit(Some("HEAD"), author, committer, message, &tree, &[&head])?; + Ok(()) + } + + pub(crate) fn repository(&self) -> Arc> { + Arc::clone(&self.repository) + } + } +} + // Paths in Windows makes these tests difficult, so disable #[cfg(all(unix, test))] -mod tests { - use std::env::set_var; +mod unix_tests { + use std::path::Path; use claims::{assert_err_eq, assert_ok}; use git2::{ErrorClass, ErrorCode}; diff --git a/src/input/event_provider.rs b/src/input/event_provider.rs index 5c7264b..e6743a7 100644 --- a/src/input/event_provider.rs +++ b/src/input/event_provider.rs @@ -74,7 +74,7 @@ mod read_event_mocks { mod tests { use std::{io, io::ErrorKind}; - use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseButton}; + use crossterm::event::{KeyCode, KeyModifiers, MouseButton}; use super::*; diff --git a/src/input/standard_event.rs b/src/input/standard_event.rs index 69283a5..59e659d 100644 --- a/src/input/standard_event.rs +++ b/src/input/standard_event.rs @@ -2,6 +2,7 @@ #[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy)] #[non_exhaustive] pub(crate) enum StandardEvent { + #[allow(unused)] /// The exit meta event. Exit, /// The kill meta event. diff --git a/src/input/thread/state.rs b/src/input/thread/state.rs index 43fb478..57c0395 100644 --- a/src/input/thread/state.rs +++ b/src/input/thread/state.rs @@ -122,7 +122,6 @@ mod tests { }; use super::*; - use crate::input::Event; fn create_state() -> State { State::new() diff --git a/src/main.rs b/src/main.rs index 03a6b57..962bbcd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,11 +4,13 @@ #![cfg_attr( test, allow( - let_underscore_drop, clippy::cast_possible_truncation, clippy::cognitive_complexity, clippy::let_underscore_must_use, clippy::let_underscore_untyped, + clippy::missing_const_for_fn, + clippy::missing_errors_doc, + clippy::multiple_inherent_impl, clippy::needless_pass_by_value, clippy::panic, clippy::shadow_reuse, @@ -16,12 +18,14 @@ clippy::struct_field_names, clippy::undocumented_unsafe_blocks, clippy::unimplemented, - clippy::unreachable + clippy::unreachable, + clippy::unused_self, + let_underscore_drop, + missing_docs ) )] // allowable upcoming nightly lints #![cfg_attr(include_nightly_lints, allow(clippy::arc_with_non_send_sync))] -#![allow(unused)] mod application; mod arguments; diff --git a/src/modules/confirm_rebase.rs b/src/modules/confirm_rebase.rs index e63efdd..b145a02 100644 --- a/src/modules/confirm_rebase.rs +++ b/src/modules/confirm_rebase.rs @@ -54,7 +54,7 @@ mod tests { assert_results, input::{KeyCode, StandardEvent}, process::Artifact, - test_helpers::testers, + test_helpers::{assertions::assert_rendered_output::AssertRenderOptions, testers}, }; fn create_confirm_rebase() -> ConfirmRebase { diff --git a/src/modules/external_editor/argument_tokenizer.rs b/src/modules/external_editor/argument_tokenizer.rs index c30ad49..75267d7 100644 --- a/src/modules/external_editor/argument_tokenizer.rs +++ b/src/modules/external_editor/argument_tokenizer.rs @@ -1,5 +1,3 @@ -use std::iter::Iterator; - #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum State { Normal, diff --git a/src/modules/external_editor/tests.rs b/src/modules/external_editor/tests.rs index 9c886f1..c519686 100644 --- a/src/modules/external_editor/tests.rs +++ b/src/modules/external_editor/tests.rs @@ -1,14 +1,7 @@ use std::{fs, fs::File}; use super::*; -use crate::{ - assert_rendered_output, - assert_results, - input::{Event, KeyCode}, - module::ExitStatus, - process::Artifact, - test_helpers::testers, -}; +use crate::{assert_rendered_output, assert_results, input::KeyCode, process::Artifact, test_helpers::testers}; fn assert_external_editor_state_eq(actual: &ExternalEditorState, expected: &ExternalEditorState) { let actual_state = match *actual { diff --git a/src/modules/insert/tests.rs b/src/modules/insert/tests.rs index 271fbff..1a11f68 100644 --- a/src/modules/insert/tests.rs +++ b/src/modules/insert/tests.rs @@ -1,11 +1,5 @@ use super::*; -use crate::{ - assert_rendered_output, - assert_results, - input::{Event, KeyCode}, - process::Artifact, - test_helpers::testers, -}; +use crate::{assert_rendered_output, assert_results, input::KeyCode, process::Artifact, test_helpers::testers}; fn create_insert(todo_file: TodoFile) -> Insert { Insert::new(Arc::new(Mutex::new(todo_file))) diff --git a/src/modules/list/search.rs b/src/modules/list/search.rs index fd0e793..3a362ac 100644 --- a/src/modules/list/search.rs +++ b/src/modules/list/search.rs @@ -258,7 +258,7 @@ mod tests { fn search_empty_rebase_file() { with_todo_file(&[], |context| { let (_todo_file_path, todo_file) = context.to_owned(); - let mut search = create_and_run_search(todo_file, "foo", SearchResult::Complete); + let search = create_and_run_search(todo_file, "foo", SearchResult::Complete); assert_eq!(search.total_results(), 0); }); } diff --git a/src/modules/list/tests/abort_and_rebase.rs b/src/modules/list/tests/abort_and_rebase.rs index e064105..8746347 100644 --- a/src/modules/list/tests/abort_and_rebase.rs +++ b/src/modules/list/tests/abort_and_rebase.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{assert_results, process::Artifact, test_helpers::testers}; +use crate::{assert_results, process::Artifact}; #[test] fn normal_mode_abort() { diff --git a/src/modules/list/tests/activate.rs b/src/modules/list/tests/activate.rs index 24dd42e..10b5c49 100644 --- a/src/modules/list/tests/activate.rs +++ b/src/modules/list/tests/activate.rs @@ -4,8 +4,7 @@ use super::*; use crate::{ assert_results, process::Artifact, - search::{Interrupter, SearchResult, Searchable}, - test_helpers::{create_config, testers}, + search::{Interrupter, SearchResult}, }; #[derive(Clone)] @@ -14,7 +13,7 @@ struct MockedSearchable; impl Searchable for MockedSearchable { fn reset(&mut self) {} - fn search(&mut self, _: Interrupter, term: &str) -> SearchResult { + fn search(&mut self, _: Interrupter, _: &str) -> SearchResult { SearchResult::None } } diff --git a/src/modules/list/tests/change_action.rs b/src/modules/list/tests/change_action.rs index 215fd10..b7200be 100644 --- a/src/modules/list/tests/change_action.rs +++ b/src/modules/list/tests/change_action.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{action_line, assert_rendered_output, test_helpers::testers}; +use crate::{action_line, assert_rendered_output}; #[test] fn normal_mode_action_change_to_drop() { diff --git a/src/modules/list/tests/edit_mode.rs b/src/modules/list/tests/edit_mode.rs index 4736a83..579f0aa 100644 --- a/src/modules/list/tests/edit_mode.rs +++ b/src/modules/list/tests/edit_mode.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{assert_rendered_output, assert_results, input::KeyCode, process::Artifact, test_helpers::testers}; +use crate::{assert_rendered_output, assert_results, input::KeyCode, process::Artifact}; #[test] fn edit_with_edit_content() { diff --git a/src/modules/list/tests/external_editor.rs b/src/modules/list/tests/external_editor.rs index 8b0e58c..2cd93fd 100644 --- a/src/modules/list/tests/external_editor.rs +++ b/src/modules/list/tests/external_editor.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{assert_results, process::Artifact, test_helpers::testers}; +use crate::{assert_results, process::Artifact}; #[test] fn normal_mode_open_external_editor() { diff --git a/src/modules/list/tests/help.rs b/src/modules/list/tests/help.rs index 3ffb99e..78ec6ac 100644 --- a/src/modules/list/tests/help.rs +++ b/src/modules/list/tests/help.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{assert_rendered_output, input::KeyCode, test_helpers::testers}; +use crate::{assert_rendered_output, input::KeyCode}; #[test] fn normal_mode_help() { diff --git a/src/modules/list/tests/insert_line.rs b/src/modules/list/tests/insert_line.rs index 119526b..e3ec818 100644 --- a/src/modules/list/tests/insert_line.rs +++ b/src/modules/list/tests/insert_line.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{assert_results, process::Artifact, test_helpers::testers}; +use crate::{assert_results, process::Artifact}; #[test] fn insert_line() { diff --git a/src/modules/list/tests/movement.rs b/src/modules/list/tests/movement.rs index 03b055f..77a3fed 100644 --- a/src/modules/list/tests/movement.rs +++ b/src/modules/list/tests/movement.rs @@ -2,8 +2,7 @@ use super::*; use crate::{ action_line, assert_rendered_output, - input::{KeyModifiers, MouseEvent, MouseEventKind}, - test_helpers::testers, + input::{KeyModifiers, MouseEvent}, }; #[test] diff --git a/src/modules/list/tests/normal_mode.rs b/src/modules/list/tests/normal_mode.rs index ec4306b..7e277ec 100644 --- a/src/modules/list/tests/normal_mode.rs +++ b/src/modules/list/tests/normal_mode.rs @@ -1,12 +1,5 @@ use super::*; -use crate::{ - action_line, - assert_rendered_output, - assert_results, - input::KeyCode, - process::Artifact, - test_helpers::testers, -}; +use crate::{action_line, assert_rendered_output, assert_results, input::KeyCode, process::Artifact}; #[test] fn change_auto_select_next_with_next_line() { diff --git a/src/modules/list/tests/read_event.rs b/src/modules/list/tests/read_event.rs index 63646c6..a2aa411 100644 --- a/src/modules/list/tests/read_event.rs +++ b/src/modules/list/tests/read_event.rs @@ -1,10 +1,7 @@ use rstest::rstest; use super::*; -use crate::{ - input::{KeyCode, KeyModifiers, MouseEvent}, - test_helpers::testers, -}; +use crate::input::{KeyCode, KeyModifiers, MouseEvent}; #[test] fn edit_mode_passthrough_event() { @@ -63,7 +60,7 @@ fn search() { #[case::togglevisualmode('v', StandardEvent::ToggleVisualMode)] fn default_events_single_char(#[case] binding: char, #[case] expected: StandardEvent) { testers::read_event(Event::from(binding), |mut context| { - let mut module = create_list(&create_config(), context.take_todo_file()); + let module = create_list(&create_config(), context.take_todo_file()); assert_eq!(context.read_event(&module), Event::from(expected)); }); } @@ -80,7 +77,7 @@ fn default_events_single_char(#[case] binding: char, #[case] expected: StandardE #[case::delete(KeyCode::Delete, StandardEvent::Delete)] fn default_events_special(#[case] code: KeyCode, #[case] expected: StandardEvent) { testers::read_event(Event::from(code), |mut context| { - let mut module = create_list(&create_config(), context.take_todo_file()); + let module = create_list(&create_config(), context.take_todo_file()); assert_eq!(context.read_event(&module), Event::from(expected)); }); } @@ -118,7 +115,7 @@ fn mouse_move_down() { modifiers: KeyModifiers::empty(), }), |mut context| { - let mut module = create_list(&create_config(), context.take_todo_file()); + let module = create_list(&create_config(), context.take_todo_file()); assert_eq!(context.read_event(&module), Event::from(StandardEvent::MoveCursorDown)); }, ); @@ -134,7 +131,7 @@ fn mouse_move_up() { modifiers: KeyModifiers::empty(), }), |mut context| { - let mut module = create_list(&create_config(), context.take_todo_file()); + let module = create_list(&create_config(), context.take_todo_file()); assert_eq!(context.read_event(&module), Event::from(StandardEvent::MoveCursorUp)); }, ); @@ -149,7 +146,7 @@ fn mouse_other() { modifiers: KeyModifiers::empty(), }); testers::read_event(mouse_event, |mut context| { - let mut module = create_list(&create_config(), context.take_todo_file()); + let module = create_list(&create_config(), context.take_todo_file()); assert_eq!(context.read_event(&module), mouse_event); }); } @@ -157,7 +154,7 @@ fn mouse_other() { #[test] fn event_other() { testers::read_event(Event::None, |mut context| { - let mut module = create_list(&create_config(), context.take_todo_file()); + let module = create_list(&create_config(), context.take_todo_file()); assert_eq!(context.read_event(&module), Event::None); }); } diff --git a/src/modules/list/tests/remove_lines.rs b/src/modules/list/tests/remove_lines.rs index 7b82bc5..16e3a8b 100644 --- a/src/modules/list/tests/remove_lines.rs +++ b/src/modules/list/tests/remove_lines.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{action_line, assert_rendered_output, test_helpers::testers}; +use crate::{action_line, assert_rendered_output}; #[test] fn normal_mode_remove_line_first() { diff --git a/src/modules/list/tests/render.rs b/src/modules/list/tests/render.rs index c78d5eb..79e6da8 100644 --- a/src/modules/list/tests/render.rs +++ b/src/modules/list/tests/render.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{assert_rendered_output, test_helpers::testers}; +use crate::{assert_rendered_output, test_helpers::assertions::assert_rendered_output::AssertRenderOptions}; #[test] fn empty_list() { diff --git a/src/modules/list/tests/search.rs b/src/modules/list/tests/search.rs index 8740efd..8b1fc7b 100644 --- a/src/modules/list/tests/search.rs +++ b/src/modules/list/tests/search.rs @@ -287,7 +287,7 @@ fn search_indicator_refresh_on_update() { #[test] fn start_edit() { - search_test(&[Action::Start("")], &["pick aaaaaaaa comment"], |mut test_context| { + search_test(&[Action::Start("")], &["pick aaaaaaaa comment"], |test_context| { assert!(test_context.list.search_bar.is_active()); }); } diff --git a/src/modules/list/tests/show_commit.rs b/src/modules/list/tests/show_commit.rs index e9ee1c1..84c5691 100644 --- a/src/modules/list/tests/show_commit.rs +++ b/src/modules/list/tests/show_commit.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{assert_results, process::Artifact, test_helpers::testers}; +use crate::{assert_results, process::Artifact}; #[test] fn when_hash_available() { diff --git a/src/modules/list/tests/swap_lines.rs b/src/modules/list/tests/swap_lines.rs index b84d28a..93fda8f 100644 --- a/src/modules/list/tests/swap_lines.rs +++ b/src/modules/list/tests/swap_lines.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{action_line, assert_rendered_output, test_helpers::testers}; +use crate::{action_line, assert_rendered_output}; #[test] fn normal_mode_change_swap_down() { diff --git a/src/modules/list/tests/toggle_break.rs b/src/modules/list/tests/toggle_break.rs index ac5dd1b..8c4ac37 100644 --- a/src/modules/list/tests/toggle_break.rs +++ b/src/modules/list/tests/toggle_break.rs @@ -1,10 +1,5 @@ use super::*; -use crate::{ - action_line, - assert_rendered_output, - test_helpers::testers, - todo_file::{Action::Pick, ParseError}, -}; +use crate::{action_line, assert_rendered_output}; #[test] fn change_toggle_break_add() { diff --git a/src/modules/list/tests/toggle_option.rs b/src/modules/list/tests/toggle_option.rs index 5cc38a0..f1c75ce 100644 --- a/src/modules/list/tests/toggle_option.rs +++ b/src/modules/list/tests/toggle_option.rs @@ -1,7 +1,6 @@ use claims::{assert_none, assert_some, assert_some_eq}; use super::*; -use crate::test_helpers::testers; #[test] fn on_fixup_keep_message() { diff --git a/src/modules/list/tests/undo_redo.rs b/src/modules/list/tests/undo_redo.rs index 2aaaf92..cf83fcb 100644 --- a/src/modules/list/tests/undo_redo.rs +++ b/src/modules/list/tests/undo_redo.rs @@ -1,5 +1,5 @@ use super::*; -use crate::{action_line, assert_rendered_output, assert_results, process::Artifact, test_helpers::testers}; +use crate::{action_line, assert_rendered_output, assert_results, process::Artifact}; #[test] fn normal_mode_undo() { diff --git a/src/modules/list/tests/visual_mode.rs b/src/modules/list/tests/visual_mode.rs index ffebd26..c7f1741 100644 --- a/src/modules/list/tests/visual_mode.rs +++ b/src/modules/list/tests/visual_mode.rs @@ -6,7 +6,7 @@ use crate::{ input::KeyCode, process::Artifact, render_line, - test_helpers::{assertions::assert_rendered_output::AssertRenderOptions, testers}, + test_helpers::assertions::assert_rendered_output::AssertRenderOptions, }; fn render_options() -> AssertRenderOptions { @@ -21,7 +21,6 @@ fn start() { |mut test_context| { let mut module = create_list(&create_config(), test_context.take_todo_file()); _ = test_context.handle_all_events(&mut module); - let view_data = test_context.build_view_data(&mut module); assert_rendered_output!( Options render_options(), test_context.build_view_data(&mut module), @@ -44,9 +43,9 @@ fn start_cursor_down_one() { |mut test_context| { let mut module = create_list(&create_config(), test_context.take_todo_file()); _ = test_context.handle_all_events(&mut module); - let view_data = test_context.build_view_data(&mut module); assert_rendered_output!( - Options render_options(),test_context.build_view_data(&mut module), + Options render_options(), + test_context.build_view_data(&mut module), render_line!(All render_line!(Contains "Dimmed"), action_line!(Selected Pick "aaa", "c1")), render_line!(All render_line!(Not Contains "Dimmed"), action_line!(Selected Pick "aaa", "c2")), action_line!(Pick "aaa", "c3") @@ -73,9 +72,9 @@ fn start_cursor_page_down() { let mut module = create_list(&create_config(), test_context.take_todo_file()); module.height = 4; _ = test_context.handle_all_events(&mut module); - let view_data = test_context.build_view_data(&mut module); assert_rendered_output!( - Options render_options(),test_context.build_view_data(&mut module), + Options render_options(), + test_context.build_view_data(&mut module), render_line!(All render_line!(Contains "Dimmed"), action_line!(Selected Pick "aaa", "c1")), render_line!(All render_line!(Contains "Dimmed"), action_line!(Selected Pick "aaa", "c2")), render_line!(All render_line!(Not Contains "Dimmed"), action_line!(Selected Pick "aaa", "c3")), @@ -107,9 +106,9 @@ fn start_cursor_from_bottom_move_up() { |mut test_context| { let mut module = create_list(&create_config(), test_context.take_todo_file()); _ = test_context.handle_all_events(&mut module); - let view_data = test_context.build_view_data(&mut module); assert_rendered_output!( - Options render_options(),test_context.build_view_data(&mut module), + Options render_options(), + test_context.build_view_data(&mut module), action_line!(Pick "aaa", "c1"), action_line!(Pick "aaa", "c2"), action_line!(Pick "aaa", "c3"), @@ -144,9 +143,9 @@ fn start_cursor_from_bottom_to_top() { |mut test_context| { let mut module = create_list(&create_config(), test_context.take_todo_file()); _ = test_context.handle_all_events(&mut module); - let view_data = test_context.build_view_data(&mut module); assert_rendered_output!( - Options render_options(),test_context.build_view_data(&mut module), + Options render_options(), + test_context.build_view_data(&mut module), render_line!(All render_line!(Not Contains "Dimmed"), action_line!(Selected Pick "aaa", "c1")), render_line!(All render_line!(Contains "Dimmed"), action_line!(Selected Pick "aaa", "c2")), render_line!(All render_line!(Contains "Dimmed"), action_line!(Selected Pick "aaa", "c3")), @@ -170,7 +169,6 @@ fn action_change_top_bottom() { |mut test_context| { let mut module = create_list(&create_config(), test_context.take_todo_file()); _ = test_context.handle_all_events(&mut module); - let view_data = test_context.build_view_data(&mut module); assert_rendered_output!( Options render_options(), test_context.build_view_data(&mut module), @@ -197,9 +195,9 @@ fn action_change_bottom_top() { |mut test_context| { let mut module = create_list(&create_config(), test_context.take_todo_file()); _ = test_context.handle_all_events(&mut module); - let view_data = test_context.build_view_data(&mut module); assert_rendered_output!( - Options render_options(),test_context.build_view_data(&mut module), + Options render_options(), + test_context.build_view_data(&mut module), render_line!(All render_line!(Not Contains "Dimmed"), action_line!(Selected Reword "aaa", "c1")), render_line!(All render_line!(Contains "Dimmed"), action_line!(Selected Reword "aaa", "c2")), render_line!(All render_line!(Contains "Dimmed"), action_line!(Selected Reword "aaa", "c3")) diff --git a/src/process/artifact.rs b/src/process/artifact.rs index 54f88b0..b46777d 100644 --- a/src/process/artifact.rs +++ b/src/process/artifact.rs @@ -43,10 +43,7 @@ mod tests { use rstest::rstest; use super::*; - use crate::{ - search::{Interrupter, SearchResult}, - test_helpers::mocks, - }; + use crate::test_helpers::mocks; #[rstest] #[case::change_state(Artifact::ChangeState(State::List), "ChangeState(List)")] diff --git a/src/process/results.rs b/src/process/results.rs index 17f7ce4..a389531 100644 --- a/src/process/results.rs +++ b/src/process/results.rs @@ -112,63 +112,57 @@ mod tests { use anyhow::anyhow; use super::*; - use crate::test_helpers::mocks; + use crate::{assert_results, test_helpers::mocks}; #[test] fn empty() { - let mut results = Results::new(); - assert!(results.artifact().is_none()); + let results = Results::new(); + assert_results!(results); } #[test] fn event() { - let mut results = Results::from(Event::from('a')); - assert!(matches!(results.artifact(), Some(Artifact::Event(_)))); + let results = Results::from(Event::from('a')); + assert_results!(results, Artifact::Event(Event::from('a'))); } #[test] fn error() { let mut results = Results::new(); results.error(anyhow!("Test Error")); - assert!(matches!(results.artifact(), Some(Artifact::Error(_, None)))); + assert_results!(results, Artifact::Error(anyhow!("Test Error"), None)); } #[test] fn error_from() { - let mut results = Results::from(anyhow!("Test Error")); - assert!(matches!(results.artifact(), Some(Artifact::Error(_, None)))); + let results = Results::from(anyhow!("Test Error")); + assert_results!(results, Artifact::Error(anyhow!("Test Error"), None)); } #[test] fn error_with_return() { let mut results = Results::new(); results.error_with_return(anyhow!("Test Error"), State::List); - assert!(matches!( - results.artifact(), - Some(Artifact::Error(_, Some(State::List))) - )); + assert_results!(results, Artifact::Error(anyhow!("Test Error"), Some(State::List))); } #[test] fn exit_status() { - let mut results = Results::from(ExitStatus::Good); - assert!(matches!( - results.artifact(), - Some(Artifact::ExitStatus(ExitStatus::Good)) - )); + let results = Results::from(ExitStatus::Good); + assert_results!(results, Artifact::ExitStatus(ExitStatus::Good)); } #[test] fn state() { - let mut results = Results::from(State::List); - assert!(matches!(results.artifact(), Some(Artifact::ChangeState(State::List)))); + let results = Results::from(State::List); + assert_results!(results, Artifact::ChangeState(State::List)); } #[test] fn search_cancel() { let mut results = Results::new(); results.search_cancel(); - assert!(matches!(results.artifact(), Some(Artifact::SearchCancel))); + assert_results!(results, Artifact::SearchCancel); } #[test] @@ -176,28 +170,31 @@ mod tests { let mut results = Results::new(); let search_term = String::from("foo"); results.search_term(search_term.as_str()); - assert!(matches!(results.artifact(), Some(Artifact::SearchTerm(search_term)))); + assert_results!(results, Artifact::SearchTerm(search_term)); } #[test] fn searchable() { let mocked_searchable: Box = Box::new(mocks::Searchable::new()); - let mut results = Results::from(mocked_searchable); - assert!(matches!(results.artifact(), Some(Artifact::Searchable(_)))); + let results = Results::from(mocked_searchable); + assert_results!(results, Artifact::Searchable(Box::new(mocks::Searchable::new()))); } #[test] fn external_command() { let mut results = Results::new(); results.external_command(String::from("editor"), vec![String::from("arg1"), String::from("arg2")]); - assert!(matches!(results.artifact(), Some(Artifact::ExternalCommand(_)))); + assert_results!( + results, + Artifact::ExternalCommand((String::from("editor"), vec![String::from("arg1"), String::from("arg2")])) + ); } #[test] fn enqueue_resize() { let mut results = Results::new(); results.enqueue_resize(); - assert!(matches!(results.artifact(), Some(Artifact::EnqueueResize))); + assert_results!(results, Artifact::EnqueueResize); } #[test] @@ -207,7 +204,6 @@ mod tests { let mut results_2 = Results::new(); results_2.state(State::List); results_1.append(results_2); - assert!(matches!(results_1.artifact(), Some(Artifact::EnqueueResize))); - assert!(matches!(results_1.artifact(), Some(Artifact::ChangeState(State::List)))); + assert_results!(results_1, Artifact::EnqueueResize, Artifact::ChangeState(State::List)); } } diff --git a/src/process/tests.rs b/src/process/tests.rs index a7e6a19..7465466 100644 --- a/src/process/tests.rs +++ b/src/process/tests.rs @@ -8,7 +8,6 @@ use crate::{ input::{InputOptions, KeyBindings}, module::{Module, DEFAULT_INPUT_OPTIONS, DEFAULT_VIEW_DATA}, runtime::Status, - search::{Interrupter, SearchResult}, test_helpers::{create_default_test_module_handler, create_test_module_handler, mocks, testers}, todo_file::Line, view::{ViewData, REFRESH_THREAD_NAME}, @@ -614,10 +613,7 @@ fn handle_search_term() { let search_term = String::from("foo"); results.search_term(search_term.as_str()); process.handle_results(results); - assert!(matches!( - search_context.state.receive_update(), - Action::Start(search_term) - )); + assert!(matches!(search_context.state.receive_update(), Action::Start(_))); }, ); } diff --git a/src/runtime/notifier.rs b/src/runtime/notifier.rs index acc3048..95f1306 100644 --- a/src/runtime/notifier.rs +++ b/src/runtime/notifier.rs @@ -26,7 +26,7 @@ impl Notifier { } /// Notify the `Runtime` to request that the `Runtime` and all other registered thread pause processing. - #[allow(clippy::missing_panics_doc)] + #[allow(clippy::missing_panics_doc, unused)] pub(crate) fn request_pause(&self) { self.sender .send((String::from(&self.thread_name), Status::RequestPause)) @@ -34,7 +34,7 @@ impl Notifier { } /// Notify the `Runtime` to request that the `Runtime` and all other registered thread resume processing. - #[allow(clippy::missing_panics_doc)] + #[allow(clippy::missing_panics_doc, unused)] pub(crate) fn request_resume(&self) { self.sender .send((String::from(&self.thread_name), Status::RequestResume)) diff --git a/src/runtime/runtime.rs b/src/runtime/runtime.rs index dc91efd..9175ccb 100644 --- a/src/runtime/runtime.rs +++ b/src/runtime/runtime.rs @@ -1,4 +1,4 @@ -use std::{clone::Clone, sync::Arc, thread}; +use std::{sync::Arc, thread}; use crossbeam_channel::{unbounded, Receiver, Sender}; use parking_lot::Mutex; @@ -33,12 +33,6 @@ impl<'runtime> Runtime<'runtime> { } } - /// Get a cloned copy of the `ThreadStatuses`. - #[must_use] - pub(crate) fn statuses(&self) -> ThreadStatuses { - self.thread_statuses.clone() - } - /// Register a new `Threadable`. pub(crate) fn register(&self, threadable: &'runtime mut (dyn Threadable)) { self.threadables.lock().push(threadable); @@ -140,6 +134,14 @@ mod tests { use super::*; + impl Runtime<'_> { + /// Get a cloned copy of the `ThreadStatuses`. + #[must_use] + pub(crate) fn statuses(&self) -> ThreadStatuses { + self.thread_statuses.clone() + } + } + #[test] fn run_thread_finish() { struct Thread; diff --git a/src/runtime/status.rs b/src/runtime/status.rs index a73a142..14cd038 100644 --- a/src/runtime/status.rs +++ b/src/runtime/status.rs @@ -13,8 +13,10 @@ pub(crate) enum Status { Waiting, /// The thread is finished. This is a final state. Ended, + #[allow(unused)] /// The thread has requested all threads pause. RequestPause, + #[allow(unused)] /// The thread has requested all threads resume. RequestResume, /// The thread has requested all threads end. diff --git a/src/search/interrupter.rs b/src/search/interrupter.rs index 7aa3549..8778dbe 100644 --- a/src/search/interrupter.rs +++ b/src/search/interrupter.rs @@ -21,10 +21,9 @@ impl Interrupter { #[cfg(test)] mod test { - use std::{ops::Sub, time::Duration}; + use std::ops::Sub; use super::*; - use crate::search::Interrupter; #[test] fn should_continue_before_finish() { diff --git a/src/test_helpers.rs b/src/test_helpers.rs index 3950e87..3da3610 100644 --- a/src/test_helpers.rs +++ b/src/test_helpers.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] pub(crate) mod assertions; pub(crate) mod builders; mod create_commit; @@ -36,6 +37,6 @@ pub(crate) use self::{ with_search::{with_search, SearchTestContext}, with_temp_bare_repository::with_temp_bare_repository, with_temp_repository::with_temp_repository, - with_todo_file::{with_todo_file, TodoFileTestContext}, + with_todo_file::with_todo_file, with_view_state::{with_view_state, ViewStateTestContext}, }; diff --git a/src/test_helpers/assertions/assert_rendered_output.rs b/src/test_helpers/assertions/assert_rendered_output.rs index 9230932..95dad50 100644 --- a/src/test_helpers/assertions/assert_rendered_output.rs +++ b/src/test_helpers/assertions/assert_rendered_output.rs @@ -3,11 +3,11 @@ mod render_style; mod render_view_data; mod render_view_line; -use std::fmt::{Debug, Formatter}; +use std::fmt::Debug; use bitflags::bitflags; -use itertools::Itertools; +#[allow(unused_imports)] pub(crate) use self::{ patterns::{ ActionPattern, @@ -19,16 +19,12 @@ pub(crate) use self::{ ExactPattern, LinePattern, NotPattern, - StartsWithPattern, }, render_style::render_style, render_view_data::render_view_data, render_view_line::render_view_line, }; -use crate::{ - test_helpers::shared::replace_invisibles, - view::{ViewData, ViewLine}, -}; +use crate::{test_helpers::shared::replace_invisibles, view::ViewData}; bitflags! { /// Options for the `assert_rendered_output!` macro @@ -45,7 +41,7 @@ bitflags! { } } -#[allow(clippy::string_slice, clippy::panic)] +#[allow(clippy::string_slice)] pub(crate) fn _assert_rendered_output( options: AssertRenderOptions, actual: &[String], @@ -270,26 +266,31 @@ macro_rules! action_line { #[macro_export] macro_rules! assert_rendered_output { ($view_data:expr, $($arg:expr),*) => { + use $crate::test_helpers::assertions::assert_rendered_output::AssertRenderOptions; assert_rendered_output!( @base AssertRenderOptions::default(), None, None, $view_data, $($arg),* ) }; (Body $view_data:expr, $($arg:expr),*) => { + use $crate::test_helpers::assertions::assert_rendered_output::AssertRenderOptions; assert_rendered_output!( @base AssertRenderOptions::BODY_ONLY, None, None, $view_data, $($arg),* ) }; (Style $view_data:expr, $($arg:expr),*) => { + use $crate::test_helpers::assertions::assert_rendered_output::AssertRenderOptions; assert_rendered_output!( @base AssertRenderOptions::INCLUDE_STYLE, None, None, $view_data, $($arg),* ) }; (Skip $start:expr, $view_data:expr, $($arg:expr),*) => { + use $crate::test_helpers::assertions::assert_rendered_output::AssertRenderOptions; assert_rendered_output!( @base AssertRenderOptions::default(), Some($start), None, $view_data, $($arg),* ) }; (Skip $start:expr;$end:expr, $view_data:expr, $($arg:expr),*) => { + use $crate::test_helpers::assertions::assert_rendered_output::AssertRenderOptions; assert_rendered_output!( @base AssertRenderOptions::default(), Some($start), Some($end), $view_data, $($arg),* ) @@ -300,11 +301,13 @@ macro_rules! assert_rendered_output { ) }; (Body, Skip $start:expr, $view_data:expr, $($arg:expr),*) => { + use $crate::test_helpers::assertions::assert_rendered_output::AssertRenderOptions; assert_rendered_output!( @base AssertRenderOptions::BODY_ONLY, Some($start), None, $view_data, $($arg),* ) }; (Body, Skip $start:expr;$end:expr, $view_data:expr, $($arg:expr),*) => { + use $crate::test_helpers::assertions::assert_rendered_output::AssertRenderOptions; assert_rendered_output!( @base AssertRenderOptions::BODY_ONLY, Some($start), Some($end), $view_data, $($arg),* ) @@ -322,7 +325,7 @@ macro_rules! assert_rendered_output { (@base $options:expr, $start:expr, $end:expr, $view_data:expr, $($arg:expr),*) => { use $crate::test_helpers::assertions::assert_rendered_output::{ _assert_rendered_output_from_view_data, - AssertRenderOptions,LinePattern + LinePattern, }; let expected: Vec> = vec![$( Box::new($arg), )*]; _assert_rendered_output_from_view_data($view_data, &expected, $options, $start, $end); diff --git a/src/test_helpers/assertions/assert_results.rs b/src/test_helpers/assertions/assert_results.rs index e53c01b..84d118c 100644 --- a/src/test_helpers/assertions/assert_results.rs +++ b/src/test_helpers/assertions/assert_results.rs @@ -73,15 +73,6 @@ impl PartialEq for ArtifactCompareWrapper { } } -// impl PartialEq for ArtifactCompareWrapper { -// fn eq(&self, other: &Artifact) -> bool { -// match self { -// ArtifactCompareWrapper::Any => true, -// ArtifactCompareWrapper::Artifact(a) => compare_artifact(a, other), -// } -// } -// } - impl Debug for ArtifactCompareWrapper { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { @@ -98,7 +89,7 @@ impl From for ArtifactCompareWrapper { } impl From for ArtifactCompareWrapper { - fn from(value: AnyArtifact) -> Self { + fn from(_: AnyArtifact) -> Self { Self::Any } } diff --git a/src/test_helpers/builders/commit.rs b/src/test_helpers/builders/commit.rs index afa15d6..a5f44e5 100644 --- a/src/test_helpers/builders/commit.rs +++ b/src/test_helpers/builders/commit.rs @@ -15,7 +15,6 @@ impl CommitBuilder { /// Create a new instance of the builder with the provided hash. The new instance will default /// to a committed date of Jan 1, 2021 UTC. All other fields are `None`. #[must_use] - #[allow(clippy::missing_panics_doc)] pub(crate) fn new(hash: &str) -> Self { Self { commit: Commit { @@ -40,7 +39,6 @@ impl CommitBuilder { /// Set the reference, use `create::testutil::ReferenceBuilder` to build a `Reference`. #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn reference(mut self, reference: Reference) -> Self { self.commit.reference = Some(reference); self @@ -48,7 +46,6 @@ impl CommitBuilder { /// Set the author name and related email address. #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn author(mut self, author: User) -> Self { self.commit.author = author; self @@ -63,7 +60,6 @@ impl CommitBuilder { /// Set the committer name and related email address. #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn committer(mut self, committer: User) -> Self { self.commit.committer = Some(committer); self @@ -92,7 +88,6 @@ impl CommitBuilder { /// Build the `Commit`. #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn build(self) -> Commit { self.commit } diff --git a/src/test_helpers/builders/commit_diff.rs b/src/test_helpers/builders/commit_diff.rs index 55b286e..a393aaf 100644 --- a/src/test_helpers/builders/commit_diff.rs +++ b/src/test_helpers/builders/commit_diff.rs @@ -27,7 +27,6 @@ impl CommitDiffBuilder { /// Set the commit. #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn commit(mut self, commit: Commit) -> Self { self.commit = commit; self @@ -35,7 +34,6 @@ impl CommitDiffBuilder { /// Set the parent commit. #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn parent(mut self, parent: Commit) -> Self { self.parent = Some(parent); self @@ -71,7 +69,6 @@ impl CommitDiffBuilder { /// Return the built `CommitDiff` #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn build(self) -> CommitDiff { CommitDiff::new( self.commit, diff --git a/src/test_helpers/builders/file_status.rs b/src/test_helpers/builders/file_status.rs index 25cb1f8..8f3be20 100644 --- a/src/test_helpers/builders/file_status.rs +++ b/src/test_helpers/builders/file_status.rs @@ -40,7 +40,6 @@ impl FileStatusBuilder { /// Set if the destination is binary. #[must_use] - #[allow(dead_code)] pub(crate) const fn destination_is_binary(mut self, binary: bool) -> Self { self.destination_is_binary = binary; self @@ -62,7 +61,6 @@ impl FileStatusBuilder { /// Set if the source is binary. #[must_use] - #[allow(dead_code)] pub(crate) const fn source_is_binary(mut self, binary: bool) -> Self { self.source_is_binary = binary; self @@ -70,7 +68,6 @@ impl FileStatusBuilder { /// Set if the source file mode. #[must_use] - #[allow(dead_code)] pub(crate) const fn source_mode(mut self, mode: FileMode) -> Self { self.source_mode = mode; self @@ -92,7 +89,6 @@ impl FileStatusBuilder { /// Build the `FileStatus` #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn build(self) -> FileStatus { let mut file_status = FileStatus::new( self.source_path, diff --git a/src/test_helpers/builders/reference.rs b/src/test_helpers/builders/reference.rs index b7cb33e..2aba0f8 100644 --- a/src/test_helpers/builders/reference.rs +++ b/src/test_helpers/builders/reference.rs @@ -48,7 +48,6 @@ impl ReferenceBuilder { /// Build the `Reference`. #[must_use] - #[allow(clippy::missing_const_for_fn)] pub(crate) fn build(self) -> Reference { Reference::new(self.hash, self.name, self.shorthand, self.kind) } diff --git a/src/test_helpers/create_commit.rs b/src/test_helpers/create_commit.rs index 03f51fa..83416f5 100644 --- a/src/test_helpers/create_commit.rs +++ b/src/test_helpers/create_commit.rs @@ -1,5 +1,3 @@ -use std::path::Path; - use lazy_static::lazy_static; use crate::{git::Repository, test_helpers::JAN_2021_EPOCH}; diff --git a/src/test_helpers/create_event_reader.rs b/src/test_helpers/create_event_reader.rs index 3c2117c..6316107 100644 --- a/src/test_helpers/create_event_reader.rs +++ b/src/test_helpers/create_event_reader.rs @@ -13,7 +13,6 @@ use crate::input::{Event, EventReaderFn}; /// /// # Panics /// If provided an event generator that returns a `Event::MetaEvent` or `Event::StandardEvent` event type. -#[allow(clippy::panic)] pub(crate) fn create_event_reader( event_generator: EventGeneratorFunction, ) -> impl EventReaderFn diff --git a/src/test_helpers/mocks/crossterm.rs b/src/test_helpers/mocks/crossterm.rs index 825bf05..cd88cd7 100644 --- a/src/test_helpers/mocks/crossterm.rs +++ b/src/test_helpers/mocks/crossterm.rs @@ -1,4 +1,4 @@ -use std::{io, ops::Deref, sync::Arc}; +use std::sync::Arc; use ::crossterm::style::{Attribute, Attributes, Color, Colors}; use parking_lot::RwLock; @@ -20,7 +20,6 @@ pub(crate) enum CrosstermMockState { /// A version of the `TUI` that provides defaults for all trait methods. This can be used to create /// mocked versions of the `TUI` interface, without needing to define all methods provided by the /// interface. -#[allow(missing_docs, clippy::missing_errors_doc)] pub(crate) trait MockableTui: Tui { fn get_color_mode(&self) -> ColorMode { ColorMode::TwoTone diff --git a/src/test_helpers/shared/replace_invisibles.rs b/src/test_helpers/shared/replace_invisibles.rs index ad33cb3..0fd30c7 100644 --- a/src/test_helpers/shared/replace_invisibles.rs +++ b/src/test_helpers/shared/replace_invisibles.rs @@ -1,10 +1,3 @@ -use bitflags::bitflags; - -use crate::{ - display::DisplayColor, - view::{LineSegment, ViewData, ViewLine}, -}; - const VISIBLE_SPACE_REPLACEMENT: &str = "\u{b7}"; // "·" const VISIBLE_TAB_REPLACEMENT: &str = " \u{2192}"; // " →" diff --git a/src/test_helpers/testers/module.rs b/src/test_helpers/testers/module.rs index 453c5bb..609e4c7 100644 --- a/src/test_helpers/testers/module.rs +++ b/src/test_helpers/testers/module.rs @@ -27,12 +27,10 @@ impl ModuleTestContext { module.build_view_data(&self.render_context) } - #[allow(clippy::unused_self)] pub(crate) fn activate(&self, module: &'_ mut dyn Module, state: State) -> Results { module.activate(state) } - #[allow(clippy::unused_self)] pub(crate) fn deactivate(&mut self, module: &'_ mut dyn Module) -> Results { module.deactivate() } diff --git a/src/test_helpers/testers/threadable.rs b/src/test_helpers/testers/threadable.rs index 95d1ff3..8e8b404 100644 --- a/src/test_helpers/testers/threadable.rs +++ b/src/test_helpers/testers/threadable.rs @@ -47,7 +47,6 @@ impl Threadable { } /// Start a `Threadable` running the thread specified by the name, to completion in a separate thread. - #[allow(clippy::missing_panics_doc)] pub(crate) fn start_threadable( &self, theadable: &Threadable, diff --git a/src/test_helpers/with_temp_bare_repository.rs b/src/test_helpers/with_temp_bare_repository.rs index b84bc60..27ecf8a 100644 --- a/src/test_helpers/with_temp_bare_repository.rs +++ b/src/test_helpers/with_temp_bare_repository.rs @@ -8,7 +8,6 @@ use crate::{ /// # Panics /// /// If the repository cannot be created for any reason, this function will panic. -#[allow(clippy::panic)] pub(crate) fn with_temp_bare_repository(callback: F) where F: FnOnce(Repository) { with_temporary_path(|path| { diff --git a/src/test_helpers/with_view_state.rs b/src/test_helpers/with_view_state.rs index c1daf8e..78b4a40 100644 --- a/src/test_helpers/with_view_state.rs +++ b/src/test_helpers/with_view_state.rs @@ -2,7 +2,6 @@ use std::time::Duration; use crate::view::{RenderAction, State, ViewAction}; -#[allow(clippy::panic)] fn assert_view_state_actions(state: &State, expected_actions: &[String]) { let actions = state .render_slice() @@ -97,7 +96,6 @@ impl ViewStateTestContext { } /// Assert that certain messages were sent by the `State`. - #[allow(clippy::missing_panics_doc, clippy::panic)] pub(crate) fn assert_sent_messages(&self, messages: Vec<&str>) { let mut mismatch = false; let mut error_output = vec![ diff --git a/src/tests.rs b/src/tests.rs index 7c558fa..b054076 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,4 +1,4 @@ -use std::{ffi::OsString, path::Path}; +use std::path::Path; use super::*; use crate::{module::ExitStatus, test_helpers::set_git_directory}; -- cgit v1.2.3