From 3bb64b97c9ffddfa28139a39342b777a3c7aaf26 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Fri, 3 May 2024 11:49:08 +0200 Subject: [PATCH 1/5] fix clippy lints --- crates/core/src/archiver.rs | 4 ++-- crates/core/src/archiver/parent.rs | 2 +- crates/core/src/backend/ignore.rs | 2 +- crates/core/src/backend/local_destination.rs | 4 ++-- crates/core/src/blob/packer.rs | 2 +- crates/core/src/blob/tree.rs | 2 +- crates/core/src/commands/config.rs | 4 ++-- crates/core/src/commands/restore.rs | 2 +- crates/core/src/repofile/snapshotfile.rs | 6 ++---- crates/core/src/repository.rs | 2 +- crates/core/src/vfs.rs | 2 +- 11 files changed, 15 insertions(+), 17 deletions(-) diff --git a/crates/core/src/archiver.rs b/crates/core/src/archiver.rs index ac858763..b5e9e4f3 100644 --- a/crates/core/src/archiver.rs +++ b/crates/core/src/archiver.rs @@ -40,7 +40,7 @@ pub struct Archiver<'a, BE: DecryptFullBackend, I: ReadGlobalIndex> { /// The parent snapshot to use. parent: Parent, - /// The SharedIndexer is used to index the data. + /// The `SharedIndexer` is used to index the data. indexer: SharedIndexer, /// The backend to write to. @@ -49,7 +49,7 @@ pub struct Archiver<'a, BE: DecryptFullBackend, I: ReadGlobalIndex> { /// The backend to write to. index: &'a I, - /// The SnapshotFile to write to. + /// The `SnapshotFile` to write to. snap: SnapshotFile, } diff --git a/crates/core/src/archiver/parent.rs b/crates/core/src/archiver/parent.rs index 9f31dba6..d04287ae 100644 --- a/crates/core/src/archiver/parent.rs +++ b/crates/core/src/archiver/parent.rs @@ -279,7 +279,7 @@ impl Parent { let parent = match parent { ParentResult::Matched(p_node) => { if p_node.content.iter().flatten().all(|id| index.has_data(id)) { - node.content = p_node.content.clone(); + node.content.clone_from(&p_node.content); ParentResult::Matched(()) } else { warn!( diff --git a/crates/core/src/backend/ignore.rs b/crates/core/src/backend/ignore.rs index 163251cd..d4669b0a 100644 --- a/crates/core/src/backend/ignore.rs +++ b/crates/core/src/backend/ignore.rs @@ -329,7 +329,7 @@ impl Iterator for LocalSourceWalker { self.save_opts.with_atime, self.save_opts.ignore_devid, ) - .map_err(std::convert::Into::into) + .map_err(Into::into) }) } } diff --git a/crates/core/src/backend/local_destination.rs b/crates/core/src/backend/local_destination.rs index e0d18fcd..3bed86dc 100644 --- a/crates/core/src/backend/local_destination.rs +++ b/crates/core/src/backend/local_destination.rs @@ -330,7 +330,7 @@ impl LocalDestination { if let Some(mode) = node.meta.mode { let mode = map_mode_from_go(mode); - std::fs::set_permissions(filename, fs::Permissions::from_mode(mode)) + fs::set_permissions(filename, fs::Permissions::from_mode(mode)) .map_err(LocalDestinationErrorKind::SettingFilePermissionsFailed)?; } Ok(()) @@ -660,7 +660,7 @@ impl LocalDestination { /// [`LocalDestinationErrorKind::CouldNotWriteToBuffer`]: crate::error::LocalDestinationErrorKind::CouldNotWriteToBuffer pub fn write_at(&self, item: impl AsRef, offset: u64, data: &[u8]) -> RusticResult<()> { let filename = self.path(item); - let mut file = fs::OpenOptions::new() + let mut file = OpenOptions::new() .create(true) .truncate(false) .write(true) diff --git a/crates/core/src/blob/packer.rs b/crates/core/src/blob/packer.rs index d97e3afb..790ba536 100644 --- a/crates/core/src/blob/packer.rs +++ b/crates/core/src/blob/packer.rs @@ -160,7 +160,7 @@ impl PackSizer { #[allow(clippy::struct_field_names)] #[derive(Clone)] pub struct Packer { - /// The raw packer wrapped in an Arc and RwLock. + /// The raw packer wrapped in an `Arc` and `RwLock`. // This is a hack: raw_packer and indexer are only used in the add_raw() method. // TODO: Refactor as actor, like the other add() methods raw_packer: Arc>>, diff --git a/crates/core/src/blob/tree.rs b/crates/core/src/blob/tree.rs index bce973ce..768288fd 100644 --- a/crates/core/src/blob/tree.rs +++ b/crates/core/src/blob/tree.rs @@ -824,7 +824,7 @@ pub(crate) fn merge_trees( let mut tree_iters: Vec<_> = trees .iter() - .map(|id| Tree::from_backend(be, index, *id).map(std::iter::IntoIterator::into_iter)) + .map(|id| Tree::from_backend(be, index, *id).map(IntoIterator::into_iter)) .collect::>()?; // fill Heap with first elements from all trees diff --git a/crates/core/src/commands/config.rs b/crates/core/src/commands/config.rs index 9d50ad05..df99a0a0 100644 --- a/crates/core/src/commands/config.rs +++ b/crates/core/src/commands/config.rs @@ -125,7 +125,7 @@ pub struct ConfigOptions { pub set_treepack_size: Option, /// Set upper limit for default packsize for tree packs. - /// Note that packs actually can get up to some MiBs larger. + /// Note that packs actually can get a bit larger. /// If not set, pack sizes can grow up to approximately `4 GiB`. #[cfg_attr(feature = "clap", clap(long, value_name = "SIZE"))] pub set_treepack_size_limit: Option, @@ -151,7 +151,7 @@ pub struct ConfigOptions { pub set_datapack_growfactor: Option, /// Set upper limit for default packsize for tree packs. - /// Note that packs actually can get up to some MiBs larger. + /// Note that packs actually can get a bit larger. /// If not set, pack sizes can grow up to approximately `4 GiB`. #[cfg_attr(feature = "clap", clap(long, value_name = "SIZE"))] pub set_datapack_size_limit: Option, diff --git a/crates/core/src/commands/restore.rs b/crates/core/src/commands/restore.rs index d0d58be1..8bf9324f 100644 --- a/crates/core/src/commands/restore.rs +++ b/crates/core/src/commands/restore.rs @@ -595,7 +595,7 @@ impl BlobLocation { self.uncompressed_length .map_or( self.length - 32, // crypto overhead - std::num::NonZeroU32::get, + NonZeroU32::get, ) .into() } diff --git a/crates/core/src/repofile/snapshotfile.rs b/crates/core/src/repofile/snapshotfile.rs index 6299e898..c54aaac2 100644 --- a/crates/core/src/repofile/snapshotfile.rs +++ b/crates/core/src/repofile/snapshotfile.rs @@ -385,7 +385,7 @@ impl SnapshotFile { .collect::>() .join(" ") }, - std::clone::Clone::clone, + Clone::clone, ); let mut snap = Self { @@ -951,9 +951,7 @@ pub struct StringList(pub(crate) Vec); impl FromStr for StringList { type Err = RusticError; fn from_str(s: &str) -> RusticResult { - Ok(Self( - s.split(',').map(std::string::ToString::to_string).collect(), - )) + Ok(Self(s.split(',').map(ToString::to_string).collect())) } } diff --git a/crates/core/src/repository.rs b/crates/core/src/repository.rs index 55f7e91c..dbf71528 100644 --- a/crates/core/src/repository.rs +++ b/crates/core/src/repository.rs @@ -257,7 +257,7 @@ pub struct Repository { /// The name of the repository pub name: String, - /// The HotColdBackend to use for this repository + /// The `HotColdBackend` to use for this repository pub(crate) be: Arc, /// The Backend to use for hot files diff --git a/crates/core/src/vfs.rs b/crates/core/src/vfs.rs index f54e5715..9f670a20 100644 --- a/crates/core/src/vfs.rs +++ b/crates/core/src/vfs.rs @@ -146,7 +146,7 @@ impl VfsTree { return Ok(VfsPath::RusticPath(id, path)); } Self::VirtualTree(virtual_tree) => match components.next() { - Some(std::path::Component::Normal(name)) => { + Some(Component::Normal(name)) => { if let Some(new_tree) = virtual_tree.get(name) { tree = new_tree; } else { From c0865002400191d73bb2b581f1122c0a8148cca7 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Fri, 3 May 2024 12:34:08 +0200 Subject: [PATCH 2/5] ignore markdown lints for error messages --- crates/core/src/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/core/src/error.rs b/crates/core/src/error.rs index 5bb514fd..fb5607d2 100644 --- a/crates/core/src/error.rs +++ b/crates/core/src/error.rs @@ -1,5 +1,6 @@ //! Error types and Result module. +#![allow(clippy::doc_markdown)] // use std::error::Error as StdError; // use std::fmt; From 2b3adeb81a027a322dc0b4b7d83af7e29ae18392 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Fri, 3 May 2024 13:38:23 +0200 Subject: [PATCH 3/5] ignore markdown lints for error messages --- crates/backend/src/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/backend/src/error.rs b/crates/backend/src/error.rs index 01bcfded..ef89efe4 100644 --- a/crates/backend/src/error.rs +++ b/crates/backend/src/error.rs @@ -1,3 +1,4 @@ +#![allow(clippy::doc_markdown)] use std::{num::TryFromIntError, process::ExitStatus, str::Utf8Error}; use displaydoc::Display; From bc81029c4a9afab279be69ff2f760f689a378e80 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Fri, 3 May 2024 13:52:13 +0200 Subject: [PATCH 4/5] fix clippy lints for integration tests --- crates/core/tests/integration.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/core/tests/integration.rs b/crates/core/tests/integration.rs index 1383c8dd..d8d2639f 100644 --- a/crates/core/tests/integration.rs +++ b/crates/core/tests/integration.rs @@ -26,17 +26,19 @@ use anyhow::Result; use flate2::read::GzDecoder; use globset::Glob; -use insta::internals::{Content, ContentPath}; -use insta::{assert_ron_snapshot, Settings}; +use insta::{ + assert_ron_snapshot, + internals::{Content, ContentPath}, + Settings, +}; use pretty_assertions::assert_eq; -use rstest::fixture; -use rstest::rstest; +use rstest::{fixture, rstest}; use rustic_core::repofile::{Metadata, Node}; use rustic_core::{ - repofile::SnapshotFile, BackupOptions, ConfigOptions, KeyOptions, LsOptions, NoProgressBars, - OpenStatus, PathList, Repository, RepositoryBackends, RepositoryOptions, + repofile::SnapshotFile, BackupOptions, ConfigOptions, FindMatches, FindNode, KeyOptions, + LsOptions, NoProgressBars, OpenStatus, PathList, Repository, RepositoryBackends, + RepositoryOptions, RusticResult, }; -use rustic_core::{FindMatches, FindNode, RusticResult}; use serde::Serialize; use rustic_testing::backend::in_memory_backend::InMemoryBackend; @@ -93,7 +95,7 @@ fn handle_option(val: Content, _: ContentPath<'_>) -> String { #[fixture] fn insta_summary_redaction() -> Settings { - let mut settings = insta::Settings::clone_current(); + let mut settings = Settings::clone_current(); settings.add_redaction(".tree", "[tree_id]"); settings.add_dynamic_redaction(".program_version", |val, _| { @@ -128,7 +130,7 @@ fn insta_summary_redaction() -> Settings { #[fixture] fn insta_tree_redaction() -> Settings { - let mut settings = insta::Settings::clone_current(); + let mut settings = Settings::clone_current(); settings.add_redaction(".nodes[].inode", "[inode]"); settings.add_redaction(".nodes[].device_id", "[device_id]"); From 3f6ecdfda5ee8e001f60c2d5ec12399aae852d09 Mon Sep 17 00:00:00 2001 From: aawsome <37850842+aawsome@users.noreply.github.com> Date: Fri, 3 May 2024 14:11:35 +0200 Subject: [PATCH 5/5] Update crates/core/src/error.rs Co-authored-by: simonsan <14062932+simonsan@users.noreply.github.com> --- crates/core/src/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/core/src/error.rs b/crates/core/src/error.rs index fb5607d2..13ec6793 100644 --- a/crates/core/src/error.rs +++ b/crates/core/src/error.rs @@ -1,5 +1,6 @@ //! Error types and Result module. +// FIXME: Remove when 'displaydoc' has fixed/recommended further treatment upstream: https://github.com/yaahc/displaydoc/issues/48 #![allow(clippy::doc_markdown)] // use std::error::Error as StdError; // use std::fmt;