diff --git a/Cargo.toml b/Cargo.toml index 0e22e76fa4..cfbea9f300 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,9 +29,9 @@ discord_url = "https://discord.gg/m3YfbXpUUY" # Source :: https://github.com/obox-systems/conventions/blob/master/code_style.md#lints-and-warnings # Denies non-idiomatic code for Rust 2018 edition. -rust_2018_idioms = "deny" +rust_2018_idioms = { level = "deny", priority = -1 } # Denies using features that may break in future Rust versions. -future_incompatible = "deny" +future_incompatible = { level = "deny", priority = -1 } # Warns if public items lack documentation. missing_docs = "warn" # Warns for public types not implementing Debug. @@ -41,9 +41,9 @@ unsafe-code = "warn" [workspace.lints.clippy] # Denies restrictive lints, limiting certain language features/patterns. -restriction = "warn" +#restriction = { level = "deny", priority = -1 } # Denies pedantic lints, enforcing strict coding styles and conventions. -pedantic = "warn" +pedantic = { level = "warn", priority = -1 } # Denies undocumented unsafe blocks. undocumented_unsafe_blocks = "deny" # xxx : check diff --git a/module/core/clone_dyn_types/Readme.md b/module/core/clone_dyn_types/Readme.md index 12cc1e5f46..0a3caaae26 100644 --- a/module/core/clone_dyn_types/Readme.md +++ b/module/core/clone_dyn_types/Readme.md @@ -1,5 +1,5 @@ -# Module :: clone_dyn_types +# Module :: `clone_dyn_types` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml) [![docs.rs](https://img.shields.io/docsrs/clone_dyn_types?color=e3e8f0&logo=docs.rs)](https://docs.rs/clone_dyn_types) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fclone_dyn%2Fexamples%2Fclone_dyn_trivial.rs,RUN_POSTFIX=--example%20clone_dyn_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) diff --git a/module/core/clone_dyn_types/src/lib.rs b/module/core/clone_dyn_types/src/lib.rs index cc55badce4..2642542d03 100644 --- a/module/core/clone_dyn_types/src/lib.rs +++ b/module/core/clone_dyn_types/src/lib.rs @@ -39,6 +39,7 @@ mod private T : Clone, { #[ inline ] + #[ allow( clippy::implicit_return, clippy::as_conversions, clippy::ptr_as_ptr ) ] fn __clone_dyn( &self, _ : DontCallMe ) -> *mut () { Box::< T >::into_raw( Box::new( self.clone() ) ) as *mut () @@ -51,6 +52,7 @@ mod private T : Clone, { #[ inline ] + #[ allow( clippy::implicit_return, clippy::as_conversions, clippy::ptr_as_ptr ) ] fn __clone_dyn( &self, _ : DontCallMe ) -> *mut () { Box::< [ T ] >::into_raw( self.iter().cloned().collect() ) as *mut () @@ -61,6 +63,7 @@ mod private impl CloneDyn for str { #[ inline ] + #[ allow( clippy::as_conversions, clippy::ptr_as_ptr, clippy::implicit_return ) ] fn __clone_dyn( &self, _ : DontCallMe ) -> *mut () { Box::< str >::into_raw( Box::from( self ) ) as *mut () @@ -68,7 +71,7 @@ mod private } /// - /// True clone which is applicable not only to clonable entities, but to trait objects implementing CloneDyn. + /// True clone which is applicable not only to clonable entities, but to trait objects implementing `CloneDyn`. /// /// # Example /// @@ -100,7 +103,7 @@ mod private // that the `CloneDyn` trait is correctly implemented for the given type `T`, ensuring that `__clone_dyn` returns a // valid pointer to a cloned instance of `T`. // - #[ allow( unsafe_code ) ] + #[ allow( unsafe_code, clippy::as_conversions, clippy::ptr_as_ptr, clippy::implicit_return, clippy::undocumented_unsafe_blocks ) ] unsafe { *Box::from_raw( < T as CloneDyn >::__clone_dyn( src, DontCallMe ) as *mut T ) @@ -185,7 +188,7 @@ mod private // The safety of this function relies on the correct implementation of the `CloneDyn` trait for the given type `T`. // Specifically, `__clone_dyn` must return a valid pointer to a cloned instance of `T`. // - #[ allow( unsafe_code ) ] + #[ allow( unsafe_code, clippy::implicit_return, clippy::as_conversions, clippy::ptr_cast_constness, clippy::ptr_as_ptr, clippy::multiple_unsafe_ops_per_block, clippy::undocumented_unsafe_blocks, clippy::ref_as_ptr ) ] unsafe { let mut ptr = ref_dyn as *const T; @@ -207,13 +210,14 @@ mod private impl< T : Clone > Sealed for [ T ] {} impl Sealed for str {} } - use sealed::*; + use sealed::{ DontCallMe, Sealed }; } #[ cfg( feature = "enabled" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. @@ -221,8 +225,9 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { - use super::*; + use super::orphan; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use orphan::*; } @@ -231,8 +236,9 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { - use super::*; + use super::exposed; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; } @@ -241,8 +247,9 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { - use super::*; + use super::prelude; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; } @@ -251,8 +258,9 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + use super::private; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private:: { CloneDyn, diff --git a/module/core/collection_tools/Readme.md b/module/core/collection_tools/Readme.md index 2b6f2b0ab6..b247a692b0 100644 --- a/module/core/collection_tools/Readme.md +++ b/module/core/collection_tools/Readme.md @@ -1,6 +1,6 @@ -# Module :: collection_tools +# Module :: `collection_tools` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/collection_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/collection_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fcollection_tools%2Fexamples%2Fcollection_tools_trivial.rs,RUN_POSTFIX=--example%20collection_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) diff --git a/module/core/collection_tools/src/collection/binary_heap.rs b/module/core/collection_tools/src/collection/binary_heap.rs index 965f5804c5..faaa934427 100644 --- a/module/core/collection_tools/src/collection/binary_heap.rs +++ b/module/core/collection_tools/src/collection/binary_heap.rs @@ -1,8 +1,9 @@ -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use alloc::collections::binary_heap::*; /// Creates a `BinaryHeap` from a list of elements. @@ -32,8 +33,8 @@ pub use alloc::collections::binary_heap::*; /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `BinaryHeap`. -/// Each element can be of any type that implements the `Into` trait, where `T` is the -/// type stored in the `BinaryHeap`. +/// Each element can be of any type that implements the `Into` trait, where `T` is the +/// type stored in the `BinaryHeap`. /// /// # Returns /// @@ -101,8 +102,8 @@ macro_rules! heap /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `BinaryHeap`. -/// Each element can be of any type that implements the `Into` trait, where `T` is the -/// type stored in the `BinaryHeap`. +/// Each element can be of any type that implements the `Into` trait, where `T` is the +/// type stored in the `BinaryHeap`. /// /// # Returns /// diff --git a/module/core/collection_tools/src/collection/btree_map.rs b/module/core/collection_tools/src/collection/btree_map.rs index 2e4ec94f13..fc79de564b 100644 --- a/module/core/collection_tools/src/collection/btree_map.rs +++ b/module/core/collection_tools/src/collection/btree_map.rs @@ -1,8 +1,9 @@ -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use alloc::collections::btree_map::*; /// Creates a `BTreeMap` from a list of key-value pairs. @@ -32,8 +33,8 @@ pub use alloc::collections::btree_map::*; /// # Parameters /// /// - `$( $key:expr => $value:expr ),* $( , )?`: A comma-separated list of key-value pairs to insert into the `BTreeMap`. -/// Each key and value can be of any type that implements the `Into< K >` and `Into< V >` traits, where `K` and `V` are the -/// types stored in the `BTreeMap` as keys and values, respectively. +/// Each key and value can be of any type that implements the `Into< K >` and `Into< V >` traits, where `K` and `V` are the +/// types stored in the `BTreeMap` as keys and values, respectively. /// /// # Returns /// @@ -114,8 +115,8 @@ macro_rules! bmap /// # Parameters /// /// - `$( $key:expr => $value:expr ),* $( , )?`: A comma-separated list of key-value pairs to insert into the `BTreeMap`. -/// Each key and value can be of any type that implements the `Into< K >` and `Into< V >` traits, where `K` and `V` are the -/// types stored in the `BTreeMap` as keys and values, respectively. +/// Each key and value can be of any type that implements the `Into< K >` and `Into< V >` traits, where `K` and `V` are the +/// types stored in the `BTreeMap` as keys and values, respectively. /// /// # Returns /// diff --git a/module/core/collection_tools/src/collection/btree_set.rs b/module/core/collection_tools/src/collection/btree_set.rs index 7111811c2e..d7b22ababc 100644 --- a/module/core/collection_tools/src/collection/btree_set.rs +++ b/module/core/collection_tools/src/collection/btree_set.rs @@ -1,8 +1,9 @@ -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use alloc::collections::btree_set::*; /// Creates a `BTreeSet` from a list of elements. @@ -29,8 +30,8 @@ pub use alloc::collections::btree_set::*; /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `BTreeSet`. -/// Each element can be of any type that implements the `Into` trait, where `T` is the -/// type stored in the `BTreeSet`. +/// Each element can be of any type that implements the `Into` trait, where `T` is the +/// type stored in the `BTreeSet`. /// /// # Returns /// @@ -100,8 +101,8 @@ macro_rules! bset /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `BTreeSet`. -/// Each element can be of any type that implements the `Into` trait, where `T` is the -/// type stored in the `BTreeSet`. +/// Each element can be of any type that implements the `Into` trait, where `T` is the +/// type stored in the `BTreeSet`. /// /// # Returns /// diff --git a/module/core/collection_tools/src/collection/hash_map.rs b/module/core/collection_tools/src/collection/hash_map.rs index 8ebbc9f90f..2b2a8226a6 100644 --- a/module/core/collection_tools/src/collection/hash_map.rs +++ b/module/core/collection_tools/src/collection/hash_map.rs @@ -10,6 +10,7 @@ pub use crate::dependency::hashbrown::hash_map::*; #[ cfg( not( feature = "no_std" ) ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use std::collections::hash_map::*; /// Creates a `HashMap` from a list of key-value pairs. @@ -41,8 +42,8 @@ pub use std::collections::hash_map::*; /// # Parameters /// /// - `$( $key:expr => $value:expr ),* $( , )?`: A comma-separated list of key-value pairs to insert into the `HashMap`. -/// Each key and value can be of any type that implements the `Into` and `Into` traits, where `K` and `V` are the -/// types stored in the `HashMap` as keys and values, respectively. +/// Each key and value can be of any type that implements the `Into` and `Into` traits, where `K` and `V` are the +/// types stored in the `HashMap` as keys and values, respectively. /// /// # Returns /// @@ -125,8 +126,8 @@ macro_rules! hmap /// # Parameters /// /// - `$( $key:expr => $value:expr ),* $( , )?`: A comma-separated list of key-value pairs to insert into the `HashMap`. -/// Each key and value can be of any type that implements the `Into` and `Into` traits, where `K` and `V` are the -/// types stored in the `HashMap` as keys and values, respectively. +/// Each key and value can be of any type that implements the `Into` and `Into` traits, where `K` and `V` are the +/// types stored in the `HashMap` as keys and values, respectively. /// /// # Returns /// diff --git a/module/core/collection_tools/src/collection/hash_set.rs b/module/core/collection_tools/src/collection/hash_set.rs index 6fe8d8287a..f2a73c5faf 100644 --- a/module/core/collection_tools/src/collection/hash_set.rs +++ b/module/core/collection_tools/src/collection/hash_set.rs @@ -9,6 +9,7 @@ pub use crate::dependency::hashbrown::hash_set::*; #[ cfg( not( feature = "no_std" ) ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use std::collections::hash_set::*; /// Creates a `HashSet` from a list of elements. @@ -40,8 +41,8 @@ pub use std::collections::hash_set::*; /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `HashSet`. -/// Each element can be of any type that implements the `Into< T >` trait, where `T` is the -/// type stored in the `HashSet`. +/// Each element can be of any type that implements the `Into< T >` trait, where `T` is the +/// type stored in the `HashSet`. /// /// # Returns /// @@ -124,8 +125,8 @@ macro_rules! hset /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `HashSet`. -/// Each element can be of any type that implements the `Into< T >` trait, where `T` is the -/// type stored in the `HashSet`. +/// Each element can be of any type that implements the `Into< T >` trait, where `T` is the +/// type stored in the `HashSet`. /// /// # Returns /// diff --git a/module/core/collection_tools/src/collection/linked_list.rs b/module/core/collection_tools/src/collection/linked_list.rs index cc23637be1..7fbaba79fa 100644 --- a/module/core/collection_tools/src/collection/linked_list.rs +++ b/module/core/collection_tools/src/collection/linked_list.rs @@ -1,8 +1,9 @@ -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use alloc::collections::linked_list::*; /// Creates a `LinkedList` from a llist of elements. @@ -32,8 +33,8 @@ pub use alloc::collections::linked_list::*; /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated llist of elements to insert into the `LinkedList`. -/// Each element can be of any type that implements the `Into` trait, where `T` is the -/// type stored in the `LinkedList`. +/// Each element can be of any type that implements the `Into` trait, where `T` is the +/// type stored in the `LinkedList`. /// /// # Returns /// @@ -114,8 +115,8 @@ macro_rules! llist /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated llist of elements to insert into the `LinkedList`. -/// Each element can be of any type that implements the `Into` trait, where `T` is the -/// type stored in the `LinkedList`. +/// Each element can be of any type that implements the `Into` trait, where `T` is the +/// type stored in the `LinkedList`. /// /// # Returns /// diff --git a/module/core/collection_tools/src/collection/mod.rs b/module/core/collection_tools/src/collection/mod.rs index 0f74158835..22e59e8aae 100644 --- a/module/core/collection_tools/src/collection/mod.rs +++ b/module/core/collection_tools/src/collection/mod.rs @@ -18,26 +18,27 @@ macro_rules! count #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] extern crate alloc; -/// [std::collections::BTreeMap] macros +/// [`std::collections::BTreeMap`] macros pub mod btree_map; -/// [std::collections::BTreeSet] macros +/// [`std::collections::BTreeSet`] macros pub mod btree_set; -/// [std::collections::BinaryHeap] macros +/// [`std::collections::BinaryHeap`] macros pub mod binary_heap; -/// [std::collections::HashMap] macros +/// [`std::collections::HashMap`] macros pub mod hash_map; -/// [std::collections::HashSet] macros +/// [`std::collections::HashSet`] macros pub mod hash_set; -/// [std::collections::LinkedList] macros +/// [`std::collections::LinkedList`] macros pub mod linked_list; /// [Vec] macros pub mod vector; -/// [std::collections::VecDeque] macros +/// [`std::collections::VecDeque`] macros pub mod vec_deque; #[ doc( inline ) ] #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. @@ -45,8 +46,10 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super:: { btree_map, @@ -60,6 +63,7 @@ pub mod own }; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use orphan::*; } @@ -69,8 +73,10 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; } @@ -79,17 +85,21 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::super::collection; #[ doc( inline ) ] #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] #[ cfg( feature = "collection_constructors" ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use crate:: { vec as dlist, @@ -104,6 +114,7 @@ pub mod exposed #[ doc( inline ) ] #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] #[ cfg( feature = "collection_into_constructors" ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use crate:: { into_vec, @@ -119,6 +130,7 @@ pub mod exposed // #[ cfg( feature = "reexports" ) ] #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use { btree_map::BTreeMap, @@ -134,6 +146,7 @@ pub mod exposed // #[ cfg( feature = "reexports" ) ] #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use { LinkedList as Llist, diff --git a/module/core/collection_tools/src/collection/vec_deque.rs b/module/core/collection_tools/src/collection/vec_deque.rs index 1060d01c0b..218f64e7ed 100644 --- a/module/core/collection_tools/src/collection/vec_deque.rs +++ b/module/core/collection_tools/src/collection/vec_deque.rs @@ -1,8 +1,9 @@ -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use alloc::collections::vec_deque::*; /// Creates a `VecDeque` from a list of elements. @@ -38,8 +39,8 @@ pub use alloc::collections::vec_deque::*; /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `VecDeque`. -/// Each element can be of any type that implements the `Into< T >` trait, where `T` is the -/// type stored in the `VecDeque`. +/// Each element can be of any type that implements the `Into< T >` trait, where `T` is the +/// type stored in the `VecDeque`. /// /// # Returns /// @@ -119,8 +120,8 @@ macro_rules! deque /// # Parameters /// /// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `VecDeque`. -/// Each element can be of any type that implements the `Into< T >` trait, where `T` is the -/// type stored in the `VecDeque`. +/// Each element can be of any type that implements the `Into< T >` trait, where `T` is the +/// type stored in the `VecDeque`. /// /// # Returns /// diff --git a/module/core/collection_tools/src/collection/vector.rs b/module/core/collection_tools/src/collection/vector.rs index 0ae9ccf6dd..568642d0c4 100644 --- a/module/core/collection_tools/src/collection/vector.rs +++ b/module/core/collection_tools/src/collection/vector.rs @@ -1,12 +1,14 @@ -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use alloc::vec::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use core::slice::{ Iter, IterMut }; /// Creates a `Vec` from a list of elements. @@ -36,8 +38,8 @@ pub use core::slice::{ Iter, IterMut }; /// # Parameters /// /// - `$( $key : expr ),* $( , )?`: A comma-separated list of elements to insert into the `Vec`. -/// Each element can be of any type that implements the `Into` trait, where `T` is the -/// type stored in the `Vec`. +/// Each element can be of any type that implements the `Into` trait, where `T` is the +/// type stored in the `Vec`. /// /// # Returns /// @@ -118,8 +120,8 @@ macro_rules! vec /// # Parameters /// /// - `$( $key : expr ),* $( , )?`: A comma-separated list of elements to insert into the `Vec`. -/// Each element can be of any type that implements the `Into` trait, where `T` is the -/// type stored in the `Vec`. +/// Each element can be of any type that implements the `Into` trait, where `T` is the +/// type stored in the `Vec`. /// /// # Returns /// diff --git a/module/core/collection_tools/src/lib.rs b/module/core/collection_tools/src/lib.rs index bcbbb4bdbc..18b8e84037 100644 --- a/module/core/collection_tools/src/lib.rs +++ b/module/core/collection_tools/src/lib.rs @@ -3,7 +3,7 @@ #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/collection_tools/latest/collection_tools/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] - +#![ allow( clippy::mod_module_files ) ] // #[ cfg( feature = "enabled" ) ] // #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] // extern crate alloc; @@ -30,6 +30,7 @@ pub mod dependency #[ doc( inline ) ] #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. @@ -40,9 +41,11 @@ pub mod own // use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::orphan::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::collection::own::*; } @@ -52,11 +55,14 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use collection::orphan::*; } @@ -66,24 +72,29 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use collection::exposed::*; } /// Prelude to use essentials: `use my_module::prelude::*`. #[ cfg( feature = "enabled" ) ] +#[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + use super::collection; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use collection::prelude::*; } diff --git a/module/core/data_type/Readme.md b/module/core/data_type/Readme.md index 62c1031498..ddadd7fb57 100644 --- a/module/core/data_type/Readme.md +++ b/module/core/data_type/Readme.md @@ -1,6 +1,6 @@ -# Module :: data_type +# Module :: `data_type` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_data_type_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_data_type_push.yml) [![docs.rs](https://img.shields.io/docsrs/data_type?color=e3e8f0&logo=docs.rs)](https://docs.rs/data_type) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fdata_type%2Fexamples%2Fdata_type_trivial.rs,RUN_POSTFIX=--example%20data_type_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) @@ -30,7 +30,7 @@ Macro [types](https://docs.rs/type_constructor/latest/type_constructor/types/mac ### Basic Use Case :: make - variadic constructor -Implement traits [From_0], [From1] up to MakeN to provide the interface to construct your structure with a different set of arguments. +Implement traits [`From_0`], [From1] up to `MakeN` to provide the interface to construct your structure with a different set of arguments. In this example structure, Struct1 could be constructed either without arguments, with a single argument, or with two arguments. - Constructor without arguments fills fields with zero. - Constructor with a single argument sets both fields to the value of the argument. diff --git a/module/core/data_type/src/dt.rs b/module/core/data_type/src/dt.rs index f384f56072..91b3babd3d 100644 --- a/module/core/data_type/src/dt.rs +++ b/module/core/data_type/src/dt.rs @@ -11,6 +11,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -20,6 +21,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -29,6 +31,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] diff --git a/module/core/data_type/src/lib.rs b/module/core/data_type/src/lib.rs index 7cdff4fae2..b645eb9a71 100644 --- a/module/core/data_type/src/lib.rs +++ b/module/core/data_type/src/lib.rs @@ -33,6 +33,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -45,6 +46,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -54,6 +56,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] diff --git a/module/core/derive_tools/Readme.md b/module/core/derive_tools/Readme.md index 746b6e4ec7..f5e6fddf2e 100644 --- a/module/core/derive_tools/Readme.md +++ b/module/core/derive_tools/Readme.md @@ -1,4 +1,4 @@ -# Module :: derive_tools +# Module :: `derive_tools` diff --git a/module/core/derive_tools/src/lib.rs b/module/core/derive_tools/src/lib.rs index 62468ed1dc..fe3c51ebbf 100644 --- a/module/core/derive_tools/src/lib.rs +++ b/module/core/derive_tools/src/lib.rs @@ -31,7 +31,7 @@ // #[ cfg( feature = "enabled" ) ] // pub mod wtools; -#[ cfg( all( feature = "derive_more" ) ) ] +#[ cfg( feature = "derive_more" ) ] #[ allow( unused_imports ) ] mod derive_more { @@ -110,6 +110,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -123,6 +124,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -133,11 +135,12 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use prelude::*; - #[ cfg( all( feature = "derive_more" ) ) ] + #[ cfg( feature = "derive_more" ) ] #[ doc( inline ) ] pub use super::derive_more::*; diff --git a/module/core/derive_tools_meta/Readme.md b/module/core/derive_tools_meta/Readme.md index 53f7fba9f0..91790856f2 100644 --- a/module/core/derive_tools_meta/Readme.md +++ b/module/core/derive_tools_meta/Readme.md @@ -1,5 +1,5 @@ -# Module :: derive_tools_meta +# Module :: `derive_tools_meta` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_meta_push.yml) [![docs.rs](https://img.shields.io/docsrs/derive_tools_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/derive_tools_meta) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) diff --git a/module/core/derive_tools_meta/src/derive/as_ref.rs b/module/core/derive_tools_meta/src/derive/as_ref.rs index dba4eacacf..7a02d29b9b 100644 --- a/module/core/derive_tools_meta/src/derive/as_ref.rs +++ b/module/core/derive_tools_meta/src/derive/as_ref.rs @@ -1,4 +1,5 @@ +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools::{ attr, diag, item_struct, Result }; diff --git a/module/core/derive_tools_meta/src/derive/deref.rs b/module/core/derive_tools_meta/src/derive/deref.rs index ac2217c1c8..ad5489bd03 100644 --- a/module/core/derive_tools_meta/src/derive/deref.rs +++ b/module/core/derive_tools_meta/src/derive/deref.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools::{ attr, diag, generic_params, Result, struct_like::StructLike }; @@ -11,7 +12,7 @@ pub fn deref( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStr let item_name = &parsed.ident(); let ( _generics_with_defaults, generics_impl, generics_ty, generics_where ) - = generic_params::decompose( &parsed.generics() ); + = generic_params::decompose( parsed.generics() ); let result = match parsed { @@ -84,6 +85,7 @@ pub fn deref( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStr /// } /// ``` /// +#[ allow( clippy::unnecessary_wraps ) ] fn generate_unit ( item_name : &syn::Ident, @@ -322,9 +324,9 @@ fn generate_enum None => return generate_unit ( item_name, - &generics_impl, - &generics_ty, - &generics_where, + generics_impl, + generics_ty, + generics_where, ), }; @@ -343,18 +345,18 @@ fn generate_enum generate_unit ( item_name, - &generics_impl, - &generics_ty, - &generics_where, + generics_impl, + generics_ty, + generics_where, ), syn::Fields::Unnamed( ref item ) => generate_enum_tuple_variants ( item_name, - &generics_impl, - &generics_ty, - &generics_where, + generics_impl, + generics_ty, + generics_where, &idents, item, ), @@ -363,9 +365,9 @@ fn generate_enum generate_enum_named_variants ( item_name, - &generics_impl, - &generics_ty, - &generics_where, + generics_impl, + generics_ty, + generics_where, &idents, item, ), diff --git a/module/core/derive_tools_meta/src/derive/from.rs b/module/core/derive_tools_meta/src/derive/from.rs index 585df90183..59a7462435 100644 --- a/module/core/derive_tools_meta/src/derive/from.rs +++ b/module/core/derive_tools_meta/src/derive/from.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools:: { @@ -10,8 +11,10 @@ use macro_tools:: }; mod field_attributes; +#[ allow( clippy::wildcard_imports ) ] use field_attributes::*; mod item_attributes; +#[ allow( clippy::wildcard_imports ) ] use item_attributes::*; // @@ -27,15 +30,15 @@ pub fn from( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStre let item_name = &parsed.ident(); let ( _generics_with_defaults, generics_impl, generics_ty, generics_where ) - = generic_params::decompose( &parsed.generics() ); + = generic_params::decompose( parsed.generics() ); let result = match parsed { StructLike::Unit( ref item ) | StructLike::Struct( ref item ) => { - let mut field_types = item_struct::field_types( &item ); - let field_names = item_struct::field_names( &item ); + let mut field_types = item_struct::field_types( item ); + let field_names = item_struct::field_names( item ); match ( field_types.len(), field_names ) { @@ -55,7 +58,7 @@ pub fn from( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStre &generics_ty, &generics_where, field_names.next().unwrap(), - &field_types.next().unwrap(), + field_types.next().unwrap(), ), ( 1, None ) => generate_single_field @@ -64,7 +67,7 @@ pub fn from( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStre &generics_impl, &generics_ty, &generics_where, - &field_types.next().unwrap(), + field_types.next().unwrap(), ), ( _, Some( field_names ) ) => generate_multiple_fields_named @@ -252,7 +255,7 @@ fn generate_single_field_named } // qqq : document, add example of generated code -- done -/// Generates `From`` implementation for structs with a single named field +/// Generates `From` implementation for structs with a single named field /// /// # Example of generated code /// @@ -441,6 +444,7 @@ fn generate_multiple_fields< 'a > } // qqq : document, add example of generated code +#[ allow ( clippy::format_in_format_args ) ] fn variant_generate ( item_name : &syn::Ident, @@ -462,7 +466,7 @@ fn variant_generate return Ok( qt!{} ) } - if fields.len() <= 0 + if fields.is_empty() { return Ok( qt!{} ) } diff --git a/module/core/derive_tools_meta/src/derive/from/field_attributes.rs b/module/core/derive_tools_meta/src/derive/from/field_attributes.rs index 5aeb72bd56..53d1c60393 100644 --- a/module/core/derive_tools_meta/src/derive/from/field_attributes.rs +++ b/module/core/derive_tools_meta/src/derive/from/field_attributes.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools:: { @@ -25,6 +26,7 @@ pub struct FieldAttributes impl FieldAttributes { + #[ allow( clippy::single_match ) ] pub fn from_attrs< 'a >( attrs : impl Iterator< Item = &'a syn::Attribute > ) -> Result< Self > { let mut result = Self::default(); @@ -50,7 +52,7 @@ impl FieldAttributes { let key_ident = attr.path().get_ident().ok_or_else( || error( attr ) )?; - let key_str = format!( "{}", key_ident ); + let key_str = format!( "{key_ident}" ); // attributes does not have to be known // if attr::is_standard( &key_str ) @@ -61,7 +63,7 @@ impl FieldAttributes match key_str.as_ref() { FieldAttributeConfig::KEYWORD => result.assign( FieldAttributeConfig::from_meta( attr )? ), - "debug" => {}, + // "debug" => {}, _ => {}, // _ => return Err( error( attr ) ), } @@ -95,17 +97,18 @@ impl AttributeComponent for FieldAttributeConfig { const KEYWORD : &'static str = "from"; + #[ allow( clippy::match_wildcard_for_single_variants ) ] fn from_meta( attr : &syn::Attribute ) -> Result< Self > { match attr.meta { syn::Meta::List( ref meta_list ) => { - return syn::parse2::< FieldAttributeConfig >( meta_list.tokens.clone() ); + syn::parse2::< FieldAttributeConfig >( meta_list.tokens.clone() ) }, syn::Meta::Path( ref _path ) => { - return Ok( Default::default() ) + Ok( FieldAttributeConfig::default() ) }, _ => return_syn_err!( attr, "Expects an attribute of format `#[ from( on ) ]`. \nGot: {}", qt!{ #attr } ), } diff --git a/module/core/derive_tools_meta/src/derive/from/item_attributes.rs b/module/core/derive_tools_meta/src/derive/from/item_attributes.rs index f60b4fbbe4..4c81f3bcf1 100644 --- a/module/core/derive_tools_meta/src/derive/from/item_attributes.rs +++ b/module/core/derive_tools_meta/src/derive/from/item_attributes.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools:: { @@ -23,6 +24,7 @@ pub struct ItemAttributes impl ItemAttributes { + #[ allow( clippy::single_match ) ] pub fn from_attrs< 'a >( attrs : impl Iterator< Item = &'a syn::Attribute > ) -> Result< Self > { let mut result = Self::default(); @@ -48,7 +50,7 @@ impl ItemAttributes { let key_ident = attr.path().get_ident().ok_or_else( || error( attr ) )?; - let key_str = format!( "{}", key_ident ); + let key_str = format!( "{key_ident}" ); // attributes does not have to be known // if attr::is_standard( &key_str ) @@ -59,7 +61,7 @@ impl ItemAttributes match key_str.as_ref() { ItemAttributeConfig::KEYWORD => result.assign( ItemAttributeConfig::from_meta( attr )? ), - "debug" => {} + // "debug" => {} _ => {}, // _ => return Err( error( attr ) ), // attributes does not have to be known @@ -92,17 +94,18 @@ impl AttributeComponent for ItemAttributeConfig { const KEYWORD : &'static str = "from"; + #[ allow( clippy::match_wildcard_for_single_variants ) ] fn from_meta( attr : &syn::Attribute ) -> Result< Self > { match attr.meta { syn::Meta::List( ref meta_list ) => { - return syn::parse2::< ItemAttributeConfig >( meta_list.tokens.clone() ); + syn::parse2::< ItemAttributeConfig >( meta_list.tokens.clone() ) }, syn::Meta::Path( ref _path ) => { - return Ok( Default::default() ) + Ok( ItemAttributeConfig::default() ) }, _ => return_syn_err!( attr, "Expects an attribute of format `#[ from( on ) ]`. \nGot: {}", qt!{ #attr } ), } diff --git a/module/core/derive_tools_meta/src/lib.rs b/module/core/derive_tools_meta/src/lib.rs index 2b323bbdc0..310fb2bf09 100644 --- a/module/core/derive_tools_meta/src/lib.rs +++ b/module/core/derive_tools_meta/src/lib.rs @@ -345,7 +345,7 @@ pub fn deref_mut( input : proc_macro::TokenStream ) -> proc_macro::TokenStream } /// -/// Derive macro to implement AsRef when-ever it's possible to do automatically. +/// Derive macro to implement `AsRef` when-ever it's possible to do automatically. /// /// ### Sample :: struct instead of macro. /// diff --git a/module/core/error_tools/Readme.md b/module/core/error_tools/Readme.md index 727ed9d8b7..f5e679a074 100644 --- a/module/core/error_tools/Readme.md +++ b/module/core/error_tools/Readme.md @@ -1,6 +1,6 @@ -# Module :: error_tools +# Module :: `error_tools` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/error_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/error_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Ferror_tools%2Fexamples%2Ferror_tools_trivial.rs,RUN_POSTFIX=--example%20error_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) diff --git a/module/core/error_tools/src/error/assert.rs b/module/core/error_tools/src/error/assert.rs index 52f45d29bf..18ba821186 100644 --- a/module/core/error_tools/src/error/assert.rs +++ b/module/core/error_tools/src/error/assert.rs @@ -2,7 +2,7 @@ mod private { /// - /// Macro asserts that two expressions are identical to each other. Unlike std::assert_eq it is removed from a release build. + /// Macro asserts that two expressions are identical to each other. Unlike `std::assert_eq` it is removed from a release build. /// #[ macro_export ] @@ -58,7 +58,7 @@ mod private // }}; } - /// Macro asserts that two expressions are identical to each other. Unlike std::assert_eq it is removed from a release build. Alias of debug_assert_id. + /// Macro asserts that two expressions are identical to each other. Unlike `std::assert_eq` it is removed from a release build. Alias of `debug_assert_id`. #[ macro_export ] macro_rules! debug_assert_identical @@ -70,7 +70,7 @@ mod private }; } - /// Macro asserts that two expressions are not identical to each other. Unlike std::assert_eq it is removed from a release build. + /// Macro asserts that two expressions are not identical to each other. Unlike `std::assert_eq` it is removed from a release build. #[ macro_export ] macro_rules! debug_assert_ni @@ -83,7 +83,7 @@ mod private }; } - /// Macro asserts that two expressions are not identical to each other. Unlike std::assert_eq it is removed from a release build. + /// Macro asserts that two expressions are not identical to each other. Unlike `std::assert_eq` it is removed from a release build. #[ macro_export ] macro_rules! debug_assert_not_identical @@ -108,9 +108,13 @@ mod private // }; // } + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use debug_assert_id; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use debug_assert_identical; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use debug_assert_ni; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use debug_assert_not_identical; } @@ -118,21 +122,26 @@ mod private #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use orphan::*; } #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Shared with parent namespace of the module #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; } @@ -140,8 +149,10 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; } @@ -149,9 +160,14 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private::debug_assert_id; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private::debug_assert_identical; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private::debug_assert_ni; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private::debug_assert_not_identical; } diff --git a/module/core/error_tools/src/error/mod.rs b/module/core/error_tools/src/error/mod.rs index 4d9c79ddaa..0de7d2fafd 100644 --- a/module/core/error_tools/src/error/mod.rs +++ b/module/core/error_tools/src/error/mod.rs @@ -1,6 +1,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use std::error::Error as ErrorTrait; /// This trait allows adding extra context or information to an error, creating a tuple of the additional @@ -26,6 +27,10 @@ mod private /// /// A `Result` of type `ReportOk` if the original result is `Ok`, or a tuple `(ReportErr, E)` containing the additional /// context and the original error if the original result is `Err`. + /// + /// # Errors + /// + /// qqq: errors /// /// # Example /// @@ -34,7 +39,7 @@ mod private /// let result : Result< (), std::io::Error > = Err( std::io::Error::new( std::io::ErrorKind::Other, "an error occurred" ) ); /// let result_with_context : Result< (), ( &str, std::io::Error ) > = result.err_with( || "additional context" ); /// ``` - fn err_with< F >( self, f : F ) -> std::result::Result< ReportOk, ( ReportErr, E ) > + fn err_with< F >( self, f : F ) -> core::result::Result< ReportOk, ( ReportErr, E ) > where F : FnOnce() -> ReportErr; @@ -51,6 +56,10 @@ mod private /// /// A `Result` of type `ReportOk` if the original result is `Ok`, or a tuple `(ReportErr, E)` containing the additional /// context and the original error if the original result is `Err`. + /// + /// # Errors + /// + /// qqq: Errors /// /// # Example /// @@ -60,32 +69,35 @@ mod private /// let report = "additional context"; /// let result_with_report : Result< (), ( &str, std::io::Error ) > = result.err_with_report( &report ); /// ``` - fn err_with_report( self, report : &ReportErr ) -> std::result::Result< ReportOk, ( ReportErr, E ) > + fn err_with_report( self, report : &ReportErr ) -> core::result::Result< ReportOk, ( ReportErr, E ) > where ReportErr : Clone; } impl< ReportErr, ReportOk, E, IntoError > ErrWith< ReportErr, ReportOk, E > - for std::result::Result< ReportOk, IntoError > + for core::result::Result< ReportOk, IntoError > where IntoError : Into< E >, { - fn err_with< F >( self, f : F ) -> std::result::Result< ReportOk, ( ReportErr, E ) > + #[ allow( clippy::implicit_return, clippy::min_ident_chars ) ] + #[ inline ] + fn err_with< F >( self, f : F ) -> core::result::Result< ReportOk, ( ReportErr, E ) > where F : FnOnce() -> ReportErr, { - self.map_err( | e | ( f(), e.into() ) ) + self.map_err( | error | ( f(), error.into() ) ) } #[ inline( always ) ] - fn err_with_report( self, report : &ReportErr ) -> std::result::Result< ReportOk, ( ReportErr, E ) > + #[ allow( clippy::implicit_return ) ] + fn err_with_report( self, report : &ReportErr ) -> core::result::Result< ReportOk, ( ReportErr, E ) > where ReportErr : Clone, Self : Sized, { - self.map_err( | e | ( report.clone(), e.into() ) ) + self.map_err( | error | ( report.clone(), error.into() ) ) } } @@ -226,6 +238,7 @@ pub mod untyped; #[ cfg( feature = "enabled" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. @@ -233,23 +246,29 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use orphan::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use assert::orphan::*; #[ cfg( feature = "error_untyped" ) ] #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use untyped::orphan::*; #[ cfg( feature = "error_typed" ) ] #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use typed::orphan::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private:: { // err, @@ -258,10 +277,13 @@ pub mod own // BasicError, }; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::assert; #[ cfg( feature = "error_typed" ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::typed; #[ cfg( feature = "error_untyped" ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::untyped; } @@ -271,8 +293,10 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; } @@ -281,15 +305,19 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; // Expose itself. + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::super::error; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private:: { ErrWith, @@ -297,14 +325,17 @@ pub mod exposed }; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use assert::exposed::*; #[ cfg( feature = "error_untyped" ) ] #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use untyped::exposed::*; #[ cfg( feature = "error_typed" ) ] #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use typed::exposed::*; } @@ -314,6 +345,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; // #[ doc( inline ) ] @@ -326,14 +358,17 @@ pub mod prelude // }; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use assert::prelude::*; #[ cfg( feature = "error_untyped" ) ] #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use untyped::prelude::*; #[ cfg( feature = "error_typed" ) ] #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use typed::prelude::*; } diff --git a/module/core/error_tools/src/error/typed.rs b/module/core/error_tools/src/error/typed.rs index 074fb5b61a..0845523e35 100644 --- a/module/core/error_tools/src/error/typed.rs +++ b/module/core/error_tools/src/error/typed.rs @@ -6,14 +6,17 @@ mod private #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use orphan::*; } @@ -21,15 +24,20 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::super::typed; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::super::typed as for_lib; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] + #[ allow( clippy::pub_use ) ] pub use ::thiserror:: { Error, @@ -41,9 +49,11 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; } @@ -52,10 +62,12 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] + #[ allow( clippy::pub_use ) ] pub use thiserror; } \ No newline at end of file diff --git a/module/core/error_tools/src/error/untyped.rs b/module/core/error_tools/src/error/untyped.rs index 8288f32866..d4d65afe67 100644 --- a/module/core/error_tools/src/error/untyped.rs +++ b/module/core/error_tools/src/error/untyped.rs @@ -6,18 +6,22 @@ mod private #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use orphan::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use ::anyhow:: { Chain, @@ -37,11 +41,15 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::super::untyped; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use super::super::untyped as for_app; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; // #[ doc( inline ) ] @@ -58,9 +66,11 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; } diff --git a/module/core/error_tools/src/lib.rs b/module/core/error_tools/src/lib.rs index 9ba2500d42..dbf07d7fb2 100644 --- a/module/core/error_tools/src/lib.rs +++ b/module/core/error_tools/src/lib.rs @@ -3,8 +3,10 @@ #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/error_tools/latest/error_tools/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] +#![ allow( clippy::mod_module_files ) ] -/// Alias for std::error::BasicError. +/// Alias for `std::error::BasicError`. +#[ allow( clippy::pub_use ) ] #[ cfg( feature = "enabled" ) ] #[ cfg( not( feature = "no_std" ) ) ] pub mod error; @@ -16,69 +18,85 @@ pub mod dependency #[ doc( inline ) ] #[ cfg( feature = "error_typed" ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use ::thiserror; #[ doc( inline ) ] #[ cfg( feature = "error_untyped" ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use ::anyhow; } #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "no_std" ) ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "no_std" ) ) ] #[ allow( unused_imports ) ] pub mod own { use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use error::own::*; } /// Shared with parent namespace of the module #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "no_std" ) ) ] #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use error::orphan::*; } /// Exposed namespace of the module. #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "no_std" ) ) ] #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use error::exposed::*; } /// Prelude to use essentials: `use my_module::prelude::*`. #[ cfg( feature = "enabled" ) ] +#[ cfg( not( feature = "no_std" ) ) ] #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + use super::error; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use error::prelude::*; } diff --git a/module/core/former/Readme.md b/module/core/former/Readme.md index d36ce4b061..0e429ab46b 100644 --- a/module/core/former/Readme.md +++ b/module/core/former/Readme.md @@ -23,7 +23,7 @@ This approach abstracts away the need for manually implementing a builder for ea ## Comparison -The Former crate and the abstract Builder pattern concept share a common goal: to construct complex objects step-by-step, ensuring they are always in a valid state and hiding internal structures. Both use a fluent interface for setting fields and support default values for fields that aren't explicitly set. They also have a finalization method to return the constructed object (.form() in Former, build() in [traditional Builder](https://refactoring.guru/design-patterns/builder)). +The Former crate and the abstract Builder pattern concept share a common goal: to construct complex objects step-by-step, ensuring they are always in a valid state and hiding internal structures. Both use a fluent interface for setting fields and support default values for fields that aren't explicitly set. They also have a finalization method to return the constructed object (`.form()` in Former, `build()` in [traditional Builder](https://refactoring.guru/design-patterns/builder)). However, the Former crate extends the traditional Builder pattern by automating the generation of builder methods using macros. This eliminates the need for manual implementation, which is often required in the abstract concept. Additionally, Former supports nested builders and subformers for complex data structures, allowing for more sophisticated object construction. @@ -660,7 +660,7 @@ Storage is not just a passive collection; it is an active part of a larger ecosy - **Former as an Active Manager**: The former is responsible for managing the storage, utilizing it to keep track of the object's evolving configuration. It orchestrates the formation process by handling intermediate states and preparing the object for its final form. - **Contextual Flexibility**: The context associated with the former adds an additional layer of flexibility, allowing the former to adjust its behavior based on the broader circumstances of the object's formation. This is particularly useful when the forming process involves conditions or states external to the object itself. -- **FormingEnd Callback**: The `FormingEnd` callback is a dynamic component that defines the final steps of the forming process. It can modify the storage based on final adjustments, validate the object's readiness, or integrate the object into a larger structure, such as embedding it as a subformer within another structure. +- **`FormingEnd` Callback**: The `FormingEnd` callback is a dynamic component that defines the final steps of the forming process. It can modify the storage based on final adjustments, validate the object's readiness, or integrate the object into a larger structure, such as embedding it as a subformer within another structure. These elements work in concert to ensure that the forming process is not only about building an object step-by-step but also about integrating it seamlessly into larger, more complex structures or systems. diff --git a/module/core/former/src/lib.rs b/module/core/former/src/lib.rs index 635a8e85e0..b692c6e9b6 100644 --- a/module/core/former/src/lib.rs +++ b/module/core/former/src/lib.rs @@ -22,6 +22,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -35,6 +36,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -45,6 +47,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] diff --git a/module/core/former_meta/Readme.md b/module/core/former_meta/Readme.md index 716940ba96..1fa3cb805f 100644 --- a/module/core/former_meta/Readme.md +++ b/module/core/former_meta/Readme.md @@ -1,13 +1,13 @@ -# Module :: former_meta +# Module :: `former_meta` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml) [![docs.rs](https://img.shields.io/docsrs/former_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/former_meta) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -A flexible implementation of the Builder pattern supporting nested builders and collection-specific subformers. Implementation of its derive macro. Should not be used independently, instead use module::former which relies on the module. +A flexible implementation of the Builder pattern supporting nested builders and collection-specific subformers. Implementation of its derive macro. Should not be used independently, instead use `module::former` which relies on the module. -Not intended to be used without runtime. This module and runtime is aggregate in module::former is [here](https://github.com/Wandalen/wTools/tree/master/module/core/former). +Not intended to be used without runtime. This module and runtime is aggregate in `module::former` is [here](https://github.com/Wandalen/wTools/tree/master/module/core/former). ### To add to your project diff --git a/module/core/former_meta/src/component/component_assign.rs b/module/core/former_meta/src/component/component_assign.rs index de12fc7f5f..951e385778 100644 --- a/module/core/former_meta/src/component/component_assign.rs +++ b/module/core/former_meta/src/component/component_assign.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools::{ attr, diag, Result }; diff --git a/module/core/former_meta/src/component/component_from.rs b/module/core/former_meta/src/component/component_from.rs index c5613a48fa..c366ef3b1c 100644 --- a/module/core/former_meta/src/component/component_from.rs +++ b/module/core/former_meta/src/component/component_from.rs @@ -1,4 +1,4 @@ - +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools::{ attr, diag, Result }; diff --git a/module/core/former_meta/src/component/components_assign.rs b/module/core/former_meta/src/component/components_assign.rs index 6b495e7629..3716ef2161 100644 --- a/module/core/former_meta/src/component/components_assign.rs +++ b/module/core/former_meta/src/component/components_assign.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools::{ attr, diag, Result, format_ident }; use iter_tools::{ Itertools }; @@ -44,7 +45,7 @@ pub fn components_assign( input : proc_macro::TokenStream ) -> Result< proc_macr let component_assigns : Vec< _ > = component_assigns.into_iter().collect::< Result< _ > >()?; // code - let doc = format!( "Interface to assign instance from set of components exposed by a single argument." ); + let doc = "Interface to assign instance from set of components exposed by a single argument.".to_string(); let trait_bounds = qt! { #( #bounds1 )* IntoT : Clone }; let impl_bounds = qt! { #( #bounds2 )* #( #bounds1 )* IntoT : Clone }; let component_assigns = qt! { #( #component_assigns )* }; @@ -75,7 +76,7 @@ pub fn components_assign( input : proc_macro::TokenStream ) -> Result< proc_macr if has_debug { - let about = format!( "derive : ComponentsAssign\nstructure : {0}", item_name ); + let about = format!( "derive : ComponentsAssign\nstructure : {item_name}" ); diag::report_print( about, &original_input, &result ); } @@ -96,6 +97,7 @@ pub fn components_assign( input : proc_macro::TokenStream ) -> Result< proc_macr /// IntoT : Into< i32 > /// ``` /// +#[ allow( clippy::unnecessary_wraps ) ] fn generate_trait_bounds( field_type : &syn::Type ) -> Result< proc_macro2::TokenStream > { Ok @@ -116,6 +118,7 @@ fn generate_trait_bounds( field_type : &syn::Type ) -> Result< proc_macro2::Toke /// T : former::Assign< i32, IntoT >, /// ``` /// +#[ allow( clippy::unnecessary_wraps ) ] fn generate_impl_bounds( field_type : &syn::Type ) -> Result< proc_macro2::TokenStream > { Ok @@ -137,6 +140,7 @@ fn generate_impl_bounds( field_type : &syn::Type ) -> Result< proc_macro2::Token /// former::Assign::< i32, _ >::assign( self.component.clone() ); /// ``` /// +#[ allow( clippy::unnecessary_wraps ) ] fn generate_component_assign_call( field : &syn::Field ) -> Result< proc_macro2::TokenStream > { // let field_name = field.ident.as_ref().expect( "Expected the field to have a name" ); diff --git a/module/core/former_meta/src/component/from_components.rs b/module/core/former_meta/src/component/from_components.rs index d76029ca0a..c496ea15d9 100644 --- a/module/core/former_meta/src/component/from_components.rs +++ b/module/core/former_meta/src/component/from_components.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools::{ attr, diag, item_struct, Result }; @@ -78,7 +79,7 @@ pub fn from_components( input : proc_macro::TokenStream ) -> Result< proc_macro2 // diag::report_print( "derive : FromComponents", original_input, &result ); // } - Ok( result.into() ) + Ok( result ) } /// Generates trait bounds for the `From< T >` implementation, ensuring that `T` diff --git a/module/core/former_meta/src/derive_former.rs b/module/core/former_meta/src/derive_former.rs index b4d163608e..4a4515c199 100644 --- a/module/core/former_meta/src/derive_former.rs +++ b/module/core/former_meta/src/derive_former.rs @@ -1,4 +1,4 @@ - +#[ allow( clippy::wildcard_imports ) ] use super::*; use iter_tools::{ Itertools }; use macro_tools::{ attr, diag, generic_params, generic_args, typ, derive, Result }; @@ -7,10 +7,13 @@ use proc_macro2::TokenStream; // qqq : implement interfaces for other collections mod field_attrs; +#[ allow( clippy::wildcard_imports ) ] use field_attrs::*; mod field; +#[ allow( clippy::wildcard_imports ) ] use field::*; mod struct_attrs; +#[ allow( clippy::wildcard_imports ) ] use struct_attrs::*; /// Generates the code for implementing the `FormerMutator` trait for a specified former definition type. @@ -40,7 +43,7 @@ use struct_attrs::*; /// } /// ``` /// - +#[ allow( clippy::format_in_format_args, clippy::unnecessary_wraps ) ] pub fn mutator ( item : &syn::Ident, @@ -114,20 +117,18 @@ fn doc_generate( item : &syn::Ident ) -> ( String, String ) let doc_former_mod = format! ( -r#" Implementation of former for [{}]. -"#, - item +r#" Implementation of former for [{item}]. +"# ); let doc_former_struct = format! ( r#" -Structure to form [{}]. Represents a forming entity designed to construct objects through a builder pattern. +Structure to form [{item}]. Represents a forming entity designed to construct objects through a builder pattern. This structure holds temporary storage and context during the formation process and utilizes a defined end strategy to finalize the object creation. -"#, - item +"# ); ( doc_former_mod, doc_former_struct ) @@ -138,7 +139,7 @@ utilizes a defined end strategy to finalize the object creation. /// /// Output examples can be found in [docs to former crate](https://docs.rs/former/latest/former/) /// - +#[ allow( clippy::too_many_lines ) ] pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > { use macro_tools::IntoGenericArgs; @@ -185,7 +186,7 @@ specific needs of the broader forming context. It mandates the implementation of { < (), #item < #struct_generics_ty >, former::ReturnPreformed > }; - let former_definition_args = generic_args::merge( &generics.into_generic_args(), &extra.into() ).args; + let former_definition_args = generic_args::merge( &generics.into_generic_args(), &extra ).args; /* parameters for former */ @@ -196,7 +197,7 @@ specific needs of the broader forming context. It mandates the implementation of Definition : former::FormerDefinition< Storage = #former_storage < #struct_generics_ty > >, Definition::Types : former::FormerDefinitionTypes< Storage = #former_storage < #struct_generics_ty > >, }; - let extra = generic_params::merge( &generics, &extra.into() ); + let extra = generic_params::merge( generics, &extra.into() ); let ( former_generics_with_defaults, former_generics_impl, former_generics_ty, former_generics_where ) = generic_params::decompose( &extra ); @@ -218,7 +219,7 @@ specific needs of the broader forming context. It mandates the implementation of Formed = #item < #struct_generics_ty >, >, }; - let extra = generic_params::merge( &generics, &extra.into() ); + let extra = generic_params::merge( generics, &extra.into() ); let ( _former_perform_generics_with_defaults, former_perform_generics_impl, former_perform_generics_ty, former_perform_generics_where ) = generic_params::decompose( &extra ); @@ -229,7 +230,7 @@ specific needs of the broader forming context. It mandates the implementation of { < __Context = (), __Formed = #item < #struct_generics_ty > > }; - let former_definition_types_generics = generic_params::merge( &generics, &extra.into() ); + let former_definition_types_generics = generic_params::merge( generics, &extra.into() ); let ( former_definition_types_generics_with_defaults, former_definition_types_generics_impl, former_definition_types_generics_ty, former_definition_types_generics_where ) = generic_params::decompose( &former_definition_types_generics ); @@ -241,7 +242,7 @@ specific needs of the broader forming context. It mandates the implementation of { < __Context = (), __Formed = #item < #struct_generics_ty >, __End = former::ReturnPreformed > }; - let generics_of_definition = generic_params::merge( &generics, &extra.into() ); + let generics_of_definition = generic_params::merge( generics, &extra.into() ); let ( former_definition_generics_with_defaults, former_definition_generics_impl, former_definition_generics_ty, former_definition_generics_where ) = generic_params::decompose( &generics_of_definition ); @@ -294,7 +295,7 @@ specific needs of the broader forming context. It mandates the implementation of field.storage_field_preform(), field.former_field_setter ( - &item, + item, &original_input, &struct_generics_impl, &struct_generics_ty, @@ -317,7 +318,7 @@ specific needs of the broader forming context. It mandates the implementation of let former_mutator_code = mutator ( - &item, + item, &original_input, &struct_attrs.mutator, &former_definition_types, diff --git a/module/core/former_meta/src/derive_former/field.rs b/module/core/former_meta/src/derive_former/field.rs index 089470ea84..98edaccf49 100644 --- a/module/core/former_meta/src/derive_former/field.rs +++ b/module/core/former_meta/src/derive_former/field.rs @@ -1,4 +1,4 @@ - +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools::{ container_kind }; @@ -26,22 +26,22 @@ impl< 'a > FormerField< 'a > /** methods -from_syn +`from_syn` -storage_fields_none -storage_field_optional -storage_field_preform -storage_field_name -former_field_setter -scalar_setter -subform_entry_setter -subform_collection_setter +`storage_fields_none` +`storage_field_optional` +`storage_field_preform` +`storage_field_name` +`former_field_setter` +`scalar_setter` +`subform_entry_setter` +`subform_collection_setter` -scalar_setter_name -subform_scalar_setter_name, -subform_collection_setter_name -subform_entry_setter_name -scalar_setter_required +`scalar_setter_name` +`subform_scalar_setter_name`, +`subform_collection_setter_name` +`subform_entry_setter_name` +`scalar_setter_required` */ @@ -173,6 +173,7 @@ scalar_setter_required /// #[ inline( always ) ] + #[ allow( clippy::unnecessary_wraps ) ] pub fn storage_field_preform( &self ) -> Result< TokenStream > { @@ -228,7 +229,7 @@ scalar_setter_required { None => { - let panic_msg = format!( "Field '{}' isn't initialized", ident ); + let panic_msg = format!( "Field '{ident}' isn't initialized" ); qt! { { @@ -327,6 +328,7 @@ scalar_setter_required /// #[ inline ] + #[ allow( clippy::too_many_arguments ) ] pub fn former_field_setter ( &self, @@ -376,7 +378,7 @@ scalar_setter_required }; // subform collection setter - let ( setters_code, namespace_code ) = if let Some( _ ) = &self.attrs.subform_collection + let ( setters_code, namespace_code ) = if self.attrs.subform_collection.is_some() { let ( setters_code2, namespace_code2 ) = self.subform_collection_setter ( @@ -421,9 +423,9 @@ scalar_setter_required } /// - /// Generate a single scalar setter for the 'field_ident' with the 'setter_name' name. + /// Generate a single scalar setter for the '`field_ident`' with the '`setter_name`' name. /// - /// Used as a helper function for former_field_setter(), which generates alias setters + /// Used as a helper function for `former_field_setter()`, which generates alias setters /// /// # Example of generated code /// @@ -441,6 +443,7 @@ scalar_setter_required /// ``` #[ inline ] + #[ allow( clippy::format_in_format_args ) ] pub fn scalar_setter ( &self, @@ -494,8 +497,7 @@ field : {field_ident}"#, let doc = format! ( - "Scalar setter for the '{}' field.", - field_ident, + "Scalar setter for the '{field_ident}' field.", ); qt! @@ -515,12 +517,13 @@ field : {field_ident}"#, } /// - /// Generate a collection setter for the 'field_ident' with the 'setter_name' name. + /// Generate a collection setter for the '`field_ident`' with the '`setter_name`' name. /// /// See `tests/inc/former_tests/subform_collection_manual.rs` for example of generated code. /// #[ inline ] + #[ allow( clippy::too_many_lines, clippy::too_many_arguments ) ] pub fn subform_collection_setter ( &self, @@ -537,8 +540,9 @@ field : {field_ident}"#, let attr = self.attrs.subform_collection.as_ref().unwrap(); let field_ident = &self.ident; let field_typ = &self.non_optional_ty; - let params = typ::type_parameters( &field_typ, .. ); + let params = typ::type_parameters( field_typ, &( .. ) ); + #[ allow( clippy::useless_attribute, clippy::items_after_statements ) ] use convert_case::{ Case, Casing }; // example : `ParentSubformCollectionChildrenEnd` @@ -584,10 +588,7 @@ field : {field_ident}"#, let doc = format! ( - "Collection setter for the '{}' field. Method {} unlike method {} accept custom collection subformer.", - field_ident, - subform_collection, - field_ident, + "Collection setter for the '{field_ident}' field. Method {subform_collection} unlike method {field_ident} accept custom collection subformer." ); let setter1 = @@ -754,7 +755,7 @@ with the new content generated during the subforming process. format!( "{}", qt!{ #field_typ } ), ); - let subformer_definition_types = if let Some( ref _subformer_definition ) = subformer_definition + let subformer_definition_types = if let Some( _subformer_definition ) = subformer_definition { let subformer_definition_types_string = format!( "{}Types", qt!{ #subformer_definition } ); let subformer_definition_types : syn::Type = syn::parse_str( &subformer_definition_types_string )?; @@ -856,6 +857,7 @@ with the new content generated during the subforming process. /// #[ inline ] + #[ allow( clippy::format_in_format_args, clippy::too_many_lines, clippy::too_many_arguments ) ] pub fn subform_entry_setter ( &self, @@ -1146,6 +1148,7 @@ formation process of the `{item}`. /// See `tests/inc/former_tests/subform_scalar_manual.rs` for example of generated code. #[ inline ] + #[ allow( clippy::format_in_format_args, clippy::unnecessary_wraps, clippy::too_many_lines, clippy::too_many_arguments ) ] pub fn subform_scalar_setter ( &self, @@ -1490,12 +1493,12 @@ Essentially, this end action integrates the individually formed scalar value bac { if let Some( ref attr ) = self.attrs.scalar { - if let Some( ref name ) = attr.name.ref_internal() + if let Some( name ) = attr.name.ref_internal() { return name } } - return &self.ident; + self.ident } /// Get name of setter for subform scalar if such setter should be generated. @@ -1505,17 +1508,14 @@ Essentially, this end action integrates the individually formed scalar value bac { if attr.setter() { - if let Some( ref name ) = attr.name.ref_internal() + if let Some( name ) = attr.name.ref_internal() { - return Some( &name ) - } - else - { - return Some( &self.ident ) + return Some( name ) } + return Some( self.ident ) } } - return None; + None } /// Get name of setter for collection if such setter should be generated. @@ -1525,17 +1525,14 @@ Essentially, this end action integrates the individually formed scalar value bac { if attr.setter() { - if let Some( ref name ) = attr.name.ref_internal() - { - return Some( &name ) - } - else + if let Some( name ) = attr.name.ref_internal() { - return Some( &self.ident ) + return Some( name ) } + return Some( self.ident ) } } - return None; + None } /// Get name of setter for subform if such setter should be generated. @@ -1547,15 +1544,12 @@ Essentially, this end action integrates the individually formed scalar value bac { if let Some( ref name ) = attr.name.as_ref() { - return Some( &name ) - } - else - { - return Some( &self.ident ) + return Some( name ) } + return Some( self.ident ) } } - return None; + None } /// Is scalar setter required. Does not if collection of subformer setter requested. @@ -1567,13 +1561,13 @@ Essentially, this end action integrates the individually formed scalar value bac { if let Some( setter ) = attr.setter.internal() { - if setter == false + if !setter { return false } explicit = true; } - if let Some( ref _name ) = attr.name.ref_internal() + if let Some( _name ) = attr.name.ref_internal() { explicit = true; } @@ -1594,7 +1588,7 @@ Essentially, this end action integrates the individually formed scalar value bac return false; } - return true; + true } } diff --git a/module/core/former_meta/src/derive_former/field_attrs.rs b/module/core/former_meta/src/derive_former/field_attrs.rs index a662fe20ae..7f97619d9a 100644 --- a/module/core/former_meta/src/derive_former/field_attrs.rs +++ b/module/core/former_meta/src/derive_former/field_attrs.rs @@ -1,5 +1,5 @@ //! Attributes of a field. - +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools:: { @@ -85,7 +85,7 @@ impl FieldAttributes { // Get the attribute key as a string let key_ident = attr.path().get_ident().ok_or_else( || error( attr ) )?; - let key_str = format!( "{}", key_ident ); + let key_str = format!( "{key_ident}" ); // // Skip standard attributes // if attr::is_standard( &key_str ) @@ -102,7 +102,7 @@ impl FieldAttributes AttributeSubformScalarSetter::KEYWORD => result.assign( AttributeSubformScalarSetter::from_meta( attr )? ), AttributeSubformCollectionSetter::KEYWORD => result.assign( AttributeSubformCollectionSetter::from_meta( attr )? ), AttributeSubformEntrySetter::KEYWORD => result.assign( AttributeSubformEntrySetter::from_meta( attr )? ), - "debug" => {}, + // "debug" => {}, _ => {}, // _ => return Err( error( attr ) ), // attributes does not have to be known @@ -134,6 +134,7 @@ impl AttributeComponent for AttributeConfig const KEYWORD : &'static str = "former"; + #[ allow( clippy::match_wildcard_for_single_variants ) ] fn from_meta( attr : &syn::Attribute ) -> Result< Self > { match attr.meta @@ -144,7 +145,7 @@ impl AttributeComponent for AttributeConfig }, syn::Meta::Path( ref _path ) => { - syn::parse2::< AttributeConfig >( Default::default() ) + syn::parse2::< AttributeConfig >( TokenStream::default() ) }, _ => return_syn_err!( attr, "Expects an attribute of format #[ former( default = 13 ) ].\nGot: {}", qt!{ #attr } ), } @@ -270,6 +271,7 @@ impl AttributeComponent for AttributeScalarSetter const KEYWORD : &'static str = "scalar"; + #[ allow( clippy::match_wildcard_for_single_variants ) ] fn from_meta( attr : &syn::Attribute ) -> Result< Self > { match attr.meta @@ -280,7 +282,7 @@ impl AttributeComponent for AttributeScalarSetter }, syn::Meta::Path( ref _path ) => { - syn::parse2::< AttributeScalarSetter >( Default::default() ) + syn::parse2::< AttributeScalarSetter >( TokenStream::default() ) }, _ => return_syn_err!( attr, "Expects an attribute of format `#[ scalar( setter = false ) ]` or `#[ scalar( setter = true, name = my_name ) ]`. \nGot: {}", qt!{ #attr } ), } @@ -445,6 +447,7 @@ impl AttributeComponent for AttributeSubformScalarSetter const KEYWORD : &'static str = "subform_scalar"; + #[ allow( clippy::match_wildcard_for_single_variants ) ] fn from_meta( attr : &syn::Attribute ) -> Result< Self > { match attr.meta @@ -455,7 +458,7 @@ impl AttributeComponent for AttributeSubformScalarSetter }, syn::Meta::Path( ref _path ) => { - syn::parse2::< AttributeSubformScalarSetter >( Default::default() ) + syn::parse2::< AttributeSubformScalarSetter >( TokenStream::default() ) }, _ => return_syn_err!( attr, "Expects an attribute of format `#[ subform_scalar( setter = false ) ]` or `#[ subform_scalar( setter = true, name = my_name ) ]`. \nGot: {}", qt!{ #attr } ), } @@ -622,6 +625,7 @@ impl AttributeComponent for AttributeSubformCollectionSetter const KEYWORD : &'static str = "subform_collection"; + #[ allow( clippy::match_wildcard_for_single_variants ) ] fn from_meta( attr : &syn::Attribute ) -> Result< Self > { match attr.meta @@ -632,7 +636,7 @@ impl AttributeComponent for AttributeSubformCollectionSetter }, syn::Meta::Path( ref _path ) => { - syn::parse2::< AttributeSubformCollectionSetter >( Default::default() ) + syn::parse2::< AttributeSubformCollectionSetter >( TokenStream::default() ) }, _ => return_syn_err!( attr, "Expects an attribute of format `#[ subform_collection ]` or `#[ subform_collection( definition = former::VectorDefinition ) ]` if you want to use default collection defition. \nGot: {}", qt!{ #attr } ), } @@ -818,6 +822,7 @@ impl AttributeComponent for AttributeSubformEntrySetter const KEYWORD : &'static str = "subform_entry"; + #[ allow( clippy::match_wildcard_for_single_variants ) ] fn from_meta( attr : &syn::Attribute ) -> Result< Self > { match attr.meta @@ -828,7 +833,7 @@ impl AttributeComponent for AttributeSubformEntrySetter }, syn::Meta::Path( ref _path ) => { - syn::parse2::< AttributeSubformEntrySetter >( Default::default() ) + syn::parse2::< AttributeSubformEntrySetter >( TokenStream::default() ) }, _ => return_syn_err!( attr, "Expects an attribute of format `#[ subform_entry ]` or `#[ subform_entry( name : child )` ], \nGot: {}", qt!{ #attr } ), } diff --git a/module/core/former_meta/src/derive_former/struct_attrs.rs b/module/core/former_meta/src/derive_former/struct_attrs.rs index 31d6ab3491..f62fff702f 100644 --- a/module/core/former_meta/src/derive_former/struct_attrs.rs +++ b/module/core/former_meta/src/derive_former/struct_attrs.rs @@ -1,7 +1,7 @@ //! //! Attributes of the whole item. //! - +#[ allow( clippy::wildcard_imports ) ] use super::*; use macro_tools:: @@ -63,7 +63,7 @@ impl ItemAttributes { let key_ident = attr.path().get_ident().ok_or_else( || error( attr ) )?; - let key_str = format!( "{}", key_ident ); + let key_str = format!( "{key_ident}" ); // attributes does not have to be known // if attr::is_standard( &key_str ) @@ -76,7 +76,7 @@ impl ItemAttributes AttributeStorageFields::KEYWORD => result.assign( AttributeStorageFields::from_meta( attr )? ), AttributeMutator::KEYWORD => result.assign( AttributeMutator::from_meta( attr )? ), AttributePerform::KEYWORD => result.assign( AttributePerform::from_meta( attr )? ), - "debug" => {} + // "debug" => {} _ => {}, // _ => return Err( error( attr ) ), // attributes does not have to be known @@ -87,7 +87,7 @@ impl ItemAttributes } /// - /// Generate parts, used for generating `perform()`` method. + /// Generate parts, used for generating `perform()` method. /// /// Similar to `form()`, but will also invoke function from `perform` attribute, if specified. /// @@ -96,13 +96,13 @@ impl ItemAttributes /// ## perform : /// return result; /// - /// ## perform_output : - /// < T : ::core::default::Default > + /// ## `perform_output` : + /// < T : `::core::default::Default` > /// - /// ## perform_generics : + /// ## `perform_generics` : /// Vec< T > /// - + #[ allow( clippy::unnecessary_wraps ) ] pub fn performer( &self ) -> Result< ( TokenStream, TokenStream, TokenStream ) > { @@ -190,7 +190,7 @@ impl AttributeComponent for AttributeStorageFields { syn::Meta::List( ref meta_list ) => { - return syn::parse2::< AttributeStorageFields >( meta_list.tokens.clone() ); + syn::parse2::< AttributeStorageFields >( meta_list.tokens.clone() ) }, _ => return_syn_err!( attr, "Expects an attribute of format #[ storage_fields( a : i32, b : Option< String > ) ] .\nGot: {}", qt!{ #attr } ), @@ -260,6 +260,7 @@ pub struct AttributeMutator pub debug : AttributePropertyDebug, } +#[ allow( clippy::match_wildcard_for_single_variants ) ] impl AttributeComponent for AttributeMutator { const KEYWORD : &'static str = "mutator"; @@ -270,11 +271,11 @@ impl AttributeComponent for AttributeMutator { syn::Meta::List( ref meta_list ) => { - return syn::parse2::< AttributeMutator >( meta_list.tokens.clone() ); + syn::parse2::< AttributeMutator >( meta_list.tokens.clone() ) }, syn::Meta::Path( ref _path ) => { - return Ok( Default::default() ) + Ok( AttributeMutator::default() ) }, _ => return_syn_err!( attr, "Expects an attribute of format `#[ mutator( custom ) ]`. \nGot: {}", qt!{ #attr } ), } @@ -407,7 +408,7 @@ impl AttributeComponent for AttributePerform { syn::Meta::List( ref meta_list ) => { - return syn::parse2::< AttributePerform >( meta_list.tokens.clone() ); + syn::parse2::< AttributePerform >( meta_list.tokens.clone() ) }, _ => return_syn_err!( attr, "Expects an attribute of format #[ perform( fn parse( mut self ) -> Request ) ] .\nGot: {}", qt!{ #attr } ), diff --git a/module/core/former_types/Readme.md b/module/core/former_types/Readme.md index 30e14aaf08..742285fb8b 100644 --- a/module/core/former_types/Readme.md +++ b/module/core/former_types/Readme.md @@ -1,6 +1,6 @@ -# Module :: former_types +# Module :: `former_types` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_former_types_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_former_types_push.yml) [![docs.rs](https://img.shields.io/docsrs/former_types?color=e3e8f0&logo=docs.rs)](https://docs.rs/former_types) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fformer_types%2Fexamples%2Fformer_types_trivial.rs,RUN_POSTFIX=--example%20former_types_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) diff --git a/module/core/former_types/src/collection.rs b/module/core/former_types/src/collection.rs index c7b25889b7..8df9c34554 100644 --- a/module/core/former_types/src/collection.rs +++ b/module/core/former_types/src/collection.rs @@ -9,6 +9,7 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Facilitates the conversion of collection entries to their corresponding value representations. @@ -347,6 +348,8 @@ mod private { /// Begins the construction process of a collection with optional initial storage and context, /// setting up an `on_end` completion handler to finalize the collection's construction. + /// # Panics + /// qqq: doc #[ inline( always ) ] pub fn begin ( @@ -370,6 +373,8 @@ mod private /// Provides a variation of the `begin` method allowing for coercion of the end handler, /// facilitating ease of integration with different end conditions. + /// # Panics + /// qqq: docs #[ inline( always ) ] pub fn begin_coercing< IntoEnd > ( @@ -394,6 +399,8 @@ mod private } /// Finalizes the building process, returning the formed or a context incorporating it. + /// # Panics + /// qqq: doc #[ inline( always ) ] pub fn end( mut self ) -> Definition::Formed { @@ -412,6 +419,7 @@ mod private /// Replaces the current storage with a provided storage, allowing for resetting or /// redirection of the building process. #[ inline( always ) ] + #[ must_use ] pub fn replace( mut self, storage : Definition::Storage ) -> Self { self.storage = storage; @@ -462,6 +470,8 @@ mod private /// Appends an entry to the end of the storage, expanding the internal collection. #[ inline( always ) ] + #[ must_use ] + #[ allow( clippy::should_implement_trait ) ] pub fn add< IntoElement >( mut self, entry : IntoElement ) -> Self where IntoElement : core::convert::Into< E >, { @@ -521,6 +531,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -530,6 +541,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -539,6 +551,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] diff --git a/module/core/former_types/src/collection/binary_heap.rs b/module/core/former_types/src/collection/binary_heap.rs index ae76f5e4f8..86d350d967 100644 --- a/module/core/former_types/src/collection/binary_heap.rs +++ b/module/core/former_types/src/collection/binary_heap.rs @@ -5,6 +5,7 @@ //! as subformer, enabling fluid and intuitive manipulation of binary heaps via builder patterns. //! +#[ allow( clippy::wildcard_imports ) ] use crate::*; #[ allow( unused ) ] use collection_tools::BinaryHeap; @@ -241,6 +242,7 @@ impl< E > BinaryHeapExt< E > for BinaryHeap< E > where E : Ord { + #[ allow( clippy::default_constructed_unit_structs ) ] fn former() -> BinaryHeapFormer< E, (), BinaryHeap< E >, ReturnStorage > { BinaryHeapFormer::< E, (), BinaryHeap< E >, ReturnStorage >::new( ReturnStorage::default() ) diff --git a/module/core/former_types/src/collection/btree_map.rs b/module/core/former_types/src/collection/btree_map.rs index d1d97bfde8..9f3d01e698 100644 --- a/module/core/former_types/src/collection/btree_map.rs +++ b/module/core/former_types/src/collection/btree_map.rs @@ -4,7 +4,7 @@ //! this module abstracts the operations on binary tree map-like data structures, making them more flexible and easier to integrate as //! as subformer, enabling fluid and intuitive manipulation of binary tree maps via builder patterns. //! - +#[ allow( clippy::wildcard_imports ) ] use crate::*; use collection_tools::BTreeMap; @@ -238,6 +238,7 @@ impl< K, E > BTreeMapExt< K, E > for BTreeMap< K, E > where K : Ord, { + #[ allow( clippy::default_constructed_unit_structs ) ] fn former() -> BTreeMapFormer< K, E, (), BTreeMap< K, E >, ReturnStorage > { BTreeMapFormer::< K, E, (), BTreeMap< K, E >, ReturnStorage >::new( ReturnStorage::default() ) diff --git a/module/core/former_types/src/collection/btree_set.rs b/module/core/former_types/src/collection/btree_set.rs index 360c9484ae..d09e1793d6 100644 --- a/module/core/former_types/src/collection/btree_set.rs +++ b/module/core/former_types/src/collection/btree_set.rs @@ -4,7 +4,7 @@ //! this module abstracts the operations on binary tree set-like data structures, making them more flexible and easier to integrate as //! as subformer, enabling fluid and intuitive manipulation of binary tree sets via builder patterns. //! - +#[ allow( clippy::wildcard_imports ) ] use crate::*; #[ allow( unused ) ] use collection_tools::BTreeSet; @@ -230,6 +230,7 @@ impl< E > BTreeSetExt< E > for BTreeSet< E > where E : Ord { + #[ allow( clippy::default_constructed_unit_structs ) ] fn former() -> BTreeSetFormer< E, (), BTreeSet< E >, ReturnStorage > { BTreeSetFormer::< E, (), BTreeSet< E >, ReturnStorage >::new( ReturnStorage::default() ) diff --git a/module/core/former_types/src/collection/hash_map.rs b/module/core/former_types/src/collection/hash_map.rs index f6d6f1b58d..1c4444fa4a 100644 --- a/module/core/former_types/src/collection/hash_map.rs +++ b/module/core/former_types/src/collection/hash_map.rs @@ -5,9 +5,11 @@ //! as subformer, enabling fluid and intuitive manipulation of hashmaps via builder patterns. //! +#[ allow( clippy::wildcard_imports ) ] use crate::*; use collection_tools::HashMap; +#[ allow( clippy::implicit_hasher ) ] impl< K, V > Collection for HashMap< K, V > where K : core::cmp::Eq + core::hash::Hash, @@ -23,6 +25,7 @@ where } +#[ allow( clippy::implicit_hasher ) ] impl< K, V > CollectionAdd for HashMap< K, V > where K : core::cmp::Eq + core::hash::Hash, @@ -36,6 +39,7 @@ where } +#[ allow( clippy::implicit_hasher ) ] impl< K, V > CollectionAssign for HashMap< K, V > where K : core::cmp::Eq + core::hash::Hash, @@ -53,6 +57,7 @@ where // = storage +#[ allow( clippy::implicit_hasher ) ] impl< K, E > Storage for HashMap< K, E > where @@ -61,6 +66,7 @@ where type Preformed = HashMap< K, E >; } +#[ allow( clippy::implicit_hasher ) ] impl< K, E > StoragePreform for HashMap< K, E > where @@ -155,6 +161,7 @@ where // = Entity To +#[ allow( clippy::implicit_hasher ) ] impl< K, E, Definition > EntityToFormer< Definition > for HashMap< K, E > where K : ::core::cmp::Eq + ::core::hash::Hash, @@ -174,6 +181,7 @@ where type Former = HashMapFormer< K, E, Definition::Context, Definition::Formed, Definition::End >; } +#[ allow( clippy::implicit_hasher ) ] impl< K, E > crate::EntityToStorage for HashMap< K, E > where @@ -182,6 +190,7 @@ where type Storage = HashMap< K, E >; } +#[ allow( clippy::implicit_hasher ) ] impl< K, E, Context, Formed, End > crate::EntityToDefinition< Context, Formed, End > for HashMap< K, E > where @@ -192,6 +201,7 @@ where type Types = HashMapDefinitionTypes< K, E, Context, Formed >; } +#[ allow( clippy::implicit_hasher ) ] impl< K, E, Context, Formed > crate::EntityToDefinitionTypes< Context, Formed > for HashMap< K, E > where @@ -234,6 +244,7 @@ where fn former() -> HashMapFormer< K, E, (), HashMap< K, E >, ReturnStorage >; } +#[ allow( clippy::default_constructed_unit_structs, clippy::implicit_hasher ) ] impl< K, E > HashMapExt< K, E > for HashMap< K, E > where K : ::core::cmp::Eq + ::core::hash::Hash, diff --git a/module/core/former_types/src/collection/hash_set.rs b/module/core/former_types/src/collection/hash_set.rs index 16d5dec6c0..97d7ddd66e 100644 --- a/module/core/former_types/src/collection/hash_set.rs +++ b/module/core/former_types/src/collection/hash_set.rs @@ -1,8 +1,9 @@ //! This module provides a builder pattern implementation (`HashSetFormer`) for `HashSet`-like collections. It is designed to extend the builder pattern, allowing for fluent and dynamic construction of sets within custom data structures. - +#[ allow( clippy::wildcard_imports ) ] use crate::*; use collection_tools::HashSet; +#[ allow( clippy::implicit_hasher ) ] impl< K > Collection for HashSet< K > where K : core::cmp::Eq + core::hash::Hash, @@ -18,6 +19,7 @@ where } +#[ allow( clippy::implicit_hasher ) ] impl< K > CollectionAdd for HashSet< K > where K : core::cmp::Eq + core::hash::Hash, @@ -33,6 +35,7 @@ where } +#[ allow( clippy::implicit_hasher ) ] impl< K > CollectionAssign for HashSet< K > where K : core::cmp::Eq + core::hash::Hash, @@ -49,6 +52,7 @@ where } } +#[ allow( clippy::implicit_hasher ) ] impl< K > CollectionValToEntry< K > for HashSet< K > where K : core::cmp::Eq + core::hash::Hash, @@ -91,6 +95,7 @@ where // = storage +#[ allow( clippy::implicit_hasher ) ] impl< K > Storage for HashSet< K > where @@ -100,6 +105,7 @@ where type Preformed = HashSet< K >; } +#[ allow( clippy::implicit_hasher ) ] impl< K > StoragePreform for HashSet< K > where @@ -187,6 +193,7 @@ where // = entity to +#[ allow( clippy::implicit_hasher ) ] impl< K, Definition > EntityToFormer< Definition > for HashSet< K > where K : ::core::cmp::Eq + ::core::hash::Hash, @@ -205,6 +212,7 @@ where type Former = HashSetFormer< K, Definition::Context, Definition::Formed, Definition::End >; } +#[ allow( clippy::implicit_hasher ) ] impl< K > crate::EntityToStorage for HashSet< K > where @@ -213,6 +221,7 @@ where type Storage = HashSet< K >; } +#[ allow( clippy::implicit_hasher ) ] impl< K, Context, Formed, End > crate::EntityToDefinition< Context, Formed, End > for HashSet< K > where @@ -223,6 +232,7 @@ where type Types = HashSetDefinitionTypes< K, Context, Formed >; } +#[ allow( clippy::implicit_hasher ) ] impl< K, Context, Formed > crate::EntityToDefinitionTypes< Context, Formed > for HashSet< K > where @@ -260,10 +270,12 @@ where fn former() -> HashSetFormer< K, (), HashSet< K >, ReturnStorage >; } +#[ allow( clippy::implicit_hasher ) ] impl< K > HashSetExt< K > for HashSet< K > where K : ::core::cmp::Eq + ::core::hash::Hash, { + #[ allow( clippy::default_constructed_unit_structs ) ] fn former() -> HashSetFormer< K, (), HashSet< K >, ReturnStorage > { HashSetFormer::< K, (), HashSet< K >, ReturnStorage >::new( ReturnStorage::default() ) diff --git a/module/core/former_types/src/collection/linked_list.rs b/module/core/former_types/src/collection/linked_list.rs index abdb327074..1ace9637a9 100644 --- a/module/core/former_types/src/collection/linked_list.rs +++ b/module/core/former_types/src/collection/linked_list.rs @@ -4,7 +4,7 @@ //! this module abstracts the operations on list-like data structures, making them more flexible and easier to integrate as //! as subformer, enabling fluid and intuitive manipulation of lists via builder patterns. //! - +#[ allow( clippy::wildcard_imports ) ] use crate::*; #[ allow( unused ) ] use collection_tools::LinkedList; @@ -221,6 +221,7 @@ pub trait LinkedListExt< E > : sealed::Sealed impl< E > LinkedListExt< E > for LinkedList< E > { + #[ allow( clippy::default_constructed_unit_structs ) ] fn former() -> LinkedListFormer< E, (), LinkedList< E >, ReturnStorage > { LinkedListFormer::< E, (), LinkedList< E >, ReturnStorage >::new( ReturnStorage::default() ) diff --git a/module/core/former_types/src/collection/vector.rs b/module/core/former_types/src/collection/vector.rs index 96f7e577f1..5e88250511 100644 --- a/module/core/former_types/src/collection/vector.rs +++ b/module/core/former_types/src/collection/vector.rs @@ -4,7 +4,7 @@ //! this module abstracts the operations on vector-like data structures, making them more flexible and easier to integrate as //! as subformer, enabling fluid and intuitive manipulation of vectors via builder patterns. //! - +#[ allow( clippy::wildcard_imports ) ] use crate::*; #[ allow( unused ) ] use collection_tools::Vec; @@ -221,6 +221,7 @@ pub trait VecExt< E > : sealed::Sealed impl< E > VecExt< E > for Vec< E > { + #[ allow( clippy::default_constructed_unit_structs ) ] fn former() -> VectorFormer< E, (), Vec< E >, ReturnStorage > { VectorFormer::< E, (), Vec< E >, ReturnStorage >::new( ReturnStorage::default() ) diff --git a/module/core/former_types/src/collection/vector_deque.rs b/module/core/former_types/src/collection/vector_deque.rs index f3b08c6c01..ae207c612e 100644 --- a/module/core/former_types/src/collection/vector_deque.rs +++ b/module/core/former_types/src/collection/vector_deque.rs @@ -4,7 +4,7 @@ //! this module abstracts the operations on vector deque-like data structures, making them more flexible and easier to integrate as //! as subformer, enabling fluid and intuitive manipulation of vector deques via builder patterns. //! - +#[ allow( clippy::wildcard_imports ) ] use crate::*; #[ allow( unused ) ] use collection_tools::VecDeque; @@ -221,6 +221,7 @@ pub trait VecDequeExt< E > : sealed::Sealed impl< E > VecDequeExt< E > for VecDeque< E > { + #[ allow( clippy::default_constructed_unit_structs ) ] fn former() -> VecDequeFormer< E, (), VecDeque< E >, ReturnStorage > { VecDequeFormer::< E, (), VecDeque< E >, ReturnStorage >::new( ReturnStorage::default() ) diff --git a/module/core/former_types/src/component.rs b/module/core/former_types/src/component.rs index 9e846e2673..001619ad1e 100644 --- a/module/core/former_types/src/component.rs +++ b/module/core/former_types/src/component.rs @@ -37,7 +37,7 @@ /// obj.assign( "New Name" ); /// assert_eq!( obj.name, "New Name" ); /// ``` -#[ cfg( any( feature = "types_component_assign" ) ) ] +#[ cfg( feature = "types_component_assign" ) ] pub trait Assign< T, IntoT > where IntoT : Into< T >, @@ -51,6 +51,7 @@ where /// Sets or replaces the component on the object with the given value. /// Unlike function (`assing`) function (`impute`) also consumes self and return it what is useful for builder pattern. #[ inline( always ) ] + #[ must_use ] fn impute( mut self, component : IntoT ) -> Self where Self : Sized, @@ -94,7 +95,7 @@ where /// opt_struct.option_assign( MyStruct { name: "New Name".to_string() } ); /// assert_eq!( opt_struct.unwrap().name, "New Name" ); /// ``` -#[ cfg( any( feature = "types_component_assign" ) ) ] +#[ cfg( feature = "types_component_assign" ) ] pub trait OptionExt< T > : sealed::Sealed where T : Sized + Assign< T, T >, @@ -109,7 +110,7 @@ where fn option_assign( & mut self, src : T ); } -#[ cfg( any( feature = "types_component_assign" ) ) ] +#[ cfg( feature = "types_component_assign" ) ] impl< T > OptionExt< T > for Option< T > where T : Sized + Assign< T, T >, @@ -125,7 +126,7 @@ where } } -#[ cfg( any( feature = "types_component_assign" ) ) ] +#[ cfg( feature = "types_component_assign" ) ] mod sealed { pub trait Sealed {} @@ -172,7 +173,7 @@ mod sealed /// /// assert_eq!( user_profile.username, "john_doe" ); /// ``` -#[ cfg( any( feature = "types_component_assign" ) ) ] +#[ cfg( feature = "types_component_assign" ) ] pub trait AssignWithType { /// Sets the value of a component by its type. @@ -196,7 +197,7 @@ pub trait AssignWithType Self : Assign< T, IntoT >; } -#[ cfg( any( feature = "types_component_assign" ) ) ] +#[ cfg( feature = "types_component_assign" ) ] impl< S > AssignWithType for S { #[ inline( always ) ] diff --git a/module/core/former_types/src/forming.rs b/module/core/former_types/src/forming.rs index d95bea8666..46c9b87aff 100644 --- a/module/core/former_types/src/forming.rs +++ b/module/core/former_types/src/forming.rs @@ -163,6 +163,7 @@ use alloc::boxed::Box; /// a closure needs to be stored or passed around as an object implementing /// `FormingEnd`. #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ allow( clippy::type_complexity ) ] pub struct FormingEndClosure< Definition : crate::FormerDefinitionTypes > { closure : Box< dyn Fn( Definition::Storage, Option< Definition::Context > ) -> Definition::Formed >, diff --git a/module/core/former_types/src/lib.rs b/module/core/former_types/src/lib.rs index 39196a30e7..f4c1ac346c 100644 --- a/module/core/former_types/src/lib.rs +++ b/module/core/former_types/src/lib.rs @@ -29,7 +29,7 @@ mod collection; /// Component-based forming. #[ cfg( feature = "enabled" ) ] -#[ cfg( any( feature = "types_component_assign" ) ) ] +#[ cfg( feature = "types_component_assign" ) ] mod component; /// Namespace with dependencies. @@ -49,6 +49,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -59,6 +60,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -76,6 +78,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -103,10 +106,11 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] - #[ cfg( any( feature = "types_component_assign" ) ) ] + #[ cfg( feature = "types_component_assign" ) ] pub use component::*; #[ doc( inline ) ] diff --git a/module/core/impls_index/Cargo.toml b/module/core/impls_index/Cargo.toml index 392f5bf2f0..fc8c02eca0 100644 --- a/module/core/impls_index/Cargo.toml +++ b/module/core/impls_index/Cargo.toml @@ -34,4 +34,4 @@ impls_index_meta = { workspace = true } [dev-dependencies] test_tools = { workspace = true } -tempdir = { workspace = true } +#tempdir = { version = "0.3.7" } diff --git a/module/core/interval_adapter/Readme.md b/module/core/interval_adapter/Readme.md index 19cfc05f9e..f1d171804d 100644 --- a/module/core/interval_adapter/Readme.md +++ b/module/core/interval_adapter/Readme.md @@ -1,11 +1,11 @@ -# Module :: interval_adapter +# Module :: `interval_adapter` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_interval_adapter_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_interval_adapter_push.yml) [![docs.rs](https://img.shields.io/docsrs/interval_adapter?color=e3e8f0&logo=docs.rs)](https://docs.rs/interval_adapter) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Finterval_adapter%2Fexamples%2Finterval_adapter_trivial.rs,RUN_POSTFIX=--example%20interval_adapter_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -Integer interval adapter for both Range and RangeInclusive. +Integer interval adapter for both Range and `RangeInclusive`. Let's assume you have a function which should accept Interval. But you don't want to limit caller of the function to either half-open interval `core::ops::Range` or closed one `core::ops::RangeInclusive` you want allow to use anyone of iterable interval. To make that work smoothly use `IterableInterval`. Both `core::ops::Range` and `core::ops::RangeInclusive` implement the trait, also it's possible to work with non-iterable intervals, like ( -Infinity .. +Infinity ). diff --git a/module/core/interval_adapter/src/lib.rs b/module/core/interval_adapter/src/lib.rs index 3fcc39e3f1..19fb7c2537 100644 --- a/module/core/interval_adapter/src/lib.rs +++ b/module/core/interval_adapter/src/lib.rs @@ -11,9 +11,11 @@ mod private #[ doc( inline ) ] #[ allow( unused_imports ) ] + #[ allow( clippy::pub_use ) ] pub use core::ops::Bound; #[ doc( inline ) ] #[ allow( unused_imports ) ] + #[ allow( clippy::pub_use ) ] pub use core::ops::RangeBounds; use core::cmp::{ PartialEq, Eq }; @@ -21,6 +23,7 @@ mod private // xxx : seal it + #[ allow( clippy::wrong_self_convention ) ] /// Extend bound adding few methods. pub trait BoundExt< T > where @@ -39,23 +42,25 @@ mod private isize : Into< T >, { #[ inline( always ) ] + #[ allow( clippy::arithmetic_side_effects, clippy::implicit_return, clippy::pattern_type_mismatch ) ] fn into_left_closed( &self ) -> T { match self { - Bound::Included( v ) => *v, - Bound::Excluded( v ) => *v + 1.into(), + Bound::Included( value ) => *value, + Bound::Excluded( value ) => *value + 1.into(), Bound::Unbounded => 0.into(), // Bound::Unbounded => isize::MIN.into(), } } #[ inline( always ) ] + #[ allow( clippy::arithmetic_side_effects, clippy::implicit_return, clippy::pattern_type_mismatch ) ] fn into_right_closed( &self ) -> T { match self { - Bound::Included( v ) => *v, - Bound::Excluded( v ) => *v - 1.into(), + Bound::Included( value ) => *value, + Bound::Excluded( value ) => *value - 1.into(), Bound::Unbounded => isize::MAX.into(), } } @@ -97,6 +102,7 @@ mod private fn right( &self ) -> Bound< T >; /// Interval in closed format as pair of numbers. /// To convert open endpoint to closed add or subtract one. + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn bounds( &self ) -> ( Bound< T >, Bound< T > ) { @@ -104,18 +110,21 @@ mod private } /// The left endpoint of the interval, converting interval into closed one. + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn closed_left( &self ) -> T { self.left().into_left_closed() } /// The right endpoint of the interval, converting interval into closed one. + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn closed_right( &self ) -> T { self.right().into_right_closed() } /// Length of the interval, converting interval into closed one. + #[ allow( clippy::implicit_return, clippy::arithmetic_side_effects ) ] #[ inline( always ) ] fn closed_len( &self ) -> T { @@ -123,6 +132,7 @@ mod private self.closed_right() - self.closed_left() + one } /// Interval in closed format as pair of numbers, converting interval into closed one. + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn closed( &self ) -> ( T, T ) { @@ -130,6 +140,7 @@ mod private } /// Convert to interval in canonical format. + #[ allow( unknown_lints, clippy::implicit_return ) ] #[ inline( always ) ] fn canonical( &self ) -> Interval< T > { @@ -166,16 +177,19 @@ mod private /// /// Canonical implementation of interval. Other implementations of interval is convertible to it. /// - /// Both [core::ops::Range], [core::ops::RangeInclusive] are convertable to [crate::Interval] + /// Both [`core::ops::Range`], [`core::ops::RangeInclusive`] are convertable to [`crate::Interval`] /// + #[ allow( clippy::used_underscore_binding ) ] #[ derive( PartialEq, Eq, Debug, Clone, Copy ) ] pub struct Interval< T = isize > where T : EndPointTrait< T >, isize : Into< T >, { + /// Left _left : Bound< T >, + /// Right _right : Bound< T >, } @@ -185,15 +199,18 @@ mod private isize : Into< T >, { /// Constructor of an interval. Expects closed interval in arguments. + #[ allow( unknown_lints, clippy::implicit_return ) ] + #[ inline ] pub fn new( left : Bound< T >, right : Bound< T > ) -> Self { Self { _left : left, _right : right } } /// Convert to interval in canonical format. + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] pub fn iter< It >( &self ) -> impl Iterator< Item = T > { - ( &self ).into_iter() + self.into_iter() } } @@ -208,6 +225,7 @@ mod private { type Item = T; type IntoIter = IntervalIterator< T >; + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn into_iter( self ) -> Self::IntoIter { @@ -222,6 +240,7 @@ mod private { type Item = T; type IntoIter = IntervalIterator< T >; + #[ allow( unknown_lints, clippy::implicit_return ) ] #[ inline( always ) ] fn into_iter( self ) -> Self::IntoIter { @@ -229,13 +248,16 @@ mod private } } + /// qqq: Documentation #[ derive( Debug ) ] pub struct IntervalIterator< T > where T : EndPointTrait< T >, isize : Into< T >, { + /// current current : T, + /// right right : T, } @@ -245,6 +267,7 @@ mod private isize : Into< T >, { /// Constructor. + #[ allow( clippy::used_underscore_binding, clippy::implicit_return ) ] pub fn new( ins : Interval< T > ) -> Self { let current = ins._left.into_left_closed(); @@ -253,12 +276,14 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > Iterator for IntervalIterator< T > where T : EndPointTrait< T >, isize : Into< T >, { type Item = T; + #[ allow( clippy::implicit_return, clippy::arithmetic_side_effects ) ] #[ inline( always ) ] fn next( &mut self ) -> Option< Self::Item > { @@ -298,17 +323,20 @@ mod private // } // } + #[ allow( clippy::used_underscore_binding, clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for Interval< T > where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn left( &self ) -> Bound< T > { self._left } + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -316,17 +344,20 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for core::ops::Range< T > where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn left( &self ) -> Bound< T > { Bound::Included( self.start ) } + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -334,17 +365,20 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for core::ops::RangeInclusive< T > where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn left( &self ) -> Bound< T > { Bound::Included( *self.start() ) } + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -352,17 +386,20 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for core::ops::RangeTo< T > where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn left( &self ) -> Bound< T > { Bound::Unbounded } + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -370,17 +407,20 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for core::ops::RangeToInclusive< T > where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return ) ] #[ inline( always ) ] fn left( &self ) -> Bound< T > { Bound::Unbounded } + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -388,17 +428,20 @@ mod private } } + #[allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for core::ops::RangeFrom< T > where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn left( &self ) -> Bound< T > { Bound::Included( self.start ) } + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -406,17 +449,20 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for core::ops::RangeFull where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn left( &self ) -> Bound< T > { Bound::Unbounded } + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -424,17 +470,20 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for ( T, T ) where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn left( &self ) -> Bound< T > { Bound::Included( self.0 ) } + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -442,17 +491,22 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for ( Bound< T >, Bound< T > ) where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( unknown_lints )] + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn left( &self ) -> Bound< T > { self.0 } + #[ allow( unknown_lints )] + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -460,17 +514,21 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for [ T ; 2 ] where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn left( &self ) -> Bound< T > { Bound::Included( self[ 0 ] ) } + #[ allow( unknown_lints )] + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -478,17 +536,20 @@ mod private } } + #[ allow( clippy::missing_trait_methods ) ] impl< T > NonIterableInterval< T > for [ Bound< T > ; 2 ] where T : EndPointTrait< T >, isize : Into< T >, { + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn left( &self ) -> Bound< T > { self[ 0 ] } + #[ allow( clippy::implicit_return )] #[ inline( always ) ] fn right( &self ) -> Bound< T > { @@ -499,7 +560,7 @@ mod private // = // from for std // = - + /// qqq: documentation macro_rules! impl_interval_from { {} => {}; @@ -519,7 +580,7 @@ mod private { let _left = NonIterableInterval::left( &src ); let _right = NonIterableInterval::right( &src ); - Self { _left, _right } + return Self { _left, _right } } } }; @@ -564,6 +625,9 @@ mod private isize : Into< T >, Interval< T > : From< Self >, { + #[ allow( unknown_lints )] + #[ allow( clippy::implicit_return )] + #[ inline ] fn into_interval( self ) -> Interval< T > { From::from( self ) @@ -576,6 +640,7 @@ mod private #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] // #[ allow( unused_imports ) ] +#[ allow( clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. @@ -583,7 +648,8 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { - use super::*; + use super::orphan; + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] #[ doc( inline ) ] pub use orphan::*; } @@ -593,8 +659,9 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { - use super::*; + use super::exposed; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use exposed::*; } @@ -603,10 +670,12 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { - use super::*; + use super::{ prelude, private }; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use prelude::*; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private:: { Bound, @@ -620,7 +689,7 @@ pub mod exposed } // #[ doc( inline ) ] -#[ allow( unused_imports ) ] +// #[ allow( unused_imports ) ] // #[ cfg( feature = "enabled" ) ] // #[ allow( unused_imports ) ] // pub use exposed::*; @@ -630,8 +699,9 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + use super::private; #[ doc( inline ) ] + #[ allow( clippy::useless_attribute, clippy::pub_use ) ] pub use private:: { IterableInterval, diff --git a/module/core/iter_tools/Readme.md b/module/core/iter_tools/Readme.md index 4aaebd7c0f..cafefb8cc7 100644 --- a/module/core/iter_tools/Readme.md +++ b/module/core/iter_tools/Readme.md @@ -1,6 +1,6 @@ -# Module :: iter_tools +# Module :: `iter_tools` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_iter_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_iter_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/iter_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/iter_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fiter_tools%2Fexamples%2Fiter_tools_trivial.rs,RUN_POSTFIX=--example%20iter_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) @@ -50,7 +50,7 @@ cd wTools cd examples/iter_tools_trivial cargo run ``` -` + ### Try out from the repository diff --git a/module/core/iter_tools/src/iter.rs b/module/core/iter_tools/src/iter.rs index 727e18409f..62b0294989 100644 --- a/module/core/iter_tools/src/iter.rs +++ b/module/core/iter_tools/src/iter.rs @@ -173,6 +173,8 @@ mod private Self : core::iter::Iterator, { /// Iterate each element and return `core::Result::Err` if any element is error. + /// # Errors + /// qqq: errors fn map_result< F, RE, El >( self, f : F ) -> core::result::Result< Vec< El >, RE > where Self : Sized + Clone, @@ -209,6 +211,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -219,6 +222,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -269,7 +273,7 @@ pub mod orphan #[ cfg( not( feature = "no_std" ) ) ] #[ doc( inline ) ] - pub use std::iter::zip; + pub use core::iter::zip; } @@ -277,6 +281,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -306,6 +311,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] diff --git a/module/core/iter_tools/src/lib.rs b/module/core/iter_tools/src/lib.rs index caa22f5593..e4b744172f 100644 --- a/module/core/iter_tools/src/lib.rs +++ b/module/core/iter_tools/src/lib.rs @@ -32,6 +32,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -48,6 +49,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -58,6 +60,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use prelude::*; diff --git a/module/core/macro_tools/Readme.md b/module/core/macro_tools/Readme.md index 6d148200b3..8cb337367c 100644 --- a/module/core/macro_tools/Readme.md +++ b/module/core/macro_tools/Readme.md @@ -1,6 +1,6 @@ -# Module :: proc_macro_tools +# Module :: `proc_macro_tools` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_macro_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_macro_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/macro_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/macro_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fmacro_tools%2Fexamples%2Fmacro_tools_trivial.rs,RUN_POSTFIX=--example%20macro_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) @@ -67,10 +67,10 @@ using reusable components like `AttributePropertyBoolean`. - `AttributeComponent`: A trait that defines how an attribute should be parsed from a `syn::Attribute`. - `AttributePropertyComponent`: A trait that defines a marker for attribute properties. - `Assign`: A trait that simplifies the logic of assigning fields to a struct. Using a -component-based approach requires each field to have a unique type, which aligns with the -strengths of strongly-typed languages. This method ensures that the logic of -assigning values to fields is encapsulated within the fields themselves, promoting modularity -and reusability. + component-based approach requires each field to have a unique type, which aligns with the + strengths of strongly-typed languages. This method ensures that the logic of + assigning values to fields is encapsulated within the fields themselves, promoting modularity + and reusability. The reusable property components from the library come with parameters that distinguish different properties of the same type. This is useful when an attribute has multiple boolean diff --git a/module/core/macro_tools/src/attr.rs b/module/core/macro_tools/src/attr.rs index 15c0d1e69d..e2edde225f 100644 --- a/module/core/macro_tools/src/attr.rs +++ b/module/core/macro_tools/src/attr.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Checks if the given iterator of attributes contains an attribute named `debug`. @@ -48,7 +49,8 @@ mod private /// /// assert!( contains_debug, "Expected to find 'debug' attribute" ); /// ``` - /// + /// # Errors + /// qqq: doc pub fn has_debug< 'a >( attrs : impl Iterator< Item = &'a syn::Attribute > ) -> syn::Result< bool > { @@ -56,7 +58,7 @@ mod private { if let Some( ident ) = attr.path().get_ident() { - let ident_string = format!( "{}", ident ); + let ident_string = format!( "{ident}" ); if ident_string == "debug" { return Ok( true ) @@ -67,7 +69,7 @@ mod private return_syn_err!( "Unknown structure attribute:\n{}", qt!{ attr } ); } } - return Ok( false ) + Ok( false ) } /// Checks if the given attribute name is a standard Rust attribute. @@ -110,8 +112,9 @@ mod private /// assert_eq!( macro_tools::attr::is_standard( "my_attribute" ), false ); /// ``` /// - - pub fn is_standard<'a>( attr_name : &'a str ) -> bool + #[ must_use ] + #[ allow( clippy::match_same_arms ) ] + pub fn is_standard( attr_name : &str ) -> bool { match attr_name { @@ -199,6 +202,7 @@ mod private } } + #[ allow( clippy::iter_without_into_iter ) ] impl AttributesInner { /// Iterator @@ -208,6 +212,7 @@ mod private } } + #[ allow( clippy::default_trait_access ) ] impl syn::parse::Parse for AttributesInner { @@ -274,6 +279,7 @@ mod private } } + #[ allow( clippy::iter_without_into_iter ) ] impl AttributesOuter { /// Iterator @@ -283,6 +289,7 @@ mod private } } + #[ allow( clippy::default_trait_access ) ] impl syn::parse::Parse for AttributesOuter { @@ -425,6 +432,9 @@ mod private /// # Returns /// /// A `syn::Result` containing the constructed component if successful, or an error if the parsing fails. + /// + /// # Errors + /// qqq: doc fn from_meta( attr : &syn::Attribute ) -> syn::Result< Self >; // zzz : redo maybe @@ -440,6 +450,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -456,6 +467,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -465,6 +477,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::attr; diff --git a/module/core/macro_tools/src/attr_prop.rs b/module/core/macro_tools/src/attr_prop.rs index 8ffa3d9cab..e981e9803a 100644 --- a/module/core/macro_tools/src/attr_prop.rs +++ b/module/core/macro_tools/src/attr_prop.rs @@ -151,6 +151,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -164,6 +165,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -173,6 +175,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::attr_prop; diff --git a/module/core/macro_tools/src/attr_prop/boolean.rs b/module/core/macro_tools/src/attr_prop/boolean.rs index fa786b990d..d57917b576 100644 --- a/module/core/macro_tools/src/attr_prop/boolean.rs +++ b/module/core/macro_tools/src/attr_prop/boolean.rs @@ -3,6 +3,8 @@ //! Defaults to `false`. //! +use core::marker::PhantomData; +#[ allow( clippy::wildcard_imports ) ] use crate::*; // use former_types::Assign; @@ -114,6 +116,7 @@ pub struct AttributePropertyBoolean< Marker = AttributePropertyBooleanMarker >( impl< Marker > AttributePropertyBoolean< Marker > { /// Just unwraps and returns the internal data. + #[ must_use ] #[ inline( always ) ] pub fn internal( self ) -> bool { @@ -122,6 +125,7 @@ impl< Marker > AttributePropertyBoolean< Marker > /// Returns a reference to the internal boolean value. #[ inline( always ) ] + #[ must_use ] pub fn ref_internal( &self ) -> &bool { &self.0 @@ -160,9 +164,10 @@ impl< Marker > syn::parse::Parse for AttributePropertyBoolean< Marker > impl< Marker > From< bool > for AttributePropertyBoolean< Marker > { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : bool ) -> Self { - Self( src, Default::default() ) + Self( src, PhantomData::default() ) } } diff --git a/module/core/macro_tools/src/attr_prop/boolean_optional.rs b/module/core/macro_tools/src/attr_prop/boolean_optional.rs index e695db40dd..bbc953c63a 100644 --- a/module/core/macro_tools/src/attr_prop/boolean_optional.rs +++ b/module/core/macro_tools/src/attr_prop/boolean_optional.rs @@ -2,7 +2,8 @@ //! A generic optional boolean attribute property: `Option< bool >`. //! Defaults to `false`. //! - +use core::marker::PhantomData; +#[ allow( clippy::wildcard_imports ) ] use crate::*; use components::Assign; @@ -19,6 +20,7 @@ pub struct AttributePropertyOptionalBoolean< Marker = AttributePropertyOptionalB impl< Marker > AttributePropertyOptionalBoolean< Marker > { /// Just unwraps and returns the internal data. + #[ must_use ] #[ inline( always ) ] pub fn internal( self ) -> Option< bool > { @@ -26,6 +28,7 @@ impl< Marker > AttributePropertyOptionalBoolean< Marker > } /// Returns a reference to the internal optional boolean value. + #[ must_use ] #[ inline( always ) ] pub fn ref_internal( &self ) -> Option< &bool > { @@ -42,6 +45,7 @@ where /// Inserts value of another instance into the option if it is None, then returns a mutable reference to the contained value. /// If another instance does is None then do nothing. #[ inline( always ) ] + #[ allow( clippy::single_match ) ] fn assign( &mut self, component : IntoT ) { let component = component.into(); @@ -73,18 +77,20 @@ impl< Marker > syn::parse::Parse for AttributePropertyOptionalBoolean< Marker > impl< Marker > From< bool > for AttributePropertyOptionalBoolean< Marker > { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : bool ) -> Self { - Self( Some( src ), Default::default() ) + Self( Some( src ), PhantomData::default() ) } } impl< Marker > From< Option< bool > > for AttributePropertyOptionalBoolean< Marker > { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : Option< bool > ) -> Self { - Self( src, Default::default() ) + Self( src, PhantomData::default() ) } } diff --git a/module/core/macro_tools/src/attr_prop/singletone.rs b/module/core/macro_tools/src/attr_prop/singletone.rs index 0e6970bdd0..1ee3d86266 100644 --- a/module/core/macro_tools/src/attr_prop/singletone.rs +++ b/module/core/macro_tools/src/attr_prop/singletone.rs @@ -11,6 +11,8 @@ //! //! This is useful for attributes that need to enable or disable features or flags. +use core::marker::PhantomData; +#[ allow( clippy::wildcard_imports ) ] use crate::*; // use former_types::Assign; @@ -35,6 +37,7 @@ impl< Marker > AttributePropertySingletone< Marker > { /// Unwraps and returns the internal optional boolean value. + #[ must_use ] #[ inline( always ) ] pub fn internal( self ) -> bool { @@ -42,6 +45,7 @@ impl< Marker > AttributePropertySingletone< Marker > } /// Returns a reference to the internal optional boolean value. + #[ must_use ] #[ inline( always ) ] pub fn ref_internal( &self ) -> &bool { @@ -72,9 +76,10 @@ where impl< Marker > From< bool > for AttributePropertySingletone< Marker > { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : bool ) -> Self { - Self( src, Default::default() ) + Self( src, PhantomData::default() ) } } diff --git a/module/core/macro_tools/src/attr_prop/singletone_optional.rs b/module/core/macro_tools/src/attr_prop/singletone_optional.rs index 7d500cc94f..0761d65233 100644 --- a/module/core/macro_tools/src/attr_prop/singletone_optional.rs +++ b/module/core/macro_tools/src/attr_prop/singletone_optional.rs @@ -12,7 +12,8 @@ //! ``` //! //! This is useful for attributes that need to enable or disable features or flags. - +use core::marker::PhantomData; +#[ allow( clippy::wildcard_imports ) ] use crate::*; // use former_types::Assign; @@ -39,7 +40,10 @@ impl< Marker > AttributePropertyOptionalSingletone< Marker > { /// Return bool value: on/off, use argument as default if it's `None`. + /// # Panics + /// qqq: doc #[ inline ] + #[ must_use ] pub fn value( self, default : bool ) -> bool { if self.0.is_none() @@ -51,12 +55,14 @@ impl< Marker > AttributePropertyOptionalSingletone< Marker > /// Unwraps and returns the internal optional boolean value. #[ inline( always ) ] + #[ must_use ] pub fn internal( self ) -> Option< bool > { self.0 } /// Returns a reference to the internal optional boolean value. + #[ must_use ] #[ inline( always ) ] pub fn ref_internal( &self ) -> Option< &bool > { @@ -73,6 +79,7 @@ where /// Inserts value of another instance into the option if it is None, then returns a mutable reference to the contained value. /// If another instance does is None then do nothing. #[ inline( always ) ] + #[ allow( clippy::single_match ) ] fn assign( &mut self, component : IntoT ) { let component = component.into(); @@ -94,18 +101,20 @@ where impl< Marker > From< bool > for AttributePropertyOptionalSingletone< Marker > { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : bool ) -> Self { - Self( Some( src ), Default::default() ) + Self( Some( src ), PhantomData::default() ) } } impl< Marker > From< Option< bool > > for AttributePropertyOptionalSingletone< Marker > { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : Option< bool > ) -> Self { - Self( src, Default::default() ) + Self( src, PhantomData::default() ) } } diff --git a/module/core/macro_tools/src/attr_prop/syn.rs b/module/core/macro_tools/src/attr_prop/syn.rs index 183ead1a3a..4427a83f22 100644 --- a/module/core/macro_tools/src/attr_prop/syn.rs +++ b/module/core/macro_tools/src/attr_prop/syn.rs @@ -2,6 +2,8 @@ //! Property of an attribute which simply wraps one of the standard `syn` types. //! +use core::marker::PhantomData; +#[ allow( clippy::wildcard_imports ) ] use crate::*; // use former_types::Assign; @@ -108,8 +110,9 @@ impl< T, Marker > From< T > for AttributePropertySyn< T, Marker > where T : syn::parse::Parse + quote::ToTokens { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : T ) -> Self { - Self( src, Default::default() ) + Self( src, PhantomData::default() ) } } diff --git a/module/core/macro_tools/src/attr_prop/syn_optional.rs b/module/core/macro_tools/src/attr_prop/syn_optional.rs index 4e5bba2783..e95e46b779 100644 --- a/module/core/macro_tools/src/attr_prop/syn_optional.rs +++ b/module/core/macro_tools/src/attr_prop/syn_optional.rs @@ -1,7 +1,8 @@ //! //! Property of an attribute which simply wraps one of the standard `syn` types and keeps it optional. //! - +use core::marker::PhantomData; +#[ allow( clippy::wildcard_imports ) ] use crate::*; // use former_types::Assign; @@ -46,6 +47,7 @@ where { /// Inserts value of another instance into the option if it is None, then returns a mutable reference to the contained value. /// If another instance does is None then do nothing. + #[ allow( clippy::single_match ) ] #[ inline( always ) ] fn assign( &mut self, component : IntoT ) { @@ -70,9 +72,10 @@ impl< T, Marker > Default for AttributePropertyOptionalSyn< T, Marker > where T : syn::parse::Parse + quote::ToTokens, { + #[ allow( clippy::default_constructed_unit_structs ) ] fn default() -> Self { - Self( None, Default::default() ) + Self( None, PhantomData::default() ) } } @@ -123,9 +126,10 @@ impl< T, Marker > From< T > for AttributePropertyOptionalSyn< T, Marker > where T : syn::parse::Parse + quote::ToTokens { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : T ) -> Self { - Self( Some( src ), Default::default() ) + Self( Some( src ), PhantomData::default() ) } } @@ -133,9 +137,10 @@ impl< T, Marker > From< Option< T > > for AttributePropertyOptionalSyn< T, Marke where T : syn::parse::Parse + quote::ToTokens { #[ inline( always ) ] + #[ allow( clippy::default_constructed_unit_structs ) ] fn from( src : Option< T > ) -> Self { - Self( src, Default::default() ) + Self( src, PhantomData::default() ) } } diff --git a/module/core/macro_tools/src/components.rs b/module/core/macro_tools/src/components.rs index 4e8b2ccf20..7d744f57c1 100644 --- a/module/core/macro_tools/src/components.rs +++ b/module/core/macro_tools/src/components.rs @@ -15,6 +15,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -31,6 +32,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -40,6 +42,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::components; diff --git a/module/core/macro_tools/src/container_kind.rs b/module/core/macro_tools/src/container_kind.rs index 6dc2719925..a2e1de1297 100644 --- a/module/core/macro_tools/src/container_kind.rs +++ b/module/core/macro_tools/src/container_kind.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // use crate::type_rightmost; @@ -39,7 +40,9 @@ mod private /// let kind = container_kind::of_type( &tree_type ); /// assert_eq!( kind, container_kind::ContainerKind::HashMap ); /// ``` - + /// # Panics + /// qqq: doc + #[ must_use ] pub fn of_type( ty : &syn::Type ) -> ContainerKind { @@ -61,7 +64,7 @@ mod private ContainerKind::No } - /// Return kind of container specified by type. Unlike [of_type] it also understand optional types. + /// Return kind of container specified by type. Unlike [`of_type`] it also understand optional types. /// /// Good to verify `Option< alloc::vec::Vec< i32 > >` is optional vector. /// @@ -75,13 +78,16 @@ mod private /// assert_eq!( kind, container_kind::ContainerKind::HashMap ); /// assert_eq!( optional, true ); /// ``` + /// # Panics + /// qqq: doc + #[ must_use ] pub fn of_optional( ty : &syn::Type ) -> ( ContainerKind, bool ) { if typ::type_rightmost( ty ) == Some( "Option".to_string() ) { - let ty2 = typ::type_parameters( ty, 0 ..= 0 ).first().copied(); + let ty2 = typ::type_parameters( ty, &( 0 ..= 0 ) ).first().copied(); // inspect_type::inspect_type_of!( ty2 ); if ty2.is_none() { @@ -104,6 +110,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -122,6 +129,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -131,6 +139,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::container_kind; diff --git a/module/core/macro_tools/src/ct.rs b/module/core/macro_tools/src/ct.rs index 1264aea393..4083f7321c 100644 --- a/module/core/macro_tools/src/ct.rs +++ b/module/core/macro_tools/src/ct.rs @@ -19,6 +19,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -35,6 +36,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -44,6 +46,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::ct; diff --git a/module/core/macro_tools/src/derive.rs b/module/core/macro_tools/src/derive.rs index dacf84f8e7..7dd8888d61 100644 --- a/module/core/macro_tools/src/derive.rs +++ b/module/core/macro_tools/src/derive.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use syn::punctuated::Punctuated; @@ -24,8 +25,10 @@ mod private /// }; /// let fields = derive.named_fields( &ast ); /// ``` + /// # Errors + /// qqq: doc - pub fn named_fields< 'a >( ast : &'a syn::DeriveInput ) -> crate::Result< &'a Punctuated< syn::Field, syn::token::Comma > > + pub fn named_fields( ast : &syn::DeriveInput ) -> crate::Result< &Punctuated< syn::Field, syn::token::Comma > > { let fields = match ast.data @@ -54,6 +57,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -70,6 +74,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -79,6 +84,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::derive; @@ -96,6 +102,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] diff --git a/module/core/macro_tools/src/diag.rs b/module/core/macro_tools/src/diag.rs index 81138cd382..40a3afb1bf 100644 --- a/module/core/macro_tools/src/diag.rs +++ b/module/core/macro_tools/src/diag.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Adds indentation and optional prefix/postfix to each line of the given string. @@ -62,17 +63,17 @@ mod private { if b.0 > 0 { - a.push_str( "\n" ); + a.push( '\n' ); } a.push_str( prefix ); - a.push_str( &b.1 ); + a.push_str( b.1 ); a.push_str( postfix ); a }); - if src.ends_with( "\n" ) || src.ends_with( "\n\r" ) || src.ends_with( "\r\n" ) + if src.ends_with( '\n' ) || src.ends_with( "\n\r" ) || src.ends_with( "\r\n" ) { - result.push_str( "\n" ); + result.push( '\n' ); result.push_str( prefix ); result.push_str( postfix ); } @@ -128,11 +129,12 @@ mod private /// }; /// /// // Format the debug report for printing or logging - /// let formatted_report = report_format( "Code Transformation for MyStruct", original_input, generated_code ); + /// let formatted_report = report_format( &"Code Transformation for MyStruct", &original_input, generated_code ); /// println!( "{}", formatted_report ); /// ``` /// + #[ allow( clippy::needless_pass_by_value ) ] pub fn report_format< IntoAbout, IntoInput, IntoOutput > ( about : IntoAbout, input : IntoInput, output : IntoOutput @@ -142,7 +144,7 @@ mod private IntoInput : ToString, IntoOutput : ToString, { - format!( "\n" ) + + "\n".to_string() + &format!( " = context\n\n{}\n\n", indentation( " ", about.to_string(), "" ) ) + &format!( " = original\n\n{}\n\n", indentation( " ", input.to_string(), "" ) ) + &format!( " = generated\n\n{}\n", indentation( " ", output.to_string(), "" ) ) @@ -384,6 +386,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -395,6 +398,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -412,6 +416,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::diag; @@ -432,6 +437,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] diff --git a/module/core/macro_tools/src/equation.rs b/module/core/macro_tools/src/equation.rs index 3d89aa4ba4..ae7080efdb 100644 --- a/module/core/macro_tools/src/equation.rs +++ b/module/core/macro_tools/src/equation.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Represents an equation parsed from a procedural macro input. @@ -85,7 +86,7 @@ mod private /// /// For attribute like `#[former( default = 31 ) ]` return key `default` and value `31`, - /// as well as syn::Meta as the last element of result tuple. + /// as well as `syn::Meta` as the last element of result tuple. /// /// ### Basic use-case. /// @@ -96,19 +97,20 @@ mod private /// let got = equation::from_meta( &attr ).unwrap(); /// assert_eq!( macro_tools::code_to_str!( got ), "default = 31".to_string() ); /// ``` - + /// # Errors + /// qqq: doc pub fn from_meta( attr : &syn::Attribute ) -> Result< Equation > { let meta = &attr.meta; - return match meta + match meta { syn::Meta::List( ref meta_list ) => { let eq : Equation = syn::parse2( meta_list.tokens.clone() )?; Ok( eq ) } - _ => return Err( syn::Error::new( attr.span(), "Unknown format of attribute, expected syn::Meta::List( meta_list )" ) ), - }; + _ => Err( syn::Error::new( attr.span(), "Unknown format of attribute, expected syn::Meta::List( meta_list )" ) ), + } } } @@ -121,6 +123,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -135,6 +138,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -144,6 +148,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::equation; diff --git a/module/core/macro_tools/src/generic_args.rs b/module/core/macro_tools/src/generic_args.rs index 1cd40e8f7a..b07b22c5d3 100644 --- a/module/core/macro_tools/src/generic_args.rs +++ b/module/core/macro_tools/src/generic_args.rs @@ -24,6 +24,7 @@ mod private /// # Returns /// A new instance of `syn::AngleBracketedGenericArguments` representing the generic parameters /// of the original type. + #[ allow( clippy::wrong_self_convention ) ] fn into_generic_args( &self ) -> syn::AngleBracketedGenericArguments; } @@ -98,6 +99,7 @@ mod private /// /// This example demonstrates how lifetimes `'a` and `'b` are placed before other generic parameters /// like `T`, `U`, and `V` in the merged result, adhering to the expected syntax order in Rust generics. + #[ must_use ] pub fn merge ( a : &syn::AngleBracketedGenericArguments, @@ -110,7 +112,7 @@ mod private // Function to categorize and collect arguments into lifetimes and others let mut categorize_and_collect = |args : &syn::punctuated::Punctuated| { - for arg in args.iter() + for arg in args { match arg { @@ -148,6 +150,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -163,6 +166,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; diff --git a/module/core/macro_tools/src/generic_params.rs b/module/core/macro_tools/src/generic_params.rs index fac0859aa1..401fd0d326 100644 --- a/module/core/macro_tools/src/generic_params.rs +++ b/module/core/macro_tools/src/generic_params.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use crate::IterTrait; // use iter_tools::IterTrait; @@ -36,12 +37,15 @@ mod private impl GenericsWithWhere { /// Unwraps the `GenericsWithWhere` to retrieve the inner `syn::Generics`. + #[ must_use ] pub fn unwrap( self ) -> syn::Generics { self.generics } /// Parses a string to a `GenericsWithWhere`, specifically designed to handle generics syntax with where clauses effectively. + /// # Errors + /// qqq: doc pub fn parse_from_str( s : &str ) -> syn::Result< GenericsWithWhere > { syn::parse_str::< GenericsWithWhere >( s ) @@ -109,27 +113,29 @@ mod private /// # Examples /// /// - /// # use syn::{Generics, parse_quote}; + /// # use `syn::{Generics`, `parse_quote`}; /// - /// let mut generics_a : syn::Generics = parse_quote!{ < T : Clone, U : Default > }; - /// generics_a.where_clause = parse_quote!{ where T : Default }; - /// let mut generics_b : syn::Generics = parse_quote!{ < V : core::fmt::Debug > }; - /// generics_b.where_clause = parse_quote!{ where V : Sized }; - /// let got = generic_params::merge( &generics_a, &generics_b ); + /// let mut `generics_a` : `syn::Generics` = `parse_quote`!{ < T : Clone, U : Default > }; + /// `generics_a.where_clause` = `parse_quote`!{ where T : Default }; + /// let mut `generics_b` : `syn::Generics` = `parse_quote`!{ < V : `core::fmt::Debug` > }; + /// `generics_b.where_clause` = `parse_quote`!{ where V : Sized }; + /// let got = `generic_params::merge`( &`generics_a`, &`generics_b` ); /// - /// let mut exp : syn::Generics = parse_quote! + /// let mut exp : `syn::Generics` = `parse_quote`! /// { - /// < T : Clone, U : Default, V : core::fmt::Debug > + /// < T : Clone, U : Default, V : `core::fmt::Debug` > /// }; - /// exp.where_clause = parse_quote! + /// `exp.where_clause` = `parse_quote`! /// { /// where /// T : Default, /// V : Sized /// }; /// - /// assert_eq!( got, exp ); + /// `assert_eq`!( got, exp ); + #[ must_use ] + #[ allow( clippy::default_trait_access ) ] pub fn merge( a : &syn::Generics, b : &syn::Generics ) -> syn::Generics { @@ -205,6 +211,8 @@ mod private /// assert!( simplified_generics.where_clause.is_none() ); // Where clause is removed /// ``` + #[ allow( clippy::default_trait_access ) ] + #[ must_use ] pub fn only_names( generics : &syn::Generics ) -> syn::Generics { // use syn::{ Generics, GenericParam, LifetimeDef, TypeParam, ConstParam }; @@ -282,9 +290,9 @@ mod private /// &syn::Ident::new( "N", proc_macro2::Span::call_site() ) /// ]); /// ``` - - pub fn names< 'a >( generics : &'a syn::Generics ) - -> impl IterTrait< 'a, &'a syn::Ident > + #[ must_use ] + pub fn names( generics : &syn::Generics ) + -> impl IterTrait< '_, &syn::Ident > // -> std::iter::Map // < // syn::punctuated::Iter< 'a, syn::GenericParam >, @@ -388,6 +396,8 @@ mod private /// ``` /// + #[ allow( clippy::type_complexity ) ] + #[ must_use ] pub fn decompose ( generics : &syn::Generics, @@ -512,6 +522,7 @@ pub use own::*; /// Own namespace of the module. pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -530,6 +541,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; diff --git a/module/core/macro_tools/src/item.rs b/module/core/macro_tools/src/item.rs index d82f484847..45138346e9 100644 --- a/module/core/macro_tools/src/item.rs +++ b/module/core/macro_tools/src/item.rs @@ -6,6 +6,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Ensures the last field in a struct has a trailing comma. @@ -56,7 +57,7 @@ mod private /// } /// }.to_string() ); /// ``` - + #[ must_use ] pub fn ensure_comma( input : &syn::ItemStruct ) -> syn::ItemStruct { let mut new_input = input.clone(); // Clone the input to modify it @@ -66,16 +67,16 @@ mod private // Handle named fields syn::Fields::Named( syn::FieldsNamed { named, .. } ) => { - punctuated::ensure_trailing_comma( named ) + punctuated::ensure_trailing_comma( named ); }, // Handle unnamed fields (tuples) syn::Fields::Unnamed( syn::FieldsUnnamed { unnamed, .. } ) => { - punctuated::ensure_trailing_comma( unnamed ) + punctuated::ensure_trailing_comma( unnamed ); }, // Do nothing for unit structs syn::Fields::Unit => {} - } + }; new_input } @@ -90,6 +91,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -104,6 +106,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; diff --git a/module/core/macro_tools/src/item_struct.rs b/module/core/macro_tools/src/item_struct.rs index dd8f31f739..09f8f2c7a5 100644 --- a/module/core/macro_tools/src/item_struct.rs +++ b/module/core/macro_tools/src/item_struct.rs @@ -5,13 +5,15 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // use iter_tools::{ IterTrait, BoxedIter }; /// Extracts the types of each field into a vector. - pub fn field_types< 'a >( t : &'a syn::ItemStruct ) + #[ must_use ] + pub fn field_types( t : &syn::ItemStruct ) -> - impl IterTrait< 'a, &'a syn::Type > + impl IterTrait< '_, &syn::Type > // -> std::iter::Map // < // syn::punctuated::Iter< 'a, syn::Field >, @@ -22,7 +24,13 @@ mod private } /// Retrieves the names of each field, if they exist. - pub fn field_names< 'a >( t : &'a syn::ItemStruct ) -> Option< BoxedIter< 'a, &'a syn::Ident > > + /// # Errors + /// qqq: doc + /// # Panics + /// qqq: error + #[ allow( clippy::match_wildcard_for_single_variants ) ] + #[ must_use ] + pub fn field_names( t : &syn::ItemStruct ) -> Option< BoxedIter< '_, &syn::Ident > > { match &t.fields { @@ -35,6 +43,9 @@ mod private /// Retrieves the type of the first field of the struct. /// /// Returns the type if the struct has at least one field, otherwise returns an error. + /// # Errors + /// qqq + #[ allow( clippy::match_wildcard_for_single_variants ) ] pub fn first_field_type( t : &syn::ItemStruct ) -> Result< syn::Type > { let maybe_field = match t.fields @@ -49,13 +60,16 @@ mod private return Ok( field.ty.clone() ) } - return Err( syn_err!( t.span(), "Expects at least one field" ) ); + Err( syn_err!( t.span(), "Expects at least one field" ) ) } /// Retrieves the name of the first field of the struct, if available. /// /// Returns `Some` with the field identifier for named fields, or `None` for unnamed fields. /// Returns an error if the struct has no fields + /// # Errors + /// qqq: doc + #[ allow( clippy::match_wildcard_for_single_variants ) ] pub fn first_field_name( t : &syn::ItemStruct ) -> Result< Option< syn::Ident > > { let maybe_field = match t.fields @@ -70,7 +84,7 @@ mod private return Ok( field.ident.clone() ) } - return Err( syn_err!( t.span(), "Expects type for fields" ) ); + Err( syn_err!( t.span(), "Expects type for fields" ) ) } @@ -84,6 +98,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -101,6 +116,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -110,6 +126,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::item_struct; diff --git a/module/core/macro_tools/src/iter.rs b/module/core/macro_tools/src/iter.rs index 71bf438658..587750de8a 100644 --- a/module/core/macro_tools/src/iter.rs +++ b/module/core/macro_tools/src/iter.rs @@ -15,6 +15,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -27,6 +28,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -36,6 +38,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; // pub use super::super::iter; diff --git a/module/core/macro_tools/src/kw.rs b/module/core/macro_tools/src/kw.rs index 4a29a6879d..9ae3e2abf2 100644 --- a/module/core/macro_tools/src/kw.rs +++ b/module/core/macro_tools/src/kw.rs @@ -17,6 +17,7 @@ mod private // qqq : cover by test /// Check is string a keyword. + #[ must_use ] pub fn is( src : &str ) -> bool { KEYWORDS.contains( &src ) @@ -32,6 +33,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -41,6 +43,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -50,6 +53,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::kw; diff --git a/module/core/macro_tools/src/lib.rs b/module/core/macro_tools/src/lib.rs index 8f20b5d77b..c3a663cf22 100644 --- a/module/core/macro_tools/src/lib.rs +++ b/module/core/macro_tools/src/lib.rs @@ -8,13 +8,14 @@ #[ cfg( feature = "enabled" ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// - /// Result with syn::Error. + /// Result with `syn::Error`. /// - pub type Result< T > = std::result::Result< T, syn::Error >; + pub type Result< T > = core::result::Result< T, syn::Error >; } @@ -63,7 +64,7 @@ pub mod typ; #[ cfg( all( feature = "enabled", feature = "typed" ) ) ] pub mod typed; -#[ cfg( all( feature = "enabled" ) ) ] +#[ cfg( feature = "enabled" ) ] pub mod iter; /// @@ -98,6 +99,7 @@ pub mod own mod _all { + #[ allow( clippy::wildcard_imports ) ] use super::super::*; pub use orphan::*; @@ -167,6 +169,7 @@ pub mod orphan mod _all { + #[ allow( clippy::wildcard_imports ) ] use super::super::*; pub use exposed::*; } @@ -185,6 +188,7 @@ pub mod exposed mod _all { + #[ allow( clippy::wildcard_imports ) ] use super::super::*; pub use prelude::*; @@ -249,6 +253,7 @@ pub mod prelude mod _all { + #[ allow( clippy::wildcard_imports ) ] use super::super::*; // pub use prelude::*; diff --git a/module/core/macro_tools/src/name.rs b/module/core/macro_tools/src/name.rs index a5185ea8c4..ae70cba3f8 100644 --- a/module/core/macro_tools/src/name.rs +++ b/module/core/macro_tools/src/name.rs @@ -39,7 +39,7 @@ mod private syn::Item::Union( item ) => item.name(), // syn::Item::Use( item ) => item.name(), // syn::Item::Verbatim( item ) => item.name(), - _ => "".into(), + _ => String::new(), } } } @@ -51,7 +51,7 @@ mod private let first = self.segments.first(); if first.is_none() { - return "".into() + return String::new() } let first = first.unwrap(); first.ident.to_string() @@ -104,7 +104,7 @@ mod private { if self.trait_.is_none() { - return "".into() + return String::new() } let t = self.trait_.as_ref().unwrap(); t.1.name() @@ -117,7 +117,7 @@ mod private { if self.ident.is_none() { - return "".to_string() + return String::new() } let ident = self.ident.as_ref().unwrap(); ident.to_string() @@ -232,6 +232,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -241,6 +242,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -250,6 +252,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::name; @@ -263,6 +266,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] diff --git a/module/core/macro_tools/src/phantom.rs b/module/core/macro_tools/src/phantom.rs index 507a7fe0d1..4f52f3d5fa 100644 --- a/module/core/macro_tools/src/phantom.rs +++ b/module/core/macro_tools/src/phantom.rs @@ -7,6 +7,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Adds a `PhantomData` field to a struct to manage generic parameter usage. @@ -42,7 +43,8 @@ mod private /// // Output will include a _phantom field of type `PhantomData< ( T, U ) >` /// ``` /// - + #[ allow( clippy::default_trait_access, clippy::semicolon_if_nothing_returned ) ] + #[ must_use ] pub fn add_to_item( input : &syn::ItemStruct ) -> syn::ItemStruct { @@ -136,6 +138,8 @@ mod private /// // Output : ::core::marker::PhantomData< ( &'a (), *const T, N ) > /// ``` /// + #[ must_use ] + #[ allow( clippy::default_trait_access ) ] pub fn tuple( input : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma > ) -> syn::Type { use proc_macro2::Span; @@ -198,6 +202,7 @@ pub use own::*; /// Own namespace of the module. pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -214,6 +219,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; diff --git a/module/core/macro_tools/src/punctuated.rs b/module/core/macro_tools/src/punctuated.rs index 893e8459fb..a2c3fa0c8a 100644 --- a/module/core/macro_tools/src/punctuated.rs +++ b/module/core/macro_tools/src/punctuated.rs @@ -28,6 +28,7 @@ pub use own::*; /// Own namespace of the module. pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -43,6 +44,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; diff --git a/module/core/macro_tools/src/quantifier.rs b/module/core/macro_tools/src/quantifier.rs index a1c3cb7833..030074314a 100644 --- a/module/core/macro_tools/src/quantifier.rs +++ b/module/core/macro_tools/src/quantifier.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// @@ -105,11 +106,13 @@ mod private T : Element, { /// Constructor. + #[ must_use ] pub fn new() -> Self { Self( Vec::new() ) } /// Constructor. + #[ must_use ] pub fn new_with( src : Vec< T > ) -> Self { Self( src ) @@ -148,6 +151,7 @@ mod private T : quote::ToTokens, { type Item = T; + #[ allow( clippy::std_instead_of_alloc ) ] type IntoIter = std::vec::IntoIter< Self::Item >; fn into_iter( self ) -> Self::IntoIter { @@ -253,6 +257,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -262,6 +267,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -271,6 +277,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::quantifier; @@ -291,6 +298,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use private:: diff --git a/module/core/macro_tools/src/struct_like.rs b/module/core/macro_tools/src/struct_like.rs index 5b9652b506..321fbffee3 100644 --- a/module/core/macro_tools/src/struct_like.rs +++ b/module/core/macro_tools/src/struct_like.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Enum to encapsulate either a field from a struct or a variant from an enum. @@ -59,6 +60,7 @@ mod private { /// Returns a reference to the attributes of the item. + #[ must_use ] pub fn attrs( &self ) -> &Vec< syn::Attribute > { match self @@ -69,6 +71,7 @@ mod private } /// Returns a reference to the visibility of the item. + #[ must_use ] pub fn vis( &self ) -> Option< &syn::Visibility > { match self @@ -79,6 +82,7 @@ mod private } /// Returns a reference to the mutability of the item. + #[ must_use ] pub fn mutability( &self ) -> Option< &syn::FieldMutability > { match self @@ -89,6 +93,7 @@ mod private } /// Returns a reference to the identifier of the item. + #[ must_use] pub fn ident( &self ) -> Option< &syn::Ident > { match self @@ -99,6 +104,7 @@ mod private } /// Returns an iterator over elements of the item. + #[ must_use ] pub fn typ( &self ) -> Option< &syn::Type > { match self @@ -115,6 +121,7 @@ mod private } /// Returns a reference to the fields of the item. + #[ must_use ] pub fn fields( &self ) -> Option< &syn::Fields > { match self @@ -125,6 +132,7 @@ mod private } /// Returns a reference to the discriminant of the item. + #[ must_use ] pub fn discriminant( &self ) -> Option< &( syn::token::Eq, syn::Expr ) > { match self @@ -202,7 +210,7 @@ mod private // Parse ItemStruct let mut item_struct : ItemStruct = input.parse()?; item_struct.vis = visibility; - item_struct.attrs = attributes.into(); + item_struct.attrs = attributes; if item_struct.fields.is_empty() { Ok( StructLike::Unit( item_struct ) ) @@ -217,7 +225,7 @@ mod private // Parse ItemEnum let mut item_enum : ItemEnum = input.parse()?; item_enum.vis = visibility; - item_enum.attrs = attributes.into(); + item_enum.attrs = attributes; Ok( StructLike::Enum( item_enum ) ) } else @@ -274,14 +282,12 @@ mod private } /// Returns an iterator over elements of the item. + #[ must_use ] pub fn attrs( &self ) -> &Vec< syn::Attribute > { match self { - StructLike::Unit( item ) => - { - &item.attrs - }, + StructLike::Unit( item ) | StructLike::Struct( item ) => { &item.attrs @@ -294,14 +300,12 @@ mod private } /// Returns an iterator over elements of the item. + #[ must_use ] pub fn vis( &self ) -> &syn::Visibility { match self { - StructLike::Unit( item ) => - { - &item.vis - }, + StructLike::Unit( item ) | StructLike::Struct( item ) => { &item.vis @@ -314,14 +318,12 @@ mod private } /// Returns an iterator over elements of the item. + #[ must_use ] pub fn ident( &self ) -> &syn::Ident { match self { - StructLike::Unit( item ) => - { - &item.ident - }, + StructLike::Unit( item ) | StructLike::Struct( item ) => { &item.ident @@ -334,14 +336,12 @@ mod private } /// Returns an iterator over elements of the item. + #[ must_use ] pub fn generics( &self ) -> &syn::Generics { match self { - StructLike::Unit( item ) => - { - &item.generics - }, + StructLike::Unit( item ) | StructLike::Struct( item ) => { &item.generics @@ -355,13 +355,14 @@ mod private /// Returns an iterator over fields of the item. // pub fn fields< 'a >( &'a self ) -> impl IterTrait< 'a, &'a syn::Field > + #[ must_use ] pub fn fields< 'a >( &'a self ) -> BoxedIter< 'a, &'a syn::Field > { let result : BoxedIter< 'a, &'a syn::Field > = match self { StructLike::Unit( _item ) => { - Box::new( std::iter::empty() ) + Box::new( core::iter::empty() ) }, StructLike::Struct( item ) => { @@ -369,22 +370,22 @@ mod private }, StructLike::Enum( _item ) => { - Box::new( std::iter::empty() ) + Box::new( core::iter::empty() ) }, }; result } /// Extracts the name of each field. + /// # Panics + /// qqq: docs // pub fn field_names< 'a >( &'a self ) -> Option< impl IterTrait< 'a, &'a syn::Ident > + '_ > - pub fn field_names< 'a >( &'a self ) -> Option< BoxedIter< 'a, &'a syn::Ident >> + #[ must_use ] + pub fn field_names( &self ) -> Option< BoxedIter< '_, &syn::Ident >> { match self { - StructLike::Unit( item ) => - { - item_struct::field_names( item ) - }, + StructLike::Unit( item ) | StructLike::Struct( item ) => { item_struct::field_names( item ) @@ -398,8 +399,9 @@ mod private } /// Extracts the type of each field. - pub fn field_types<'a>( &'a self ) - -> BoxedIter< 'a, &'a syn::Type > + #[ must_use ] + pub fn field_types( & self ) + -> BoxedIter< '_, & syn::Type > // -> std::iter::Map // < // std::boxed::Box< dyn _IterTrait< '_, &syn::Field > + 'a >, @@ -411,8 +413,9 @@ mod private /// Extracts the name of each field. // pub fn field_attrs< 'a >( &'a self ) -> impl IterTrait< 'a, &'a Vec< syn::Attribute > > - pub fn field_attrs<'a>( &'a self ) - -> BoxedIter< 'a, &'a Vec< syn::Attribute > > + #[ must_use ] + pub fn field_attrs( & self ) + -> BoxedIter< '_, &Vec< syn::Attribute > > // -> std::iter::Map // < // std::boxed::Box< dyn _IterTrait< '_, &syn::Field > + 'a >, @@ -423,6 +426,7 @@ mod private } /// Extract the first field. + #[ must_use ] pub fn first_field( &self ) -> Option< &syn::Field > { self.fields().next() @@ -443,6 +447,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -458,6 +463,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -467,6 +473,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::struct_like; diff --git a/module/core/macro_tools/src/tokens.rs b/module/core/macro_tools/src/tokens.rs index 4785c8dfc8..cfb52da63f 100644 --- a/module/core/macro_tools/src/tokens.rs +++ b/module/core/macro_tools/src/tokens.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use core::fmt; @@ -32,6 +33,7 @@ mod private impl Tokens { /// Constructor from `proc_macro2::TokenStream`. + #[ must_use ] pub fn new( inner : proc_macro2::TokenStream ) -> Self { Tokens { inner } @@ -59,7 +61,7 @@ mod private { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { - write!( f, "{}", self.inner.to_string() ) + write!( f, "{}", self.inner ) } } @@ -67,7 +69,7 @@ mod private { fn fmt( &self, f : &mut core::fmt::Formatter< '_ > ) -> core::fmt::Result { - write!( f, "{}", self.inner.to_string() ) + write!( f, "{}", self.inner ) } } @@ -81,6 +83,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -90,6 +93,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -99,6 +103,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::tokens; diff --git a/module/core/macro_tools/src/typ.rs b/module/core/macro_tools/src/typ.rs index 1c1f0e39e5..3a2e710808 100644 --- a/module/core/macro_tools/src/typ.rs +++ b/module/core/macro_tools/src/typ.rs @@ -5,6 +5,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use interval_adapter::BoundExt; @@ -22,7 +23,9 @@ mod private /// let got = typ::type_rightmost( &tree_type ); /// assert_eq!( got, Some( "Option".to_string() ) ); /// ``` - + /// # Panics + /// qqq: doc + #[ must_use ] pub fn type_rightmost( ty : &syn::Type ) -> Option< String > { if let syn::Type::Path( path ) = ty @@ -53,8 +56,10 @@ mod private /// // < i16 /// // < i32 /// ``` - - pub fn type_parameters( ty : &syn::Type, range : impl NonIterableInterval ) -> Vec< &syn::Type > + /// # Panics + /// qqq: doc + #[ allow( clippy::cast_possible_wrap ) ] + pub fn type_parameters< 'a >( ty : &'a syn::Type, range : &'a impl NonIterableInterval ) -> Vec< &'a syn::Type > { if let syn::Type::Path( syn::TypePath{ path : syn::Path { ref segments, .. }, .. } ) = ty { @@ -104,7 +109,7 @@ mod private /// assert!( macro_tools::typ::is_optional( &parsed_type ) ); /// ``` /// - + #[ must_use ] pub fn is_optional( ty : &syn::Type ) -> bool { typ::type_rightmost( ty ) == Some( "Option".to_string() ) @@ -124,10 +129,11 @@ mod private /// let first_param = macro_tools::typ::parameter_first( &parsed_type ).expect( "Should have at least one parameter" ); /// // Option< i32 > /// ``` - + /// # Errors + /// qqq: docs pub fn parameter_first( ty : &syn::Type ) -> Result< &syn::Type > { - typ::type_parameters( ty, 0 ..= 0 ) + typ::type_parameters( ty, &( 0 ..= 0 ) ) .first() .copied() .ok_or_else( || syn_err!( ty, "Expects at least one parameter here:\n {}", qt!{ #ty } ) ) @@ -143,6 +149,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -160,6 +167,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -169,6 +177,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::typ; diff --git a/module/core/macro_tools/src/typed.rs b/module/core/macro_tools/src/typed.rs index 5e75476fb1..c5d2d05c3c 100644 --- a/module/core/macro_tools/src/typed.rs +++ b/module/core/macro_tools/src/typed.rs @@ -17,6 +17,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] @@ -35,6 +36,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -44,6 +46,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::super::typed; diff --git a/module/core/mod_interface/Readme.md b/module/core/mod_interface/Readme.md index 0bb7e9b255..53e887fdd3 100644 --- a/module/core/mod_interface/Readme.md +++ b/module/core/mod_interface/Readme.md @@ -1,6 +1,6 @@ -# Module :: mod_interface +# Module :: `mod_interface` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml) [![docs.rs](https://img.shields.io/docsrs/mod_interface?color=e3e8f0&logo=docs.rs)](https://docs.rs/mod_interface) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) @@ -92,7 +92,8 @@ crate::mod_interface! use super::child; } -fn main() + +// fn main() { assert!( child::prelude_thing(), "prelude thing of child is there" ); @@ -195,7 +196,7 @@ pub mod own { use super::*; pub use orphan::*; - pub use child::orphan::*; + pub use super::child::orphan::*; pub use super::child; } @@ -226,7 +227,7 @@ pub mod prelude // -fn main() +// fn main() { assert!( child::prelude_thing(), "prelude thing of child is there" ); @@ -263,41 +264,6 @@ fn main() -As you can see: - -- The content of the `prelude` chapter is automatically propagated into the `exposed` chapter of the same layer. -- The content of the `exposed` chapter is automatically propagated into the `orphan` chapter of the same layer. -- The content of the `orphan` chapter is automatically propagated into the `own` chapter of the same layer. -- The content of the `own` chapter is not automatically propagated anywhere. - -### `layer ` vs `use ` - -The `use ;` syntax is used to import a layer from anywhere within the project or even from external crates. This provides flexibility in how layers are organized, as the layer being used does not need to be a direct submodule of the current module. It allows you to bring any accessible layer into the current scope without enforcing a specific file structure. The visibility of the imported layer remains as it is defined in its original location, and this syntax does not inherently change that visibility. - -In contrast, the `layer ` syntax is used to establish a hierarchical relationship where the current module uses a child layer. This requires the child layer to be a direct submodule, meaning it must be physically present in the file structure as a submodule. The `layer ` syntax implies `pub mod layer1`, making the child layer publicly accessible as a submodule. This enforces a specific organizational structure, where the child layer is part of the current module's hierarchy, and its contents are directly accessible according to the defined propagation strategies. - -Thus, `layer ` acts as a shortcut, combining the definition of a reference to a module file and using it, while `use ` uses a module that is already defined somewhere, not necessarily in the same crate. - -### `reuse ` vs `use ` - -The `reuse ` syntax treats the child layer as an integral part of the parent layer, so the normal rules of propagation do not apply to the content of the child layer. Specifically, the `own` chapter of the child layer is imported into the `own` chapter of the parent layer, and the `orphan` chapter of the child layer is imported into the `orphan` chapter of the parent layer. - -In contrast, `use ` follows the standard propagation rules: - -- `child::own` is not propagated. -- `child::orphan` is imported into `parent::own`. -- `child::exposed` is imported into `parent::exposed`. -- `child::prelude` is imported into `parent::prelude`. - -For `reuse `, the propagation is as follows: - -- `child::own` is imported into `parent::own`. -- `child::orphan` is imported into `parent::orphan`. -- `child::exposed` is imported into `parent::exposed`. -- `child::prelude` is imported into `parent::prelude`. - -`reusing` does not impact parent of parent or child of child. - ### Debugging To debug module interface use directive `#![ debug ]` in macro `mod_interface`. Let's update the main file of the example : diff --git a/module/core/mod_interface/src/lib.rs b/module/core/mod_interface/src/lib.rs index 726b166188..07820b8983 100644 --- a/module/core/mod_interface/src/lib.rs +++ b/module/core/mod_interface/src/lib.rs @@ -22,6 +22,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use orphan::*; @@ -37,6 +38,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use exposed::*; @@ -47,6 +49,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; #[ doc( inline ) ] pub use prelude::*; diff --git a/module/core/mod_interface_meta/Readme.md b/module/core/mod_interface_meta/Readme.md index d9b2a9bd8b..d953c21eca 100644 --- a/module/core/mod_interface_meta/Readme.md +++ b/module/core/mod_interface_meta/Readme.md @@ -1,11 +1,11 @@ -# Module :: mod_interface_meta +# Module :: `mod_interface_meta` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml) [![docs.rs](https://img.shields.io/docsrs/mod_interface_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/mod_interface_meta) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) Protocol of modularity unifying interface of a module and introducing layers. -Not intended to be used without runtime. This module and runtime is aggregate in module::mod_interface is [here](https://github.com/Wandalen/wTools/tree/master/module/core/mod_interface). -module and runtime is aggregate in module::mod_interface is [here](https://github.com/Wandalen/wTools/tree/master/module/core/mod_interface). +Not intended to be used without runtime. This module and runtime is aggregate in `module::mod_interface` is [here](https://github.com/Wandalen/wTools/tree/master/module/core/mod_interface). +module and runtime is aggregate in `module::mod_interface` is [here](https://github.com/Wandalen/wTools/tree/master/module/core/mod_interface). diff --git a/module/core/mod_interface_meta/src/impls.rs b/module/core/mod_interface_meta/src/impls.rs index 81c6cec066..cdac53e906 100644 --- a/module/core/mod_interface_meta/src/impls.rs +++ b/module/core/mod_interface_meta/src/impls.rs @@ -1,7 +1,9 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; + #[ allow( clippy::wildcard_imports ) ] use macro_tools::exposed::*; use std::collections::HashMap; @@ -409,9 +411,10 @@ mod private /// /// Protocol of modularity unifying interface of a module and introducing layers. /// - #[ allow ( dead_code ) ] + #[ allow ( dead_code, clippy::too_many_lines ) ] pub fn mod_interface( input : proc_macro::TokenStream ) -> syn::Result< proc_macro2::TokenStream > { + #[ allow( clippy::enum_glob_use ) ] use ElementType::*; let original_input = input.clone(); @@ -583,7 +586,7 @@ mod private if has_debug { - let about = format!( "derive : mod_interface" ); + let about = "derive : mod_interface"; diag::report_print( about, &original_input, &result ); } @@ -601,6 +604,7 @@ mod private #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; } @@ -611,6 +615,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } @@ -619,6 +624,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use prelude::*; pub use private:: @@ -630,6 +636,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use private:: { diff --git a/module/core/mod_interface_meta/src/lib.rs b/module/core/mod_interface_meta/src/lib.rs index 70dc68878e..f077e63508 100644 --- a/module/core/mod_interface_meta/src/lib.rs +++ b/module/core/mod_interface_meta/src/lib.rs @@ -93,10 +93,13 @@ mod impls; #[ allow( unused_imports ) ] use impls::exposed::*; mod record; +#[ allow( clippy::wildcard_imports ) ] use record::exposed::*; mod visibility; +#[ allow( clippy::wildcard_imports ) ] use visibility::exposed::*; mod use_tree; +#[ allow( clippy::wildcard_imports ) ] use use_tree::exposed::*; /// diff --git a/module/core/mod_interface_meta/src/record.rs b/module/core/mod_interface_meta/src/record.rs index aeb6a696eb..24b773be10 100644 --- a/module/core/mod_interface_meta/src/record.rs +++ b/module/core/mod_interface_meta/src/record.rs @@ -1,7 +1,9 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; + #[ allow( clippy::wildcard_imports ) ] use macro_tools::exposed::*; /// @@ -69,6 +71,7 @@ mod private { fn to_tokens( &self, tokens : &mut proc_macro2::TokenStream ) { + #[ allow( clippy::enum_glob_use ) ] use ElementType::*; match self { @@ -128,7 +131,7 @@ mod private { let ident = input.parse()?; elements = syn::punctuated::Punctuated::new(); - elements.push( Pair::new( Default::default(), ident ) ); + elements.push( Pair::new( AttributesOuter::default(), ident ) ); } }, } @@ -201,8 +204,7 @@ mod private // code_print!( attr.path() ); // code_print!( attr.meta ); - let good = true - && code_to_str!( attr.path() ) == "debug" + let good = code_to_str!( attr.path() ) == "debug" // && code_to_str!( attr.meta ).is_empty() ; @@ -268,6 +270,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; } @@ -276,6 +279,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } @@ -284,6 +288,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use prelude::*; pub use private:: @@ -299,6 +304,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use private:: { diff --git a/module/core/mod_interface_meta/src/use_tree.rs b/module/core/mod_interface_meta/src/use_tree.rs index 3f51fccc22..48e1e5bb81 100644 --- a/module/core/mod_interface_meta/src/use_tree.rs +++ b/module/core/mod_interface_meta/src/use_tree.rs @@ -26,6 +26,7 @@ mod private /// Add `super::private::` to path unless it starts from `::` or `super` or `crate`. pub fn private_prefix_is_needed( &self ) -> bool { + #[ allow( clippy::wildcard_imports, clippy::enum_glob_use ) ] use syn::UseTree::*; // println!( "private_prefix_is_needed : {:?}", self ); @@ -46,6 +47,7 @@ mod private /// Get pure path, cutting off `as module2` from `use module1 as module2`. pub fn pure_path( &self ) -> syn::Result< syn::punctuated::Punctuated< syn::Ident, Token![::] > > { + #[ allow( clippy::wildcard_imports, clippy::enum_glob_use ) ] use syn::UseTree::*; // let leading_colon = None; @@ -92,11 +94,11 @@ mod private pub fn pure_without_super_path( &self ) -> syn::Result< syn::punctuated::Punctuated< syn::Ident, Token![::] > > { let path = self.pure_path()?; - if path.len() < 1 + if path.is_empty() { return Ok( path ); } - if path[ 0 ].to_string() == "super" + if path[ 0 ] == "super" { // let mut path2 = syn::punctuated::Punctuated::< syn::Ident, Token![::] >::new(); let path2 : syn::punctuated::Punctuated< syn::Ident, Token![::] > = path.into_iter().skip(1).collect(); @@ -149,6 +151,7 @@ mod private { fn parse( input : ParseStream< '_ > ) -> syn::Result< Self > { + #[ allow( clippy::wildcard_imports, clippy::enum_glob_use ) ] use syn::UseTree::*; let leading_colon = input.parse()?; let tree = input.parse()?; @@ -216,6 +219,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; } @@ -224,6 +228,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } @@ -232,6 +237,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use prelude::*; diff --git a/module/core/mod_interface_meta/src/visibility.rs b/module/core/mod_interface_meta/src/visibility.rs index 4e229ed21c..747b2a2da5 100644 --- a/module/core/mod_interface_meta/src/visibility.rs +++ b/module/core/mod_interface_meta/src/visibility.rs @@ -13,6 +13,7 @@ mod private pub mod kw { + #[ allow( clippy::wildcard_imports ) ] use super::*; // syn::custom_keyword!( private ); syn::custom_keyword!( own ); @@ -425,7 +426,7 @@ mod private Visibility::Orphan( e ) => e.restriction(), Visibility::Exposed( e ) => e.restriction(), Visibility::Prelude( e ) => e.restriction(), - Visibility::Public( _ ) => None, + Visibility::Public( _ ) | // Visibility::Restricted( e ) => e.restriction(), Visibility::Inherited => None, } @@ -485,12 +486,12 @@ mod private } } - #[ allow( clippy::derive_hash_xor_eq ) ] + #[ allow( clippy::derived_hash_with_manual_eq ) ] impl Hash for Visibility { fn hash< H : Hasher >( &self, state : &mut H ) { - self.kind().hash( state ) + self.kind().hash( state ); } } @@ -520,6 +521,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; } @@ -528,6 +530,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } @@ -536,6 +539,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use prelude::*; diff --git a/module/core/process_tools/Readme.md b/module/core/process_tools/Readme.md index 97f7c673ea..86fb5c3d6d 100644 --- a/module/core/process_tools/Readme.md +++ b/module/core/process_tools/Readme.md @@ -1,6 +1,6 @@ -# Module :: process_tools +# Module :: `process_tools` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/process_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/process_tools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) diff --git a/module/core/process_tools/src/environment.rs b/module/core/process_tools/src/environment.rs index 31d20aa9f0..485b2b6092 100644 --- a/module/core/process_tools/src/environment.rs +++ b/module/core/process_tools/src/environment.rs @@ -6,7 +6,7 @@ mod private /// /// This function looks for environment variables that are commonly set by CI/CD systems to determine if it's running /// within such an environment. It supports detection for a variety of popular CI/CD platforms including GitHub Actions, - /// GitLab CI, Travis CI, CircleCI, and Jenkins. + /// GitLab CI, Travis CI, `CircleCI`, and Jenkins. /// /// # Returns /// - `true` if an environment variable indicating a CI/CD environment is found. @@ -29,10 +29,11 @@ mod private /// ``` #[ cfg( feature = "process_environment_is_cicd" ) ] + #[ must_use ] pub fn is_cicd() -> bool { use std::env; - let ci_vars = vec! + let ci_vars = [ "CI", // Common in many CI systems "GITHUB_ACTIONS", // GitHub Actions diff --git a/module/core/process_tools/src/process.rs b/module/core/process_tools/src/process.rs index d58e95455a..d0637d805a 100644 --- a/module/core/process_tools/src/process.rs +++ b/module/core/process_tools/src/process.rs @@ -1,4 +1,5 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { // use crate::*; @@ -73,17 +74,20 @@ mod private /// Executes an external process in a specified directory without using a shell. /// /// # Arguments: - /// - `bin_path`: Path to the executable bin_path. - /// - `args`: Command-line arguments for the bin_path. - /// - `current_path`: Directory current_path to run the bin_path in. + /// - `bin_path`: Path to the executable `bin_path`. + /// - `args`: Command-line arguments for the `bin_path`. + /// - `current_path`: Directory `current_path` to run the `bin_path` in. /// /// # Returns: /// A `Result` containing `Report` on success, detailing execution output, /// or an error message on failure. /// - /// # Errors: + /// # Errors /// Returns an error if the process fails to spawn, complete, or if output /// cannot be decoded as UTF-8. + /// + /// # Panics + /// qqq: doc // // qqq : for Petro : use typed error // qqq : for Petro : write example @@ -131,7 +135,7 @@ mod private .context( "failed to spawn process" ) .map_err( | e | { - report.error = Err( e.into() ); + report.error = Err( e ); Err::< (), () >( () ) }); @@ -141,16 +145,14 @@ mod private } let child = child.unwrap(); - let output = child + child .wait_with_output() .context( "failed to wait on child" ) .map_err( | e | { - report.error = Err( e.into() ); + report.error = Err( e ); Err::< (), () >( () ) - }); - - output + }) }; if report.error.is_err() @@ -163,7 +165,7 @@ mod private .context( "Found invalid UTF-8" ) .map_err( | e | { - report.error = Err( e.into() ); + report.error = Err( e ); Err::< (), () >( () ) }); @@ -179,7 +181,7 @@ mod private .context( "Found invalid UTF-8" ) .map_err( | e | { - report.error = Err( e.into() ); + report.error = Err( e ); Err::< (), () >( () ) }); @@ -290,10 +292,10 @@ mod private { Report { - command : Default::default(), + command : String::default(), current_path : PathBuf::new(), - out : Default::default(), - err : Default::default(), + out : String::default(), + err : String::default(), error : Ok( () ), } } diff --git a/module/core/pth/Readme.md b/module/core/pth/Readme.md index a6f4c2f04d..9479a502d6 100644 --- a/module/core/pth/Readme.md +++ b/module/core/pth/Readme.md @@ -11,7 +11,7 @@ All functions in the crate don't touch file system, but only process paths. ### Type `AbsolutePath` -The AbsolutePath type ensures that paths are absolute, which helps reduce issues and maintenance costs associated with relative paths. Relative paths can be problematic as they introduce additional variables and complexities, making code analysis, integration, refactoring, and testing more difficult. By using absolute paths, software architecture can be improved, similar to how avoiding global variables can enhance code quality. It is recommended to use relative paths only at the outskirts of an application. +The `AbsolutePath` type ensures that paths are absolute, which helps reduce issues and maintenance costs associated with relative paths. Relative paths can be problematic as they introduce additional variables and complexities, making code analysis, integration, refactoring, and testing more difficult. By using absolute paths, software architecture can be improved, similar to how avoiding global variables can enhance code quality. It is recommended to use relative paths only at the outskirts of an application. ### Trait `AsPath` @@ -19,11 +19,11 @@ This trait is used to avoid redundant allocation of memory by providing a refere ### Trait `TryIntoPath` -This trait is used to convert any path-like type into an owned PathBuf. Unlike `TryIntoCowPath`, it always returns an owned PathBuf, so there is no need to differentiate between borrowed and owned paths at runtime. Unlike `AsPath`, it is implemented for a wider range of path-like types, similar to `TryIntoCowPath`. +This trait is used to convert any path-like type into an owned `PathBuf`. Unlike `TryIntoCowPath`, it always returns an owned `PathBuf`, so there is no need to differentiate between borrowed and owned paths at runtime. Unlike `AsPath`, it is implemented for a wider range of path-like types, similar to `TryIntoCowPath`. ### Trait `TryIntoCowPath` -This trait is designed to avoid redundant memory allocation. Unlike TryIntoPath, it does not allocate memory on the heap if it’s not necessary. Unlike `AsPath`, it is implemented for a wider number of path-like types, similar to TryIntoPath. The drawback is the necessity to differentiate borrowed and owned paths at runtime. +This trait is designed to avoid redundant memory allocation. Unlike `TryIntoPath`, it does not allocate memory on the heap if it’s not necessary. Unlike `AsPath`, it is implemented for a wider number of path-like types, similar to `TryIntoPath`. The drawback is the necessity to differentiate borrowed and owned paths at runtime. -# Module :: strs_tools +# Module :: `strs_tools` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/strs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/strs_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fstrs_tools%2Fexamples%2Fstrs_tools_trivial.rs,RUN_POSTFIX=--example%20strs_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) diff --git a/module/core/strs_tools/src/lib.rs b/module/core/strs_tools/src/lib.rs index 72ff01c34c..b3858c911f 100644 --- a/module/core/strs_tools/src/lib.rs +++ b/module/core/strs_tools/src/lib.rs @@ -18,6 +18,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; pub use super::string::orphan::*; @@ -28,6 +29,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } diff --git a/module/core/strs_tools/src/string/indentation.rs b/module/core/strs_tools/src/string/indentation.rs index 59c29951eb..8e71ccbcfb 100644 --- a/module/core/strs_tools/src/string/indentation.rs +++ b/module/core/strs_tools/src/string/indentation.rs @@ -57,17 +57,17 @@ mod private { if b.0 > 0 { - a.push_str( "\n" ); + a.push( '\n' ); } a.push_str( prefix ); - a.push_str( &b.1 ); + a.push_str( b.1 ); a.push_str( postfix ); a }); - if src.ends_with( "\n" ) || src.ends_with( "\n\r" ) || src.ends_with( "\r\n" ) + if src.ends_with( '\n' ) || src.ends_with( "\n\r" ) || src.ends_with( "\r\n" ) { - result.push_str( "\n" ); + result.push( '\n' ); result.push_str( prefix ); result.push_str( postfix ); } @@ -85,6 +85,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; pub use private:: @@ -96,6 +97,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; pub use private:: @@ -107,6 +109,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::own as indentation; diff --git a/module/core/strs_tools/src/string/isolate.rs b/module/core/strs_tools/src/string/isolate.rs index 50ba7fe294..34e9af9449 100644 --- a/module/core/strs_tools/src/string/isolate.rs +++ b/module/core/strs_tools/src/string/isolate.rs @@ -26,7 +26,7 @@ mod private } /// - /// Adapter for IsolateOptions. + /// Adapter for `IsolateOptions`. /// pub trait IsolateOptionsAdapter< 'a > @@ -144,6 +144,7 @@ mod private /// It produces former. To convert former into options and run algorithm of splitting call `perform()`. /// + #[ must_use ] pub fn isolate<'a>() -> IsolateOptionsFormer<'a> { IsolateOptions::former() @@ -155,6 +156,7 @@ mod private /// It produces former. To convert former into options and run algorithm of splitting call `perform()`. /// + #[ must_use ] pub fn isolate_left<'a>() -> IsolateOptionsFormer<'a> { IsolateOptions::former() @@ -167,6 +169,7 @@ mod private /// It produces former. To convert former into options and run algorithm of splitting call `perform()`. /// + #[ must_use ] pub fn isolate_right<'a>() -> IsolateOptionsFormer<'a> { IsolateOptions::former() @@ -194,6 +197,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } diff --git a/module/core/strs_tools/src/string/mod.rs b/module/core/strs_tools/src/string/mod.rs index 46552b8124..d473f9eeef 100644 --- a/module/core/strs_tools/src/string/mod.rs +++ b/module/core/strs_tools/src/string/mod.rs @@ -33,7 +33,9 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; + #[ allow( clippy::wildcard_imports ) ] pub use orphan::*; #[ cfg( all( feature = "string_indentation", not( feature = "no_std" ) ) ) ] pub use super::indentation::orphan::*; @@ -52,6 +54,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } diff --git a/module/core/strs_tools/src/string/number.rs b/module/core/strs_tools/src/string/number.rs index 1a0df1c3ad..fac6b4664d 100644 --- a/module/core/strs_tools/src/string/number.rs +++ b/module/core/strs_tools/src/string/number.rs @@ -11,14 +11,15 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; pub use private:: { }; - #[ cfg( all( feature = "string_parse_number" ) ) ] + #[ cfg( feature = "string_parse_number" ) ] #[ doc( inline ) ] - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] pub use lexical::*; } @@ -26,6 +27,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; pub use private:: @@ -37,6 +39,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::own as number; diff --git a/module/core/strs_tools/src/string/parse_request.rs b/module/core/strs_tools/src/string/parse_request.rs index 44e215d15d..e926b4a4cf 100644 --- a/module/core/strs_tools/src/string/parse_request.rs +++ b/module/core/strs_tools/src/string/parse_request.rs @@ -1,7 +1,9 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; + #[ allow( clippy::wildcard_imports ) ] use string:: { split::*, @@ -48,6 +50,7 @@ mod private } } + #[ allow( clippy::from_over_into ) ] impl< T > Into > for OpType< T > { fn into( self ) -> Vec< T > @@ -62,8 +65,11 @@ mod private impl OpType< T > { - /// Append item of OpType to current value. If current type is `Primitive`, then it will be converted to + /// Append item of `OpType` to current value. If current type is `Primitive`, then it will be converted to /// `Vector`. + /// # Panics + /// qqq: doc + #[ must_use ] pub fn append( mut self, item : OpType< T > ) -> OpType< T > { let mut mut_item = item; @@ -156,6 +162,7 @@ mod private /// Options for parser. /// + #[ allow( clippy::struct_excessive_bools ) ] #[ derive( Debug, former::Former ) ] #[ perform( fn parse( mut self ) -> Request< 'a > ) ] pub struct ParseOptions< 'a > @@ -179,7 +186,7 @@ mod private } /// - /// Adapter for ParseOptions. + /// Adapter for `ParseOptions`. /// pub trait ParseOptionsAdapter< 'a > @@ -245,6 +252,7 @@ mod private self.subject_win_paths_maybe } + #[ allow( clippy::assigning_clones, clippy::too_many_lines, clippy::collapsible_if ) ] fn parse( mut self ) -> Request< 'a > where Self : Sized, @@ -474,6 +482,7 @@ mod private /// It produces former. To convert former into options and run algorithm of splitting call `perform()`. /// + #[ must_use ] pub fn request_parse<'a>() -> ParseOptionsFormer<'a> { ParseOptions::former() @@ -488,6 +497,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; pub use private:: @@ -504,6 +514,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } @@ -512,6 +523,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::own as parse_request; @@ -526,6 +538,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use private::ParseOptionsAdapter; } diff --git a/module/core/strs_tools/src/string/split.rs b/module/core/strs_tools/src/string/split.rs index 5c9eac10cd..6744e6a020 100644 --- a/module/core/strs_tools/src/string/split.rs +++ b/module/core/strs_tools/src/string/split.rs @@ -72,7 +72,7 @@ mod private { if let Some( x ) = src.find( pat ) { - r.push( ( x, x + pat.len() ) ) + r.push( ( x, x + pat.len() ) ); } } @@ -116,7 +116,7 @@ mod private impl< 'a, D : Searcher + Clone > SplitFastIterator< 'a, D > { - #[ allow( dead_code ) ] + #[ allow( dead_code, clippy::needless_pass_by_value ) ] fn new( o : impl SplitOptionsAdapter< 'a, D > ) -> Self { Self @@ -154,12 +154,10 @@ mod private { return None; } - else - { - self.counter -= 1; - self.stop_empty = true; - return Some( Split { string : "", typ : SplitType::Delimeted } ); - } + + self.counter -= 1; + self.stop_empty = true; + return Some( Split { string : "", typ : SplitType::Delimeted } ); } if start == 0 && end != 0 @@ -170,7 +168,7 @@ mod private let mut next = &self.iterable[ ..start ]; if start == end && self.counter >= 3 { - next = &self.iterable[ ..start + 1 ]; + next = &self.iterable[ ..=start ]; start += 1; } @@ -229,6 +227,7 @@ mod private /// #[ derive( Debug ) ] + #[ allow( clippy::struct_excessive_bools ) ] pub struct SplitIterator< 'a > { iterator : SplitFastIterator< 'a, Vec< &'a str > >, @@ -247,6 +246,7 @@ mod private impl< 'a > SplitIterator< 'a > { + #[ allow( clippy::needless_pass_by_value ) ] fn new( o : impl SplitOptionsAdapter< 'a, Vec< &'a str > > ) -> Self { let iterator; @@ -338,10 +338,7 @@ mod private { return self.next(); } - else - { - return Some( split ); - } + return Some( split ); }, None => { @@ -405,6 +402,7 @@ mod private /// #[ derive( Debug ) ] + #[ allow( clippy::struct_excessive_bools ) ] pub struct SplitOptions< 'a, D > where D : Searcher + Default + Clone, @@ -422,7 +420,8 @@ mod private impl< 'a > SplitOptions< 'a, Vec< &'a str > > { - /// Produces SplitIterator. + /// Produces `SplitIterator`. + #[ must_use ] pub fn split( self ) -> SplitIterator< 'a > where Self : Sized, @@ -435,7 +434,7 @@ mod private where D : Searcher + Default + Clone { - /// Produces SplitFastIterator. + /// Produces `SplitFastIterator`. pub fn split_fast( self ) -> SplitFastIterator< 'a, D > where Self : Sized, @@ -561,9 +560,10 @@ mod private } /// - /// Former for SplitOptions. + /// Former for `SplitOptions`. /// + #[ allow( clippy::struct_excessive_bools ) ] #[ derive( Debug ) ] pub struct SplitOptionsFormer< 'a > { @@ -637,6 +637,7 @@ mod private /// .perform(); /// ``` + #[ must_use ] pub fn split< 'a >() -> SplitOptionsFormer< 'a > { SplitOptionsFormer::new( < &str >::default() ) @@ -651,6 +652,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use orphan::*; pub use private:: @@ -668,6 +670,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use exposed::*; } @@ -676,6 +679,7 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use super::own as split; @@ -690,6 +694,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { + #[ allow( clippy::wildcard_imports ) ] use super::*; pub use private::SplitOptionsAdapter; } diff --git a/module/move/crates_tools/Readme.md b/module/move/crates_tools/Readme.md index dabc50fb6c..f407d2599e 100644 --- a/module/move/crates_tools/Readme.md +++ b/module/move/crates_tools/Readme.md @@ -1,6 +1,6 @@ -# Module :: crates_tools +# Module :: `crates_tools` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_crates_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_crates_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/crates_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/crates_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fmove%2Fcrates_tools%2Fexamples%2Fcrates_tools_trivial.rs,RUN_POSTFIX=--example%20crates_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) @@ -25,7 +25,6 @@ Some possible use cases are: ```rust use crates_tools::*; -fn main() { #[ cfg( feature = "enabled" ) ] { diff --git a/module/move/crates_tools/src/lib.rs b/module/move/crates_tools/src/lib.rs index f43c975b7f..1d60bb2135 100644 --- a/module/move/crates_tools/src/lib.rs +++ b/module/move/crates_tools/src/lib.rs @@ -8,19 +8,21 @@ mod private { use std::collections::HashMap; - use std::fmt::Formatter; + use core::fmt::Formatter; use std::io::Read; use std::path::{ Path, PathBuf }; - use std::time::Duration; - use ureq::{ Agent, AgentBuilder }; + use core::time::Duration; + use ureq::AgentBuilder; /// Represents a `.crate` archive, which is a collection of files and their contents. #[ derive( Default, Clone, PartialEq ) ] pub struct CrateArchive( HashMap< PathBuf, Vec< u8 > > ); - impl std::fmt::Debug for CrateArchive + impl core::fmt::Debug for CrateArchive { - fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result + #[ allow( clippy::implicit_return, clippy::min_ident_chars ) ] + #[ inline] + fn fmt( &self, f : &mut Formatter< '_ > ) -> core::fmt::Result { f.debug_struct( "CrateArchive" ).field( "files", &self.0.keys() ).finish() } @@ -29,24 +31,33 @@ mod private impl CrateArchive { /// Reads and decode a `.crate` archive from a given path. + /// # Errors + /// qqq: doc + #[ allow( clippy::question_mark_used, clippy::implicit_return ) ] + #[ inline ] pub fn read< P >( path : P ) -> std::io::Result< Self > where P : AsRef< Path >, { let mut file = std::fs::File::open( path )?; let mut buf = vec![]; + #[ allow( clippy::verbose_file_reads ) ] file.read_to_end( &mut buf )?; Self::decode( buf ) } #[ cfg( feature = "network" ) ] + #[ allow( clippy::question_mark_used, clippy::implicit_return, clippy::result_large_err ) ] /// Downloads and decodes a `.crate` archive from a given url. + /// # Errors + /// qqq: docs + #[ inline ] pub fn download< Url >( url : Url ) -> Result< Self, ureq::Error > where Url : AsRef< str >, { - let agent: Agent = AgentBuilder::new() + let agent = AgentBuilder::new() .timeout_read( Duration::from_secs( 5 ) ) .timeout_write( Duration::from_secs( 5 ) ) .build(); @@ -63,16 +74,24 @@ mod private /// Requires the full version of the package, in the format of `"x.y.z"` /// /// Returns error if the package with specified name and version - not exists. + /// # Errors + /// qqq: doc #[ cfg( feature = "network" ) ] + #[ allow( clippy::implicit_return, clippy::result_large_err ) ] + #[ inline ] pub fn download_crates_io< N, V >( name : N, version : V ) -> Result< Self, ureq::Error > where - N : std::fmt::Display, - V : std::fmt::Display, + N : core::fmt::Display, + V : core::fmt::Display, { Self::download( format!( "https://static.crates.io/crates/{name}/{name}-{version}.crate" ) ) } /// Decodes a bytes that represents a `.crate` file. + /// # Errors + /// qqq: doc + #[ allow( clippy::question_mark_used, unknown_lints, clippy::implicit_return ) ] + #[ inline ] pub fn decode< B >( bytes : B ) -> std::io::Result< Self > where B : AsRef<[ u8 ]>, @@ -81,43 +100,44 @@ mod private use flate2::bufread::GzDecoder; use tar::Archive; - let bytes = bytes.as_ref(); - if bytes.is_empty() + let bytes_slice = bytes.as_ref(); + if bytes_slice.is_empty() { return Ok( Self::default() ) } - let gz = GzDecoder::new( bytes ); + let gz = GzDecoder::new( bytes_slice ); let mut archive = Archive::new( gz ); let mut output = HashMap::new(); for file in archive.entries()? { - let mut file = file?; + let mut archive_file = file?; let mut contents = vec![]; - file.read_to_end( &mut contents )?; + archive_file.read_to_end( &mut contents )?; - output.insert( file.path()?.to_path_buf(), contents ); + output.insert( archive_file.path()?.to_path_buf(), contents ); } Ok( Self( output ) ) } - } - impl CrateArchive - { /// Returns a list of files from the `.crate` file. + #[ allow( clippy::implicit_return ) ] + #[ inline ] pub fn list( &self ) -> Vec< &Path > { self.0.keys().map( PathBuf::as_path ).collect() } /// Returns content of file by specified path from the `.crate` file in bytes representation. + #[ allow( clippy::implicit_return ) ] + #[ inline ] pub fn content_bytes< P >( &self, path : P ) -> Option< &[ u8 ] > - where - P : AsRef< Path >, + where + P : AsRef< Path >, { self.0.get( path.as_ref() ).map( Vec::as_ref ) } @@ -126,7 +146,7 @@ mod private #[ cfg( feature = "enabled" ) ] #[ doc( inline ) ] -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::pub_use ) ] pub use own::*; /// Own namespace of the module. @@ -134,9 +154,9 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { - use super::*; + use super::orphan; #[ doc( inline ) ] - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::pub_use ) ] pub use orphan::*; } @@ -145,9 +165,9 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { - use super::*; + use super::exposed; #[ doc( inline ) ] - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::pub_use ) ] pub use exposed::*; } @@ -156,9 +176,9 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { - use super::*; + use super::prelude; #[ doc( inline ) ] - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::pub_use ) ] pub use prelude::*; } @@ -167,8 +187,8 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + use super::private; #[ doc( inline ) ] - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::pub_use ) ] pub use private::CrateArchive; } diff --git a/module/move/optimization_tools/Cargo.toml b/module/move/optimization_tools/Cargo.toml index af2f73c222..4a276984c9 100644 --- a/module/move/optimization_tools/Cargo.toml +++ b/module/move/optimization_tools/Cargo.toml @@ -17,8 +17,8 @@ categories = [ "algorithms", "development-tools" ] keywords = [ "fundamental", "general-purpose" ] # xxx : qqq : switch that on -# [lints] -# workspace = true +#[lints] +#workspace = true [package.metadata.docs.rs] features = [ "full" ] @@ -60,7 +60,7 @@ plotters = { version = "0.3.5", default-features = false, features = [ "bitmap_backend", ] } plotters-backend = { version = "0.3.5", optional = true } -piston_window = { version = "0.120.0", optional = true } +piston_window = { version = "0.132.0", optional = true } exmex = { version = "0.18.0", features = [ "partial" ], optional = true } rayon = "1.8.0" thiserror = "1.0.56" diff --git a/module/move/unitore/Cargo.toml b/module/move/unitore/Cargo.toml index fa560e6cae..08313bc8e0 100644 --- a/module/move/unitore/Cargo.toml +++ b/module/move/unitore/Cargo.toml @@ -43,7 +43,7 @@ toml = "0.8.10" serde = "1.0.196" url = { version = "2.0", features = ["serde"] } humantime-serde = "1.1.1" -gluesql = "0.15.0" +gluesql = "0.16.2" async-trait = "0.1.41" wca = { workspace = true } mockall = "0.12.1" diff --git a/module/move/wca/src/ca/aggregator.rs b/module/move/wca/src/ca/aggregator.rs index c8cd532342..fb3725ba16 100644 --- a/module/move/wca/src/ca/aggregator.rs +++ b/module/move/wca/src/ca/aggregator.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use ca:: { @@ -81,6 +83,7 @@ mod private // xxx : aaa : aaa2 : for Bohdan : one level is obviously redundant // Program< Namespace< ExecutableCommand_ > > -> Program< ExecutableCommand_ > // aaa : done. The concept of `Namespace` has been removed + #[ allow( clippy::type_complexity ) ] struct CommandsAggregatorCallback( Box< dyn Fn( &str, &Program< VerifiedCommand > ) > ); impl fmt::Debug for CommandsAggregatorCallback @@ -94,7 +97,7 @@ mod private /// The `CommandsAggregator` struct is responsible for aggregating all commands that the user defines, /// and for parsing and executing them. It is the main entry point of the library. /// - /// CommandsAggregator component brings everything together. This component is responsible for configuring the `Parser`, `Grammar`, and `Executor` components based on the user’s needs. It also manages the entire pipeline of processing, from parsing the raw text input to executing the final command(parse -> validate -> execute). + /// `CommandsAggregator` component brings everything together. This component is responsible for configuring the `Parser`, `Grammar`, and `Executor` components based on the user’s needs. It also manages the entire pipeline of processing, from parsing the raw text input to executing the final command(parse -> validate -> execute). /// /// # Example: /// @@ -145,8 +148,8 @@ mod private let dictionary = ca.dictionary.get_or_insert_with( Dictionary::default ); dictionary.order = ca.order.unwrap_or_default(); - let help_generator = std::mem::take( &mut ca.help_generator ).unwrap_or_default(); - let help_variants = std::mem::take( &mut ca.help_variants ).unwrap_or_else( || HashSet::from([ HelpVariants::All ]) ); + let help_generator = core::mem::take( &mut ca.help_generator ).unwrap_or_default(); + let help_variants = core::mem::take( &mut ca.help_variants ).unwrap_or_else( || HashSet::from([ HelpVariants::All ]) ); if help_variants.contains( &HelpVariants::All ) { @@ -171,6 +174,8 @@ mod private /// # Arguments /// /// * `name` - The name of the command. + /// # Panics + /// qqq: doc pub fn command< IntoName >( self, name : IntoName ) -> CommandAsSubformer< Self, impl CommandAsSubformerEnd< Self > > where IntoName : Into< String >, @@ -204,6 +209,7 @@ mod private /// /// The modified instance of `Self`. // `'static` means that the value must be owned or live at least as a `Context' + #[ must_use ] pub fn with_context< T >( mut self, value : T ) -> Self where T : Sync + Send + 'static, @@ -231,6 +237,7 @@ mod private /// ca.perform( ".help" )?; /// # Ok( () ) } /// ``` + #[ must_use ] pub fn help< HelpFunction >( mut self, func : HelpFunction ) -> Self where HelpFunction : Fn( &Dictionary, HelpGeneratorOptions< '_ > ) -> String + 'static @@ -256,6 +263,7 @@ mod private /// ca.perform( ".help" )?; /// # Ok( () ) } /// ``` + #[ must_use ] pub fn callback< Callback >( mut self, callback : Callback ) -> Self where Callback : Fn( &str, &Program< VerifiedCommand > ) + 'static, @@ -270,18 +278,20 @@ mod private /// Parse, converts and executes a program /// /// Takes a string with program and executes it + /// # Errors + /// qqq: doc pub fn perform< S >( &self, program : S ) -> Result< (), Error > where S : IntoInput { let Input( ref program ) = program.into_input(); - let raw_program = self.parser.parse( program ).map_err( | e | Error::Validation( ValidationError::Parser { input : format!( "{:?}", program ), error : e } ) )?; + let raw_program = self.parser.parse( program ).map_err( | e | Error::Validation( ValidationError::Parser { input : format!( "{program:?}" ), error : e } ) )?; let grammar_program = self.verifier.to_program( &self.dictionary, raw_program ).map_err( | e | Error::Validation( ValidationError::Verifier( e ) ) )?; if let Some( callback ) = &self.callback_fn { - callback.0( &program.join( " " ), &grammar_program ) + callback.0( &program.join( " " ), &grammar_program ); } self.executor.program( &self.dictionary, grammar_program ).map_err( | e | Error::Execution( e.into() ) ) diff --git a/module/move/wca/src/ca/executor/context.rs b/module/move/wca/src/ca/executor/context.rs index 716bbafda6..a9611b618e 100644 --- a/module/move/wca/src/ca/executor/context.rs +++ b/module/move/wca/src/ca/executor/context.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { use std::sync::Arc; @@ -37,7 +38,7 @@ mod private #[ derive( Debug, Clone ) ] pub struct Context { - inner : Arc< dyn std::any::Any + Send + Sync >, + inner : Arc< dyn core::any::Any + Send + Sync >, } impl Default for Context @@ -80,6 +81,7 @@ mod private /// An `Option` containing a reference-counted smart pointer (`Arc`) to the object of type `T` if it exists in the context. /// `None` is returned if the object does not exist or if it cannot be downcasted to type `T`. // `'static` means that the object must be owned or live at least as a `Context' + #[ must_use ] pub fn get< T : Send + Sync + 'static >( &self ) -> Option< Arc< T > > { self.inner.clone().downcast::< T >().ok() diff --git a/module/move/wca/src/ca/executor/executor.rs b/module/move/wca/src/ca/executor/executor.rs index 9d662801a8..d6a7a3bdf1 100644 --- a/module/move/wca/src/ca/executor/executor.rs +++ b/module/move/wca/src/ca/executor/executor.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use ca::help::{ HelpGeneratorOptions, generate_help_content, LevelOfDetail }; @@ -45,7 +46,8 @@ mod private /// # Returns /// /// A `Result` with `Ok( () )` if the execution was successful, or an `Err` containing an error message if an error occurred. - /// + /// # Errors + /// qqq: doc // aaa : use typed error // aaa : done pub fn program( &self, dictionary : &Dictionary, program : Program< VerifiedCommand > ) @@ -71,6 +73,10 @@ mod private /// # Returns /// /// Returns a Result indicating success or failure. If successful, returns `Ok(())`, otherwise returns an error. + /// # Errors + /// qqq: doc + /// # Panics + /// qqq: doc // aaa : use typed error // aaa : done pub fn command( &self, dictionary : &Dictionary, command : VerifiedCommand ) @@ -116,6 +122,7 @@ mod private // aaa : use typed error // aaa : done + #[ allow( clippy::needless_pass_by_value ) ] fn _exec_internal_command( dictionary : &Dictionary, command : VerifiedCommand ) -> Result< (), InternalCommandError > { diff --git a/module/move/wca/src/ca/executor/routine.rs b/module/move/wca/src/ca/executor/routine.rs index ad9a455052..f40594af22 100644 --- a/module/move/wca/src/ca/executor/routine.rs +++ b/module/move/wca/src/ca/executor/routine.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // aaa : group @@ -61,6 +63,7 @@ mod private /// let first_arg : &str = args[ 0 ].clone().into(); /// assert_eq!( "Hello, World!", first_arg ); /// ``` + #[ must_use ] pub fn get_owned< T : From< Value > >( &self, index : usize ) -> Option< T > { self.0.get( index ).map( | arg | arg.to_owned().into() ) @@ -180,9 +183,9 @@ mod private pub struct Handler< I, O >( Box< dyn Fn( I ) -> O > ); - impl< I, O > std::fmt::Debug for Handler< I, O > + impl< I, O > core::fmt::Debug for Handler< I, O > { - fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result + fn fmt( &self, f : &mut Formatter< '_ > ) -> core::fmt::Result { f.debug_struct( "Handler" ).finish_non_exhaustive() } @@ -261,9 +264,9 @@ mod private WithContext( Rc< RoutineWithContextFn > ), } - impl std::fmt::Debug for Routine + impl core::fmt::Debug for Routine { - fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result + fn fmt( &self, f : &mut Formatter< '_ > ) -> core::fmt::Result { match self { @@ -316,7 +319,7 @@ mod private { // We can't compare closures. Because every closure has a separate type, even if they're identical. // Therefore, we check that the two Rc's point to the same closure (allocation). - #[ allow( clippy::vtable_address_comparisons ) ] + #[ allow( ambiguous_wide_pointer_comparisons ) ] match ( self, other ) { ( Routine::WithContext( this ), Routine::WithContext( other ) ) => Rc::ptr_eq( this, other ), @@ -335,9 +338,9 @@ mod private // xxx // aaa : This is an untyped error because we want to provide a common interface for all commands, while also allowing users to propagate their own specific custom errors. - impl IntoResult for std::convert::Infallible { fn into_result( self ) -> error::untyped::Result< () > { Ok( () ) } } + impl IntoResult for core::convert::Infallible { fn into_result( self ) -> error::untyped::Result< () > { Ok( () ) } } impl IntoResult for () { fn into_result( self ) -> error::untyped::Result< () > { Ok( () ) } } - impl< E : std::fmt::Debug + std::fmt::Display + 'static > IntoResult + impl< E : core::fmt::Debug + std::fmt::Display + 'static > IntoResult for error::untyped::Result< (), E > { fn into_result( self ) -> error::untyped::Result< () > diff --git a/module/move/wca/src/ca/formatter.rs b/module/move/wca/src/ca/formatter.rs index 30e6787d6d..1c606532d7 100644 --- a/module/move/wca/src/ca/formatter.rs +++ b/module/move/wca/src/ca/formatter.rs @@ -1,6 +1,7 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use iter_tools::Itertools; use ca::aggregator::Order; @@ -26,13 +27,14 @@ mod private /// The `md_generator` function takes a reference to a `Dictionary` and an `Order` to produce /// a help document in Markdown format. This function is useful for generating structured, /// readable help documentation suitable for Markdown-compatible platforms. + #[ must_use ] pub fn md_generator( grammar : &Dictionary, order: Order ) -> String { let text = grammar.commands() .into_iter() .map( |( name, cmd )| { - let subjects = cmd.subjects.iter().fold( String::new(), | _, _ | format!( " `[argument]`" ) ); + let subjects = cmd.subjects.iter().fold( String::new(), | _, _ | " `[argument]`".to_string() ); let properties = if cmd.properties.is_empty() { " " } else { " `[properties]` " }; format! ( @@ -48,17 +50,17 @@ mod private format!( "{acc}\n- {cmd}" ) }); - let list_of_commands = format!( "## Commands\n\n{}", text ); + let list_of_commands = format!( "## Commands\n\n{text}" ); let about_each_command = grammar.commands() .into_iter() .map( |( name, cmd )| { - let subjects = cmd.subjects.iter().fold( String::new(), | _, _ | format!( " `[Subject]`" ) ); + let subjects = cmd.subjects.iter().fold( String::new(), | _, _ | " `[Subject]`".to_string() ); let properties = if cmd.properties.is_empty() { " " } else { " `[properties]` " }; let hint = if cmd.hint.is_empty() { &cmd.long_hint } else { &cmd.hint }; - let heading = format!( "## .{}{subjects}{properties}\n__{}__\n", name, hint ); + let heading = format!( "## .{name}{subjects}{properties}\n__{hint}__\n" ); let hint = if cmd.long_hint.is_empty() { &cmd.hint } else { &cmd.long_hint }; let full_subjects = cmd @@ -86,8 +88,8 @@ mod private format! ( "{heading}\n{}{}\n\n{hint}\n", - if cmd.subjects.is_empty() { "".to_string() } else { format!( "\n\nSubjects:{}", &full_subjects ) }, - if cmd.properties.is_empty() { "".to_string() } else { format!( "\n\nProperties:{}",&full_properties ) }, + if cmd.subjects.is_empty() { String::new() } else { format!( "\n\nSubjects:{}", &full_subjects ) }, + if cmd.properties.is_empty() { String::new() } else { format!( "\n\nProperties:{}",&full_properties ) }, ) }) diff --git a/module/move/wca/src/ca/grammar/command.rs b/module/move/wca/src/ca/grammar/command.rs index 0c17e726b1..e1bc974d63 100644 --- a/module/move/wca/src/ca/grammar/command.rs +++ b/module/move/wca/src/ca/grammar/command.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::collections::HashMap; @@ -120,11 +122,11 @@ mod private { Order::Nature => { - self.properties.iter().map( | ( key, value ) | ( key, value ) ).collect() + self.properties.iter().collect() } Order::Lexicography => { - self.properties.iter().map( | ( key, value ) | ( key, value ) ).sorted_by_key( | ( k, _ ) | *k ).collect() + self.properties.iter().sorted_by_key( | ( k, _ ) | *k ).collect() } } } @@ -135,6 +137,7 @@ mod private Definition : former::FormerDefinition< Storage = < Command as former::EntityToStorage >::Storage >, { /// Setter for separate properties aliases. + #[ must_use ] pub fn property_alias< S : Into< String > >( mut self, key : S, alias : S ) -> Self { let key = key.into(); @@ -177,6 +180,7 @@ mod private /// # Returns /// /// Returns the `CommandFormer` instance with the new command routine set. + #[ must_use ] pub fn routine< I, R, F : Into< Handler< I, R > > >( mut self, f : F ) -> Self where Routine: From< Handler< I, R > >, @@ -209,6 +213,8 @@ mod private /// # Arguments /// /// * `name` - The name of the property. It should implement the `Into< String >` trait. + /// # Panics + /// qqq: doc pub fn property< IntoName >( self, name : IntoName ) -> PropertyDescriptionAsSubformer< Self, impl PropertyDescriptionAsSubformerEnd< Self > > where IntoName : Into< String >, diff --git a/module/move/wca/src/ca/grammar/dictionary.rs b/module/move/wca/src/ca/grammar/dictionary.rs index 8dc784f3db..3e8e0389a5 100644 --- a/module/move/wca/src/ca/grammar/dictionary.rs +++ b/module/move/wca/src/ca/grammar/dictionary.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use former::Former; use indexmap::IndexMap; @@ -87,17 +89,18 @@ mod private } /// asd + #[ must_use ] pub fn commands( &self ) -> Vec< ( &String, &Command ) > { match self.order { Order::Nature => { - self.commands.iter().map( | ( key, value ) | ( key, value ) ).collect() + self.commands.iter().collect() } Order::Lexicography => { - self.commands.iter().map( | ( key, value ) | ( key, value ) ).sorted_by_key( | ( key, _ ) | *key ).collect() + self.commands.iter().sorted_by_key( | ( key, _ ) | *key ).collect() } } } diff --git a/module/move/wca/src/ca/grammar/types.rs b/module/move/wca/src/ca/grammar/types.rs index 99526b35dd..6bea357228 100644 --- a/module/move/wca/src/ca/grammar/types.rs +++ b/module/move/wca/src/ca/grammar/types.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::fmt:: { @@ -44,6 +46,8 @@ mod private pub trait TryCast< T > { /// return casted value + /// # Errors + /// qqq: doc fn try_cast( &self, value : String ) -> error::untyped::Result< T >; } @@ -116,7 +120,7 @@ mod private } Value::List( list ) => { - let list = list.iter().map( | element | element.to_string() ).join( "," ); + let list = list.iter().map( std::string::ToString::to_string ).join( "," ); write!( f, "{list}" )?; } } @@ -135,7 +139,7 @@ mod private { match value { - #[ allow( clippy::redundant_closure_call ) ] // ok because of it improve understanding what is `value` at macro call + #[ allow( clippy::redundant_closure_call, clippy::cast_possible_truncation, clippy::cast_sign_loss ) ] // ok because of it improve understanding what is `value` at macro call $value_kind( value ) => ( $cast )( value ), _ => panic!( "Unknown cast variant. Got `{value:?}` and try to cast to `{}`", stringify!( $kind ) ) } @@ -170,8 +174,8 @@ mod private { match value { - Value::List( value ) => value.into_iter().map( | x | x.into() ).collect(), - _ => panic!( "Unknown cast variant. Got `{value:?}` and try to cast to `Vec<{}>`", std::any::type_name::< T >() ) + Value::List( value ) => value.into_iter().map( std::convert::Into::into ).collect(), + _ => panic!( "Unknown cast variant. Got `{value:?}` and try to cast to `Vec<{}>`", core::any::type_name::< T >() ) } } } diff --git a/module/move/wca/src/ca/help.rs b/module/move/wca/src/ca/help.rs index 6a40e28e1c..b48a8ed93c 100644 --- a/module/move/wca/src/ca/help.rs +++ b/module/move/wca/src/ca/help.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use ca:: { @@ -77,6 +79,10 @@ mod private /// This function takes a `Dictionary` of terms or commands and a `HelpGeneratorOptions` /// struct to customize the help output, generating a user-friendly help message /// or guide in `String` format. + /// # Panics + /// qqq: doc + #[ must_use ] + #[ allow( clippy::match_same_arms ) ] pub fn generate_help_content( dictionary : &Dictionary, o : HelpGeneratorOptions< '_ > ) -> String { struct Row @@ -101,15 +107,15 @@ mod private }; let subjects = match o.subject_detailing { - LevelOfDetail::None => "".into(), - _ if command.subjects.is_empty() => "".into(), + LevelOfDetail::None => String::new(), + _ if command.subjects.is_empty() => String::new(), LevelOfDetail::Simple => "< subjects >".into(), LevelOfDetail::Detailed => command.subjects.iter().map( | v | format!( "< {}{:?} >", if v.optional { "?" } else { "" }, v.kind ) ).collect::< Vec< _ > >().join( " " ), }; let properties = match o.property_detailing { - LevelOfDetail::None => "".into(), - _ if command.subjects.is_empty() => "".into(), + LevelOfDetail::None => String::new(), + _ if command.subjects.is_empty() => String::new(), LevelOfDetail::Simple => "< properties >".into(), LevelOfDetail::Detailed => command.properties( dictionary.order ).iter().map( |( n, v )| format!( "< {}:{}{:?} >", if v.optional { "?" } else { "" }, n, v.kind ) ).collect::< Vec< _ > >().join( " " ), }; @@ -122,10 +128,10 @@ mod private format! ( "{}{}", - if command.subjects.is_empty() { "".to_string() } else { format!( "\nSubjects:\n\t{}", &full_subjects ) }, - if command.properties.is_empty() { "".to_string() } else { format!( "\nProperties:\n\t{}",&full_properties ) } + if command.subjects.is_empty() { String::new() } else { format!( "\nSubjects:\n\t{}", &full_subjects ) }, + if command.properties.is_empty() { String::new() } else { format!( "\nProperties:\n\t{}",&full_properties ) } ) - } else { "".into() }; + } else { String::new() }; Row { @@ -178,6 +184,7 @@ mod private impl HelpVariants { /// Generates help commands + #[ allow( clippy::match_wildcard_for_single_variants ) ] pub fn generate( &self, helper : &HelpGeneratorFn, dictionary : &mut Dictionary, order : Order ) { match self @@ -196,6 +203,7 @@ mod private } // .help + #[ allow( clippy::unused_self ) ] fn general_help( &self, helper : &HelpGeneratorFn, dictionary : &mut Dictionary, order : Order ) { let phrase = "help".to_string(); @@ -260,6 +268,7 @@ mod private } // .help command_name + #[ allow( clippy::unused_self ) ] fn subject_command_help( &self, helper : &HelpGeneratorFn, dictionary : &mut Dictionary ) { let phrase = "help".to_string(); @@ -410,15 +419,16 @@ mod private impl HelpGeneratorFn { /// Executes the function to generate help content + #[ must_use ] pub fn exec( &self, dictionary : &Dictionary, args : HelpGeneratorOptions< '_ > ) -> String { self.0( dictionary, args ) } } - impl std::fmt::Debug for HelpGeneratorFn + impl core::fmt::Debug for HelpGeneratorFn { - fn fmt( &self, f : &mut std::fmt::Formatter< '_ > ) -> std::fmt::Result + fn fmt( &self, f : &mut core::fmt::Formatter< '_ > ) -> core::fmt::Result { f.write_str( "HelpGenerator" ) } diff --git a/module/move/wca/src/ca/input.rs b/module/move/wca/src/ca/input.rs index 46f70221b8..34d57ba2c9 100644 --- a/module/move/wca/src/ca/input.rs +++ b/module/move/wca/src/ca/input.rs @@ -3,10 +3,11 @@ mod private use std::io::{ self, Write }; /// Ask use input from standard input. + #[ must_use ] pub fn ask( request : &str ) -> String { let mut response = String::new(); - print!( "{} : ", request ); + print!( "{request} : " ); io::stdout().flush().ok(); io::stdin().read_line( &mut response ).ok(); response.trim().to_string() diff --git a/module/move/wca/src/ca/parser/command.rs b/module/move/wca/src/ca/parser/command.rs index 84cfbefc2b..9d75b11655 100644 --- a/module/move/wca/src/ca/parser/command.rs +++ b/module/move/wca/src/ca/parser/command.rs @@ -39,7 +39,7 @@ mod private /// }; /// ``` /// - /// In the above example, a `ParsedCommand` instance is created with the name "command", a single subject "subject_value", and one property "prop_name" with a raw value of "raw_prop_value". + /// In the above example, a `ParsedCommand` instance is created with the name "command", a single subject "`subject_value`", and one property "`prop_name`" with a raw value of "`raw_prop_value`". /// #[ derive( Default, Debug, Clone, PartialEq, Eq ) ] pub struct ParsedCommand diff --git a/module/move/wca/src/ca/parser/parser.rs b/module/move/wca/src/ca/parser/parser.rs index 0fec9fb6f4..4bee7321d0 100644 --- a/module/move/wca/src/ca/parser/parser.rs +++ b/module/move/wca/src/ca/parser/parser.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::collections::HashMap; @@ -32,6 +33,8 @@ mod private /// # Returns /// /// Returns a `Result` with a `Program` containing the parsed commands if successful, or an error if parsing fails. + /// # Errors + /// qqq: doc // aaa : use typed error // aaa : done. pub fn parse< As, A >( &self, args : As ) -> Result< Program< ParsedCommand >, ParserError > @@ -57,7 +60,7 @@ mod private { if let Some( name ) = input.strip_prefix( '.' ) { - name.is_empty() || name.starts_with( '?' ) || name.chars().next().is_some_and( | c | c.is_alphanumeric() ) + name.is_empty() || name.starts_with( '?' ) || name.chars().next().is_some_and( char::is_alphanumeric ) } else { @@ -90,7 +93,7 @@ mod private i += relative_pos; - return Ok( + Ok( ( ParsedCommand { diff --git a/module/move/wca/src/ca/tool/table.rs b/module/move/wca/src/ca/tool/table.rs index 4315ee5c8e..b3bce748d5 100644 --- a/module/move/wca/src/ca/tool/table.rs +++ b/module/move/wca/src/ca/tool/table.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // use wtools::error::{ Result, err }; @@ -69,7 +70,7 @@ mod private fn max_column_lengths( table : &Table ) -> Vec< usize > { - let num_columns = table.0.get( 0 ).map_or( 0, | row | row.0.len() ); + let num_columns = table.0.first().map_or( 0, | row | row.0.len() ); ( 0 .. num_columns ) .map( | column_index | { @@ -94,6 +95,8 @@ mod private /// # Returns /// /// * `error::untyped::Result` - A `error::untyped::Result` containing the formatted table as a `String`, or an `Error` if the table is invalid. + /// # Errors + /// qqq: doc // aaa : use typed error // aaa : done pub fn format_table< IntoTable >( table : IntoTable ) -> Result< String, FormatTableError > diff --git a/module/move/wca/src/ca/verifier/command.rs b/module/move/wca/src/ca/verifier/command.rs index c945bbb997..f52d54c897 100644 --- a/module/move/wca/src/ca/verifier/command.rs +++ b/module/move/wca/src/ca/verifier/command.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use executor::{ Args, Props }; @@ -23,7 +24,7 @@ mod private /// }; /// ``` /// - /// In the above example, a `VerifiedCommand` instance is created with the name "command", a single subject "subject_value", and one property "prop_name" with a typed values. + /// In the above example, a `VerifiedCommand` instance is created with the name "command", a single subject "`subject_value`", and one property "`prop_name`" with a typed values. /// #[ derive( Debug, Clone ) ] pub struct VerifiedCommand diff --git a/module/move/wca/src/ca/verifier/verifier.rs b/module/move/wca/src/ca/verifier/verifier.rs index c0636a594b..db3de37923 100644 --- a/module/move/wca/src/ca/verifier/verifier.rs +++ b/module/move/wca/src/ca/verifier/verifier.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use help::{ HelpGeneratorOptions, LevelOfDetail, generate_help_content }; @@ -78,6 +79,8 @@ mod private /// Converts raw program to grammatically correct /// /// Converts all namespaces into it with `to_namespace` method. + /// # Errors + /// qqq: doc pub fn to_program ( &self, @@ -183,8 +186,9 @@ mod private Ok( subjects ) } - // aaa : use typed error - // aaa : done. + // aaa : use typed error + // aaa : done. + #[ allow( clippy::manual_map ) ] fn extract_properties( command: &Command, raw_command : HashMap< String, String > ) -> Result< HashMap< String, Value >, PropertyError > @@ -224,7 +228,7 @@ mod private used_keys.flat_map( | key | { - reverse_aliases.get( key ).into_iter().flatten().map( | k | *k ).chain( Some( key ) ) + reverse_aliases.get( key ).into_iter().flatten().copied().chain( Some( key ) ) }) .collect() } @@ -232,6 +236,10 @@ mod private /// Converts raw command to grammatically correct /// /// Make sure that this command is described in the grammar and matches it(command itself and all it options too). + /// # Errors + /// qqq: doc + /// # Panics + /// qqq: doc // aaa : use typed error // aaa : done. pub fn to_command( &self, dictionary : &Dictionary, raw_command : ParsedCommand ) @@ -277,7 +285,7 @@ mod private Ok( VerifiedCommand { - phrase : cmd.phrase.to_owned(), + phrase : cmd.phrase.clone(), internal_command : false, args : Args( subjects ), props : Props( properties ), diff --git a/module/move/willbe/Cargo.toml b/module/move/willbe/Cargo.toml index 4f16918129..e647b11d88 100644 --- a/module/move/willbe/Cargo.toml +++ b/module/move/willbe/Cargo.toml @@ -61,12 +61,12 @@ flate2 = "~1.0" globwalk = "~0.8" toml_edit = "~0.14" petgraph = "~0.6" -ptree = "~0.4" +#ptree = "~0.4" rayon = "1.8.0" semver = "~1.0.0" similar = "~2.4" regex = "1.10.2" -sha-1 = "~0.10" +#sha-1 = "~0.10" tar = "~0.4" handlebars = "4.5.0" ureq = "~2.9" diff --git a/module/move/willbe/Readme.md b/module/move/willbe/Readme.md index b387b877c6..c7d2a441b9 100644 --- a/module/move/willbe/Readme.md +++ b/module/move/willbe/Readme.md @@ -1,6 +1,6 @@ -# Module:: willbe +# `Module`:: willbe [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_willbe_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_willbe_push.yml) [![docs.rs](https://img.shields.io/docsrs/willbe?color=e3e8f0&logo=docs.rs)](https://docs.rs/willbe) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) diff --git a/module/move/willbe/src/action/cicd_renew.rs b/module/move/willbe/src/action/cicd_renew.rs index 5814e2802c..ca46b77549 100644 --- a/module/move/willbe/src/action/cicd_renew.rs +++ b/module/move/willbe/src/action/cicd_renew.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -42,6 +43,12 @@ mod private // qqq : for Petro : should return Report and typed error in Result /// Generate workflows for modules in .github/workflows directory. + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc + #[ allow( clippy::too_many_lines, clippy::result_large_err ) ] pub fn action( base_path : &Path ) -> Result< (), CiCdGenerateError > { let workspace_cache = Workspace::try_from( CrateDir::try_from( base_path )? )?; @@ -131,13 +138,13 @@ mod private data.insert( "name", name.as_str() ); data.insert( "username_and_repository", username_and_repository.0.as_str() ); data.insert( "branch", "alpha" ); - let manifest_file = manifest_file.to_string_lossy().replace( "\\", "/" ); + let manifest_file = manifest_file.to_string_lossy().replace( '\\', "/" ); let manifest_file = manifest_file.trim_start_matches( '/' ); data.insert( "manifest_path", manifest_file ); let content = handlebars.render( "module_push", &data )?; file_write( &workflow_file_name, &content )?; - println!( "file_write : {:?}", &workflow_file_name ) + println!( "file_write : {:?}", &workflow_file_name ); } dbg!( &workflow_root ); @@ -306,7 +313,7 @@ mod private Ok( () ) } - /// Prepare params for render appropriative_branch_for template. + /// Prepare params for render `appropriative_branch_for` template. fn map_prepare_for_appropriative_branch< 'a > ( branches : &'a str, @@ -333,7 +340,7 @@ mod private { match std::fs::create_dir_all( folder ) { - Ok( _ ) => {}, + Ok( () ) => {}, Err( e ) if e.kind() == std::io::ErrorKind::AlreadyExists => {}, Err( e ) => return Err( e.into() ), } @@ -372,7 +379,7 @@ mod private .map( String::from ); if let Some( url ) = url { - return url::repo_url_extract( &url ) + url::repo_url_extract( &url ) .and_then( | url | url::git_info_extract( &url ).ok() ) .map( UsernameAndRepository ) .ok_or_else( || error::untyped::format_err!( "Fail to parse repository url from workspace Cargo.toml")) @@ -389,7 +396,7 @@ mod private break; } } - return url + url .and_then( | url | url::repo_url_extract( &url ) ) .and_then( | url | url::git_info_extract( &url ).ok() ) .map( UsernameAndRepository ) diff --git a/module/move/willbe/src/action/deploy_renew.rs b/module/move/willbe/src/action/deploy_renew.rs index 0f1c965332..c0681cc6c7 100644 --- a/module/move/willbe/src/action/deploy_renew.rs +++ b/module/move/willbe/src/action/deploy_renew.rs @@ -1,8 +1,10 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::path::Path; use error::{ untyped::Context }; + #[ allow( clippy::wildcard_imports ) ] use tool::template::*; /// Template for creating deploy files. @@ -17,6 +19,8 @@ mod private /// Creates am instance of `[TemplateHolder]` for deployment template. /// /// Used for properly initializing a template + #[ must_use ] + #[ allow( clippy::should_implement_trait ) ] pub fn default() -> TemplateHolder { let parameters = TemplateParameters::former() @@ -30,7 +34,7 @@ mod private { files : get_deploy_template_files(), parameters, - values : Default::default(), + values : TemplateValues::default(), parameter_storage : "./.deploy_template.toml".as_ref(), template_name : "deploy", } @@ -79,12 +83,13 @@ mod private fn dir_name_to_formatted( dir_name : &str, separator : &str ) -> String { dir_name - .replace( ' ', separator ) - .replace( '_', separator ) + .replace( [ ' ', '_' ], separator ) .to_lowercase() } /// Creates deploy template + /// # Errors + /// qqq: doc pub fn deploy_renew ( path : &Path, @@ -93,7 +98,7 @@ mod private -> error::untyped::Result< () > // qqq : typed error { - if let None = template.load_existing_params( path ) + if template.load_existing_params( path ).is_none() { let current_dir = std::env::current_dir()?; // qqq : for Petro : use file_name diff --git a/module/move/willbe/src/action/features.rs b/module/move/willbe/src/action/features.rs index ca7312d289..2d46a8a882 100644 --- a/module/move/willbe/src/action/features.rs +++ b/module/move/willbe/src/action/features.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -39,12 +41,13 @@ mod private impl fmt::Display for FeaturesReport { + #[ allow( clippy::match_bool ) ] fn fmt( &self, f : &mut fmt::Formatter< '_ >) -> Result< (), fmt::Error > { self.inner.iter().try_for_each ( | ( package, features ) | { - writeln!(f, "Package {}:", package)?; + writeln!(f, "Package {package}:")?; features.iter().try_for_each ( | ( feature, dependencies ) | { @@ -67,6 +70,8 @@ mod private } /// List features + /// # Errors + /// qqq: doc pub fn features( FeaturesOptions { crate_dir, with_features_deps } : FeaturesOptions ) -> error::untyped::Result< FeaturesReport > // qqq : typed error diff --git a/module/move/willbe/src/action/list.rs b/module/move/willbe/src/action/list.rs index c747532f6d..5bd66e940c 100644 --- a/module/move/willbe/src/action/list.rs +++ b/module/move/willbe/src/action/list.rs @@ -1,6 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::{ fmt, str }; @@ -285,7 +287,7 @@ mod private ( f, "{}", - v.iter().map( | l | l.to_string() ).collect::< Vec< _ > >().join( "\n" ) + v.iter().map( std::string::ToString::to_string ).collect::< Vec< _ > >().join( "\n" ) ), Self::List( v ) => @@ -321,6 +323,7 @@ mod private pub path : Option< ManifestFile >, } + #[ allow( clippy::trivially_copy_pass_by_ref, clippy::needless_lifetimes ) ] fn process_package_dependency< 'a > ( workspace : &Workspace, @@ -347,7 +350,7 @@ mod private name : dependency.name(), // unwrap should be safe because of `semver::VersionReq` version : dependency.req(), - path : dependency.crate_dir().map( | p | p.manifest_file() ), + path : dependency.crate_dir().map( CrateDir::manifest_file ), }; // format!( "{}+{}+{}", dependency.name(), dependency.req(), dependency.crate_dir().unwrap().manifest_file() ); // let dep_id = format!( "{}+{}+{}", dependency.name(), dependency.req(), dependency.path().as_ref().map( | p | p.join( "Cargo.toml" ) ).unwrap_or_default() ); @@ -402,7 +405,7 @@ mod private name : dep.name(), // unwrap should be safe because of `semver::VersionReq` version : dep.req(), - path : dep.crate_dir().map( | p | p.manifest_file() ), + path : dep.crate_dir().map( CrateDir::manifest_file ), }; // if this is a cycle (we have visited this node before) if visited.contains( &dep_id ) @@ -542,7 +545,7 @@ mod private .collect(); for package in packages { - tree_package_report( package.manifest_file().unwrap(), &mut report, &mut visited )? + tree_package_report( package.manifest_file().unwrap(), &mut report, &mut visited )?; } let ListReport::Tree( tree ) = report else { unreachable!() }; let printer = merge_build_dependencies( tree ); @@ -626,12 +629,12 @@ mod private { if args.info.contains( &PackageAdditionalInfo::Version ) { - name.push_str( " " ); + name.push( ' ' ); name.push_str( &p.version().to_string() ); } if args.info.contains( &PackageAdditionalInfo::Path ) { - name.push_str( " " ); + name.push( ' ' ); name.push_str( &p.manifest_file()?.to_string() ); // aaa : is it safe to use unwrap here? // aaa : should be safe, but now returns an error } @@ -679,12 +682,12 @@ mod private { if args.info.contains( &PackageAdditionalInfo::Version ) { - name.push_str( " " ); + name.push( ' ' ); name.push_str( &p.version().to_string() ); } if args.info.contains( &PackageAdditionalInfo::Path ) { - name.push_str( " " ); + name.push( ' ' ); name.push_str( &p.manifest_file().unwrap().to_string() ); } } @@ -757,7 +760,7 @@ mod private } let printer : Vec< TreePrinter > = report .iter() - .map( | rep | TreePrinter::new( rep ) ) + .map( TreePrinter::new ) .collect(); printer } @@ -789,15 +792,15 @@ mod private fn rearrange_duplicates( mut report : Vec< tool::ListNodeReport > ) -> Vec< tool::TreePrinter > { let mut required_normal : collection::HashMap< usize, Vec< tool::ListNodeReport > > = collection::HashMap::new(); - for i in 0 .. report.len() + for (i, report) in report.iter_mut().enumerate() { let ( required, exist ) : ( Vec< _ >, Vec< _ > ) = std::mem::take ( - &mut report[ i ].normal_dependencies + &mut report.normal_dependencies ) .into_iter() .partition( | d | d.duplicate ); - report[ i ].normal_dependencies = exist; + report.normal_dependencies = exist; required_normal.insert( i, required ); } @@ -809,7 +812,7 @@ mod private let printer : Vec< TreePrinter > = report .iter() - .map( | rep | TreePrinter::new( rep ) ) + .map( TreePrinter::new ) .collect(); printer diff --git a/module/move/willbe/src/action/main_header.rs b/module/move/willbe/src/action/main_header.rs index 05ca9ec085..41241c2ffb 100644 --- a/module/move/willbe/src/action/main_header.rs +++ b/module/move/willbe/src/action/main_header.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::fmt::{ Display, Formatter }; use std::fs:: @@ -16,6 +18,7 @@ mod private use std::path::PathBuf; use regex::Regex; use entity::{ PathError, WorkspaceInitError }; + #[ allow( unused_imports ) ] use error:: { // err, @@ -48,6 +51,7 @@ mod private impl Display for MainHeaderRenewReport { + #[ allow( clippy::collapsible_else_if ) ] fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result { if self.success @@ -140,6 +144,7 @@ mod private } /// Convert `Self`to header. + #[ allow( clippy::uninlined_format_args, clippy::wrong_self_convention ) ] fn to_header( self ) -> Result< String, MainHeaderRenewError > { let discord = self.discord_url @@ -193,6 +198,13 @@ mod private /// [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/wtools) /// /// ``` + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc + #[ allow( clippy::uninlined_format_args ) ] pub fn action( crate_dir : CrateDir ) // -> Result< MainHeaderRenewReport, ( MainHeaderRenewReport, MainHeaderRenewError ) > -> ResultWithReport< MainHeaderRenewReport, MainHeaderRenewError > diff --git a/module/move/willbe/src/action/publish.rs b/module/move/willbe/src/action/publish.rs index 6b8f4dc657..ed6a6c90f2 100644 --- a/module/move/willbe/src/action/publish.rs +++ b/module/move/willbe/src/action/publish.rs @@ -1,6 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::{ env, fmt, fs }; @@ -34,10 +36,10 @@ mod private writeln!( f, "Actions :" )?; for ( path, report ) in &self.packages { - let report = report.to_string().replace("\n", "\n "); + let report = report.to_string().replace('\n', "\n "); let path = if let Some( wrd ) = &self.workspace_root_dir { - path.as_ref().strip_prefix( &wrd.as_ref() ).unwrap() + path.as_ref().strip_prefix( wrd.as_ref() ).unwrap() } else { @@ -158,7 +160,7 @@ mod private let workspace_root_dir : AbsolutePath = workspace .workspace_root() - .try_into()?; + .into(); let packages = workspace.packages(); let packages_to_publish : Vec< String > = packages diff --git a/module/move/willbe/src/action/publish_diff.rs b/module/move/willbe/src/action/publish_diff.rs index a6b76e6528..69b98be647 100644 --- a/module/move/willbe/src/action/publish_diff.rs +++ b/module/move/willbe/src/action/publish_diff.rs @@ -1,6 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use path::PathBuf; @@ -43,6 +45,7 @@ mod private let root_name = tree.name.clone(); let root_version = tree.version.as_ref().unwrap().clone(); + #[ allow( clippy::items_after_statements, clippy::option_map_unit_fn ) ] fn modify( diffs : &HashMap< AbsolutePath, DiffReport >, tree : &mut ListNodeReport ) { let path = tree.crate_dir.take().unwrap(); @@ -75,7 +78,7 @@ mod private for dep in &mut tree.normal_dependencies { - modify( diffs, dep ) + modify( diffs, dep ); } } modify( &self.diffs, &mut tree ); @@ -83,7 +86,7 @@ mod private let root = AbsolutePath::from( root_path ); let diff = self.diffs.get( &root ).unwrap(); let printer = TreePrinter::new( &tree ); - writeln!( f, "Tree:\n{}", printer )?; + writeln!( f, "Tree:\n{printer}" )?; if diff.has_changes() { writeln!( f, "Changes detected in `{root_name} {root_version}`:" )?; @@ -92,7 +95,7 @@ mod private { writeln!( f, "No changes found in `{root_name} {root_version}`. Files:" )?; } - write!( f, "{}", diff )?; + write!( f, "{diff}" )?; Ok( () ) } @@ -157,7 +160,7 @@ mod private if let Some( out_path ) = &o.keep_archive { - _ = std::fs::create_dir_all( &out_path ); + _ = std::fs::create_dir_all( out_path ); for path in r.list() { let local_path = out_path.join( path ); @@ -173,7 +176,7 @@ mod private let report = tasks[ current_idx ].info.normal_dependencies.clone(); let printer : Vec< TreePrinter > = report .iter() - .map( | rep | TreePrinter::new( rep ) ) + .map( TreePrinter::new ) .collect(); tasks.extend( printer ); diff --git a/module/move/willbe/src/action/readme_health_table_renew.rs b/module/move/willbe/src/action/readme_health_table_renew.rs index 438c44dcd8..dff994b1d9 100644 --- a/module/move/willbe/src/action/readme_health_table_renew.rs +++ b/module/move/willbe/src/action/readme_health_table_renew.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -37,14 +39,14 @@ mod private ( regex::bytes::Regex::new ( - r#""# + r"" ).unwrap() ).ok(); CLOSE_TAG.set ( regex::bytes::Regex::new ( - r#""# + r"" ).unwrap() ).ok(); } @@ -131,6 +133,7 @@ mod private /// Structure that holds the parameters for generating a table. #[ derive( Debug ) ] + #[ allow( clippy::struct_excessive_bools ) ] struct TableOptions { // Relative path from workspace root to directory with modules @@ -151,23 +154,19 @@ mod private { let include_branches = value .get( "with_branches" ) - .map( | v | bool::from( v ) ) - .unwrap_or( true ); + .map_or( true, bool::from ); let include_stability = value .get( "with_stability" ) - .map( | v | bool::from( v ) ) - .unwrap_or( true ); + .map_or( true, bool::from ); let include_docs = value .get( "with_docs" ) - .map( | v | bool::from( v ) ) - .unwrap_or( true ); + .map_or( true, bool::from ); let include = value .get( "with_gitpod" ) - .map( | v | bool::from( v ) ) - .unwrap_or( true ); + .map_or( true, bool::from ); let b_p = value.get( "1" ); let base_path = if let Some( query::Value::String( path ) ) = value.get( "path" ).or( b_p ) @@ -200,51 +199,49 @@ mod private { return Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Cannot find Cargo.toml" ))) } - else + + let mut contents = String::new(); + File::open( cargo_toml_path )?.read_to_string( &mut contents )?; + let doc = contents.parse::< Document >()?; + + let core_url = + doc + .get( "workspace" ) + .and_then( | workspace | workspace.get( "metadata" ) ) + .and_then( | metadata | metadata.get( "repo_url" ) ) + .and_then( | url | url.as_str() ) + .map( String::from ); + + let branches = + doc + .get( "workspace" ) + .and_then( | workspace | workspace.get( "metadata" ) ) + .and_then( | metadata | metadata.get( "branches" ) ) + .and_then( | branches | branches.as_array()) + .map + ( + | array | + array + .iter() + .filter_map( | value | value.as_str() ) + .map( String::from ) + .collect::< Vec< String > >() + ); + let mut user_and_repo = String::new(); + if let Some( core_url ) = &core_url { - let mut contents = String::new(); - File::open( cargo_toml_path )?.read_to_string( &mut contents )?; - let doc = contents.parse::< Document >()?; - - let core_url = - doc - .get( "workspace" ) - .and_then( | workspace | workspace.get( "metadata" ) ) - .and_then( | metadata | metadata.get( "repo_url" ) ) - .and_then( | url | url.as_str() ) - .map( String::from ); - - let branches = - doc - .get( "workspace" ) - .and_then( | workspace | workspace.get( "metadata" ) ) - .and_then( | metadata | metadata.get( "branches" ) ) - .and_then( | branches | branches.as_array()) - .map - ( - | array | - array - .iter() - .filter_map( | value | value.as_str() ) - .map( String::from ) - .collect::< Vec< String > >() - ); - let mut user_and_repo = "".to_string(); - if let Some( core_url ) = &core_url + user_and_repo = url::git_info_extract( core_url )?; + } + Ok + ( + Self { - user_and_repo = url::git_info_extract( core_url )?; + core_url : core_url.unwrap_or_default(), + user_and_repo, + branches, + workspace_root : path.to_path_buf() } - Ok - ( - Self - { - core_url : core_url.unwrap_or_default(), - user_and_repo, - branches, - workspace_root : path.to_path_buf() - } - ) - } + ) } } @@ -259,6 +256,12 @@ mod private /// will mean that at this place the table with modules located in the directory module/core will be generated. /// The tags do not disappear after generation. /// Anything between the opening and closing tag will be destroyed. + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc // aaa : for Petro : typed errors // aaa : done pub fn readme_health_table_renew( path : &Path ) -> Result< (), HealthTableRenewError > @@ -284,8 +287,8 @@ mod private let mut tags_closures = vec![]; let mut tables = vec![]; - let open_caps = TAG_TEMPLATE.get().unwrap().captures_iter( &*contents ); - let close_caps = CLOSE_TAG.get().unwrap().captures_iter( &*contents ); + let open_caps = TAG_TEMPLATE.get().unwrap().captures_iter( &contents ); + let close_caps = CLOSE_TAG.get().unwrap().captures_iter( &contents ); // iterate by regex matches and generate table content for each dir which taken from open-tag for ( open_captures, close_captures ) in open_caps.zip( close_caps ) { @@ -324,6 +327,7 @@ mod private } /// Writes tables into a file at specified positions. + #[ allow( clippy::needless_pass_by_value ) ] fn tables_write_into_file ( tags_closures : Vec< ( usize, usize ) >, @@ -341,11 +345,11 @@ mod private ) in tags_closures.iter().zip( tables.iter() ) { - range_to_target_copy( &*contents, &mut buffer, start, *end_of_start_tag )?; + range_to_target_copy( &contents, &mut buffer, start, *end_of_start_tag )?; range_to_target_copy( con.as_bytes(), &mut buffer, 0,con.len() - 1 )?; start = *start_of_end_tag; } - range_to_target_copy( &*contents,&mut buffer,start,contents.len() - 1 )?; + range_to_target_copy( &contents,&mut buffer,start,contents.len() - 1 )?; file.set_len( 0 )?; file.seek( SeekFrom::Start( 0 ) )?; file.write_all( &buffer )?; @@ -353,7 +357,7 @@ mod private } /// Generate table from `table_parameters`. - /// Generate header, iterate over all modules in package (from table_parameters) and append row. + /// Generate header, iterate over all modules in package (from `table_parameters`) and append row. fn package_readme_health_table_generate ( workspace : &Workspace, @@ -369,7 +373,7 @@ mod private workspace .packages() )?; - let mut table = table_header_generate( parameters, &table_parameters ); + let mut table = table_header_generate( parameters, table_parameters ); for package_name in directory_names { let stability = if table_parameters.include_stability @@ -388,7 +392,7 @@ mod private { None }; - if parameters.core_url == "" + if parameters.core_url.is_empty() { let module_path = workspace .workspace_root() @@ -420,7 +424,7 @@ ensure that at least one remotest is present in git. ", &package_name, stability.as_ref(), parameters, - &table_parameters + table_parameters ) ); } @@ -429,6 +433,7 @@ ensure that at least one remotest is present in git. ", /// Return topologically sorted modules name, from packages list, in specified directory. // fn directory_names( path : PathBuf, packages : &[ WorkspacePackageRef< '_ > ] ) -> Result< Vec< String > > + #[ allow( clippy::type_complexity, clippy::unnecessary_wraps ) ] fn directory_names< 'a > ( path : PathBuf, @@ -478,7 +483,7 @@ ensure that at least one remotest is present in git. ", let module_graph = graph::construct( &module_packages_map ); let names : Vec< String > = graph::topological_sort_with_grouping( module_graph ) .into_iter() - .map + .flat_map ( | mut group | { @@ -486,7 +491,6 @@ ensure that at least one remotest is present in git. ", group } ) - .flatten() .map( | n | n.to_string() ) .collect(); @@ -511,13 +515,13 @@ ensure that at least one remotest is present in git. ", ); if table_parameters.include_stability { - let mut stability = stability_generate( &stability.as_ref().unwrap() ); + let mut stability = stability_generate( stability.as_ref().unwrap() ); stability.push_str( " |" ); rou.push_str( &stability ); } if parameters.branches.is_some() && table_parameters.include_branches { - rou.push_str( &branch_cells_generate( ¶meters, &module_name ) ); + rou.push_str( &branch_cells_generate( parameters, module_name ) ); } if table_parameters.include_docs { @@ -532,12 +536,12 @@ ensure that at least one remotest is present in git. ", } if table_parameters.include { - let path = Path::new( table_parameters.base_path.as_str() ).join( &module_name ); + let path = Path::new( table_parameters.base_path.as_str() ).join( module_name ); let p = Path::new( ¶meters.workspace_root ).join( &path ); // let path = table_parameters.base_path. - let example = if let Some( name ) = find_example_file( p.as_path(), &module_name ) + let example = if let Some( name ) = find_example_file( p.as_path(), module_name ) { - let path = path.to_string_lossy().replace( '\\', "/" ).replace( "/", "%2F" ); + let path = path.to_string_lossy().replace( '\\', "/" ).replace( '/', "%2F" ); let tmp = name.to_string_lossy().replace( '\\', "/" ); let file_name = tmp.split( '/' ).last().unwrap(); let name = file_name.strip_suffix( ".rs" ).unwrap(); @@ -552,14 +556,15 @@ ensure that at least one remotest is present in git. ", } else { - "".into() + String::new() }; - rou.push_str( &format!( " {} |", example ) ); + rou.push_str( &format!( " {example} |" ) ); } format!( "{rou}\n" ) } /// todo + #[ must_use ] pub fn find_example_file( base_path : &Path, module_name : &str ) -> Option< PathBuf > { let examples_dir = base_path.join("examples" ); @@ -568,19 +573,18 @@ ensure that at least one remotest is present in git. ", { if let Ok( entries ) = std::fs::read_dir( &examples_dir ) { - for entry in entries + for entry in entries.flatten() { - if let Ok( entry ) = entry + + let file_name = entry.file_name(); + if let Some( file_name_str ) = file_name.to_str() { - let file_name = entry.file_name(); - if let Some( file_name_str ) = file_name.to_str() + if file_name_str == format!( "{module_name}_trivial.rs" ) { - if file_name_str == format!( "{module_name}_trivial.rs" ) - { - return Some( entry.path() ) - } + return Some( entry.path() ) } } + } } } @@ -588,19 +592,20 @@ ensure that at least one remotest is present in git. ", // If module_trivial.rs doesn't exist, return any other file in the examples directory if let Ok( entries ) = std::fs::read_dir( &examples_dir ) { - for entry in entries + for entry in entries.flatten() { - if let Ok( entry ) = entry + + let file_name = entry.file_name(); + if let Some( file_name_str ) = file_name.to_str() { - let file_name = entry.file_name(); - if let Some( file_name_str ) = file_name.to_str() + if std::path::Path::new( file_name_str ) + .extension() + .map_or( false, | ext | ext.eq_ignore_ascii_case( "rs" ) ) { - if file_name_str.ends_with( ".rs" ) - { - return Some( entry.path() ) - } + return Some( entry.path() ) } } + } } @@ -608,6 +613,7 @@ ensure that at least one remotest is present in git. ", } /// Generate stability cell based on stability + #[ must_use ] pub fn stability_generate( stability : &Stability ) -> String { match stability @@ -642,7 +648,7 @@ ensure that at least one remotest is present in git. ", { for branch in branches { - header.push_str( format!( " {} |", branch ).as_str() ); + header.push_str( format!( " {branch} |" ).as_str() ); separator.push_str( "--------|" ); } } @@ -660,7 +666,7 @@ ensure that at least one remotest is present in git. ", separator.push_str( ":------:|" ); } - format!( "{}\n{}\n", header, separator ) + format!( "{header}\n{separator}\n" ) } /// Generate cells for each branch @@ -703,10 +709,7 @@ ensure that at least one remotest is present in git. ", target.extend_from_slice( &source[ from..= to ] ); return Ok( () ) } - else - { - Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Incorrect indexes" ))) - } + Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Incorrect indexes" ))) } } diff --git a/module/move/willbe/src/action/readme_modules_headers_renew.rs b/module/move/willbe/src/action/readme_modules_headers_renew.rs index aeba473c74..33b12bc29b 100644 --- a/module/move/willbe/src/action/readme_modules_headers_renew.rs +++ b/module/move/willbe/src/action/readme_modules_headers_renew.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: { @@ -130,9 +132,10 @@ mod private { /// Create `ModuleHeader` instance from the folder where Cargo.toml is stored. - fn from_cargo_toml< 'a > + #[ allow( clippy::needless_pass_by_value ) ] + fn from_cargo_toml ( - package : Package< 'a >, + package : Package< '_ >, default_discord_url : &Option< String >, ) -> Result< Self, ModulesHeadersRenewError > @@ -159,6 +162,7 @@ mod private } /// Convert `ModuleHeader`to header. + #[ allow( clippy::uninlined_format_args, clippy::wrong_self_convention ) ] fn to_header( self, workspace_path : &str ) -> Result< String, ModulesHeadersRenewError > { let discord = self.discord_url.map( | discord_url | @@ -181,7 +185,7 @@ mod private { let relative_path = pth::path::path_relative ( - workspace_path.try_into().unwrap(), + workspace_path.into(), name ) .to_string_lossy() @@ -190,7 +194,7 @@ mod private let relative_path = relative_path.replace( "\\", "/" ); // aaa : for Petro : use path_toools // aaa : used - let p = relative_path.replace( "/","%2F" ); + let p = relative_path.replace( '/',"%2F" ); format! ( " [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE={},RUN_POSTFIX=--example%20{}/https://github.com/{})", @@ -201,7 +205,7 @@ mod private } else { - "".into() + String::new() }; Ok( format! ( @@ -239,6 +243,12 @@ mod private /// [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://github.com/Username/test/actions/workflows/ModuleChainOfPackagesAPush.yml/badge.svg)](https://github.com/Username/test/actions/workflows/ModuleChainOfPackagesAPush.yml)[![docs.rs](https://img.shields.io/docsrs/_chain_of_packages_a?color=e3e8f0&logo=docs.rs)](https://docs.rs/_chain_of_packages_a)[![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F_chain_of_packages_a_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_chain_of_packages_a_trivial/https://github.com/Username/test) /// /// ``` + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc pub fn readme_modules_headers_renew( crate_dir : CrateDir ) -> ResultWithReport< ModulesHeadersRenewReport, ModulesHeadersRenewError > // -> Result< ModulesHeadersRenewReport, ( ModulesHeadersRenewReport, ModulesHeadersRenewError ) > @@ -253,7 +263,7 @@ mod private let paths : Vec< AbsolutePath > = workspace .packages() - .filter_map( | p | p.manifest_file().ok().and_then( | a | Some( a.inner() ) ) ) + .filter_map( | p | p.manifest_file().ok().map( crate::entity::files::ManifestFile::inner ) ) .collect(); report.found_files = paths @@ -285,7 +295,7 @@ mod private ) .err_with_report( &report )?; - let header = ModuleHeader::from_cargo_toml( pakage.into(), &discord_url ) + let header = ModuleHeader::from_cargo_toml( pakage, &discord_url ) .err_with_report( &report )?; let mut file = OpenOptions::new() @@ -324,6 +334,7 @@ mod private Ok( report ) } + #[ allow( clippy::uninlined_format_args ) ] fn header_content_generate< 'a > ( content : &'a str, @@ -340,7 +351,7 @@ mod private .unwrap() .replace ( - &content, + content, &format! ( "\n{}\n", diff --git a/module/move/willbe/src/action/test.rs b/module/move/willbe/src/action/test.rs index 0d22053121..2e23df5108 100644 --- a/module/move/willbe/src/action/test.rs +++ b/module/move/willbe/src/action/test.rs @@ -1,6 +1,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use entity::test::{ TestPlan, TestOptions, TestsReport, tests_run }; @@ -31,6 +32,7 @@ mod private /// - The `exclude_features` field is a vector of strings representing the names of features to exclude when running tests. /// - The `include_features` field is a vector of strings representing the names of features to include when running tests. #[ derive( Debug, Former ) ] + #[ allow( clippy::struct_excessive_bools ) ] pub struct TestsCommandOptions { dir : AbsolutePath, @@ -63,8 +65,14 @@ mod private /// It is possible to enable and disable various features of the crate. /// The function also has the ability to run tests in parallel using `Rayon` crate. /// The result of the tests is written to the structure `TestsReport` and returned as a result of the function execution. + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc // zzz : it probably should not be here // xxx : use newtype + #[ allow( clippy::too_many_lines ) ] pub fn test( o : TestsCommandOptions, dry : bool ) -> ResultWithReport< TestsReport, Error > // qqq : for Petro : typed error @@ -123,6 +131,7 @@ Try to install it with `rustup install {}` command(-s)", data_type::Either::Right( manifest ) => CrateDir::from( manifest ) }; + #[ allow( clippy::useless_conversion ) ] let workspace = Workspace ::try_from( CrateDir::try_from( path.clone() ).err_with_report( &report )? ) .err_with_report( &report )? diff --git a/module/move/willbe/src/action/workspace_renew.rs b/module/move/willbe/src/action/workspace_renew.rs index 05936758d9..ee27334708 100644 --- a/module/move/willbe/src/action/workspace_renew.rs +++ b/module/move/willbe/src/action/workspace_renew.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::fs; use std::path::Path; @@ -24,6 +26,7 @@ mod private impl WorkspaceTemplate { /// Returns template parameters + #[ must_use ] pub fn get_parameters( &self ) -> &TemplateParameters { &self.parameters @@ -41,9 +44,9 @@ mod private .form(); Self { - files : Default::default(), + files : WorkspaceTemplateFiles::default(), parameters, - values : Default::default(), + values : TemplateValues::default(), } } } @@ -134,6 +137,10 @@ mod private // qqq : for Petro : should return report // qqq : for Petro : should have typed error /// Creates workspace template + /// # Errors + /// qqq: doc + /// # Panics + /// qqq: doc pub fn action ( path : &Path, @@ -162,7 +169,7 @@ mod private "branches", wca::Value::String ( - branches.into_iter().map( | b | format!( r#""{}""#, b ) ).join( ", " ) + branches.into_iter().map( | b | format!( r#""{b}""# ) ).join( ", " ) ) ); template.files.create_all( path, &template.values )?; diff --git a/module/move/willbe/src/bin/cargo-will.rs b/module/move/willbe/src/bin/cargo-will.rs index 53aa39e51e..00c223060d 100644 --- a/module/move/willbe/src/bin/cargo-will.rs +++ b/module/move/willbe/src/bin/cargo-will.rs @@ -3,11 +3,11 @@ #![ doc( html_root_url = "https://docs.rs/willbe/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use::willbe::*; fn main() -> Result< (), error::untyped::Error > { let args = std::env::args().skip( 1 ).collect(); - Ok( willbe::run( args )? ) + willbe::run( args ) } diff --git a/module/move/willbe/src/bin/will.rs b/module/move/willbe/src/bin/will.rs index cbaad31299..b4c1df035a 100644 --- a/module/move/willbe/src/bin/will.rs +++ b/module/move/willbe/src/bin/will.rs @@ -6,12 +6,12 @@ #![ doc( html_root_url = "https://docs.rs/willbe/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use::willbe::*; fn main() -> Result< (), error::untyped::Error > { - Ok( willbe::run( std::env::args().collect() )? ) + willbe::run( std::env::args().collect() ) } // cargo_subcommand_metadata::description!( "xxx" ); diff --git a/module/move/willbe/src/bin/willbe.rs b/module/move/willbe/src/bin/willbe.rs index 5943573a67..1ad0cfeab7 100644 --- a/module/move/willbe/src/bin/willbe.rs +++ b/module/move/willbe/src/bin/willbe.rs @@ -3,10 +3,10 @@ #![ doc( html_root_url = "https://docs.rs/willbe/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -#[ allow( unused_imports ) ] +#[ allow( unused_imports, clippy::wildcard_imports ) ] use::willbe::*; fn main() -> Result< (), error::untyped::Error > { - Ok( willbe::run( std::env::args().collect() )? ) + willbe::run( std::env::args().collect() ) } diff --git a/module/move/willbe/src/command/cicd_renew.rs b/module/move/willbe/src/command/cicd_renew.rs index c82b45b8da..07f7f53d24 100644 --- a/module/move/willbe/src/command/cicd_renew.rs +++ b/module/move/willbe/src/command/cicd_renew.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use error::{ untyped::Context }; @@ -7,6 +8,8 @@ mod private /// /// Generate table. /// + /// # Errors + /// qqq: doc // qqq : typed error pub fn cicd_renew() -> error::untyped::Result< () > { diff --git a/module/move/willbe/src/command/deploy_renew.rs b/module/move/willbe/src/command/deploy_renew.rs index 7e1e68e476..36a90cdfe0 100644 --- a/module/move/willbe/src/command/deploy_renew.rs +++ b/module/move/willbe/src/command/deploy_renew.rs @@ -1,16 +1,21 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use wca::VerifiedCommand; use error::{ untyped::Context }; + #[ allow( clippy::wildcard_imports ) ] use action::deploy_renew::*; /// /// Create new deploy. /// + /// # Errors + /// qqq: doc // xxx : qqq : typed error + #[ allow( clippy::needless_pass_by_value ) ] pub fn deploy_renew( o : VerifiedCommand ) -> error::untyped::Result< () > { let current_dir = std::env::current_dir()?; diff --git a/module/move/willbe/src/command/features.rs b/module/move/willbe/src/command/features.rs index d57a8a7dc0..9fa2ec7596 100644 --- a/module/move/willbe/src/command/features.rs +++ b/module/move/willbe/src/command/features.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use action::features::FeaturesOptions; @@ -13,7 +14,10 @@ mod private /// /// List features of a package. /// + /// # Errors + /// qqq: doc + #[ allow( clippy::needless_pass_by_value ) ] pub fn features( o : VerifiedCommand ) -> error::untyped::Result< () > // qqq : use typed error { let path : PathBuf = o.args.get_owned( 0 ).unwrap_or_else( || "./".into() ); diff --git a/module/move/willbe/src/command/list.rs b/module/move/willbe/src/command/list.rs index 7687b6db1d..d474c313b1 100644 --- a/module/move/willbe/src/command/list.rs +++ b/module/move/willbe/src/command/list.rs @@ -1,6 +1,8 @@ -/// Define a private namespace for all its items. +/// Internal namespace. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -20,6 +22,7 @@ mod private use former::Former; #[ derive( Former ) ] + #[ allow( clippy::struct_excessive_bools ) ] struct ListProperties { #[ former( default = ListFormat::Tree ) ] @@ -46,6 +49,8 @@ mod private /// /// List workspace packages. /// + /// # Errors + /// qqq: doc // qqq : typed error pub fn list( o : VerifiedCommand ) -> error::untyped::Result< () > diff --git a/module/move/willbe/src/command/main_header.rs b/module/move/willbe/src/command/main_header.rs index b29229e9bd..2e850208bc 100644 --- a/module/move/willbe/src/command/main_header.rs +++ b/module/move/willbe/src/command/main_header.rs @@ -1,10 +1,14 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // use action; use error::untyped::{ Error }; /// Generates header to main Readme.md file. + /// + /// # Errors + /// qqq: doc // qqq : typed error pub fn readme_header_renew() -> error::untyped::Result< () > { diff --git a/module/move/willbe/src/command/mod.rs b/module/move/willbe/src/command/mod.rs index d54c8f2df5..5550a9233b 100644 --- a/module/move/willbe/src/command/mod.rs +++ b/module/move/willbe/src/command/mod.rs @@ -1,6 +1,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use wca::{ Type, CommandsAggregator, CommandsAggregatorFormer }; @@ -8,6 +9,7 @@ mod private /// Form CA commands grammar. /// + #[ allow( clippy::too_many_lines ) ] pub fn ca() -> CommandsAggregatorFormer { CommandsAggregator::former() diff --git a/module/move/willbe/src/command/publish.rs b/module/move/willbe/src/command/publish.rs index d02fa67bb5..5b3afd8930 100644 --- a/module/move/willbe/src/command/publish.rs +++ b/module/move/willbe/src/command/publish.rs @@ -1,6 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use colored::Colorize; @@ -11,6 +13,7 @@ mod private use channel::Channel; #[ derive( Former ) ] + #[ allow( clippy::struct_excessive_bools ) ] struct PublishProperties { #[ former( default = Channel::Stable ) ] @@ -28,6 +31,8 @@ mod private /// /// Publish package. /// + /// # Errors + /// qqq: doc pub fn publish( o : VerifiedCommand ) -> error::untyped::Result< () > // qqq : use typed error { @@ -39,14 +44,11 @@ mod private .get_owned( 0 ) .unwrap_or( std::path::PathBuf::from( "" ) ).display() ); - let prop_line = format! - ( - "{}", - o - .props - .iter() - .map( | p | format!( "{}:{}", p.0, p.1.to_string() ) ) - .collect::< Vec< _ > >().join(" ") ); + let prop_line = o + .props + .iter() + .map( | p | format!( "{}:{}", p.0, p.1 ) ) + .collect::< Vec< _ > >().join(" "); let patterns : Vec< _ > = o .args @@ -83,9 +85,9 @@ mod private if dry && !report.packages.is_empty() { - let args = if args_line.is_empty() { String::new() } else { format!(" {}", args_line) }; - let prop = if prop_line.is_empty() { String::new() } else { format!(" {}", prop_line) }; - let line = format!("will .publish{}{} dry:0", args, prop ); + let args = if args_line.is_empty() { String::new() } else { format!(" {args_line}" ) }; + let prop = if prop_line.is_empty() { String::new() } else { format!(" {prop_line}" ) }; + let line = format!("will .publish{args}{prop} dry:0" ); println!("To apply plan, call the command `{}`", line.blue() ); // aaa : for Petro : for Bohdan : bad. should be exact command with exact parameters // aaa : it`s already works diff --git a/module/move/willbe/src/command/publish_diff.rs b/module/move/willbe/src/command/publish_diff.rs index 6408de6de5..a35b453b2e 100644 --- a/module/move/willbe/src/command/publish_diff.rs +++ b/module/move/willbe/src/command/publish_diff.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::fs; @@ -31,6 +32,9 @@ mod private /// # Errors /// /// Returns an error if there is an issue with the command. + /// + /// # Panics + /// qqq: doc pub fn publish_diff( o : VerifiedCommand ) -> error::untyped::Result< () > // qqq : use typed error { diff --git a/module/move/willbe/src/command/readme_headers_renew.rs b/module/move/willbe/src/command/readme_headers_renew.rs index 3f7af310a7..86f46c5588 100644 --- a/module/move/willbe/src/command/readme_headers_renew.rs +++ b/module/move/willbe/src/command/readme_headers_renew.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // use action; // use error::{ err }; @@ -65,6 +67,8 @@ mod private } /// Aggregates two commands: `generate_modules_headers` & `generate_main_header` + /// # Errors + /// qqq: doc pub fn readme_headers_renew() -> error::untyped::Result< () > // qqq : use typed error { let mut report = ReadmeHeadersRenewReport::default(); diff --git a/module/move/willbe/src/command/readme_health_table_renew.rs b/module/move/willbe/src/command/readme_health_table_renew.rs index c91b5b6357..c569a0a1b8 100644 --- a/module/move/willbe/src/command/readme_health_table_renew.rs +++ b/module/move/willbe/src/command/readme_health_table_renew.rs @@ -1,5 +1,6 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use error::{ untyped::Context }; @@ -7,6 +8,8 @@ mod private /// /// Generate table. /// + /// # Errors + /// qqq: doc // qqq : typed error pub fn readme_health_table_renew() -> error::untyped::Result< () > { diff --git a/module/move/willbe/src/command/readme_modules_headers_renew.rs b/module/move/willbe/src/command/readme_modules_headers_renew.rs index 391205210e..bfd5ed7db1 100644 --- a/module/move/willbe/src/command/readme_modules_headers_renew.rs +++ b/module/move/willbe/src/command/readme_modules_headers_renew.rs @@ -1,10 +1,14 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // use path::AbsolutePath; // use error::{ untyped::Error }; /// Generate headers for workspace members + /// + /// # Errors + /// qqq: doc // qqq : typed error pub fn readme_modules_headers_renew() -> error::untyped::Result< () > { diff --git a/module/move/willbe/src/command/test.rs b/module/move/willbe/src/command/test.rs index 36fac78a27..118f44f8d6 100644 --- a/module/move/willbe/src/command/test.rs +++ b/module/move/willbe/src/command/test.rs @@ -1,6 +1,7 @@ /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use collection::HashSet; @@ -17,6 +18,7 @@ mod private use optimization::Optimization; #[ derive( Former, Debug ) ] + #[ allow( clippy::struct_excessive_bools ) ] struct TestsProperties { #[ former( default = true ) ] @@ -48,6 +50,8 @@ mod private } /// run tests in specified crate + /// # Errors + /// qqq: doc // qqq : don't use 1-prameter Result pub fn test( o : VerifiedCommand ) -> error::untyped::Result< () > // qqq : use typed error { @@ -60,15 +64,11 @@ mod private .unwrap_or( std::path::PathBuf::from( "" ) ) .display() ); - let prop_line = format! - ( - "{}", - o - .props - .iter() - .map( | p | format!( "{}:{}", p.0, p.1.to_string() ) ) - .collect::< Vec< _ > >().join(" ") - ); + let prop_line = o + .props + .iter() + .map( | p | format!( "{}:{}", p.0, p.1 ) ) + .collect::< Vec< _ > >().join(" "); let path : PathBuf = o.args.get_owned( 0 ).unwrap_or_else( || "./".into() ); let path = AbsolutePath::try_from( fs::canonicalize( path )? )?; @@ -127,9 +127,9 @@ Set at least one of them to true." ); { if dry { - let args = if args_line.is_empty() { String::new() } else { format!(" {}", args_line) }; - let prop = if prop_line.is_empty() { String::new() } else { format!(" {}", prop_line) }; - let line = format!("will .publish{}{} dry:0", args, prop); + let args = if args_line.is_empty() { String::new() } else { format!(" {args_line}" ) }; + let prop = if prop_line.is_empty() { String::new() } else { format!(" {prop_line}" ) }; + let line = format!( "will .publish{args}{prop} dry:0" ); println!("To apply plan, call the command `{}`", line.blue()); } else diff --git a/module/move/willbe/src/command/workspace_renew.rs b/module/move/willbe/src/command/workspace_renew.rs index 018046b146..a77254accd 100644 --- a/module/move/willbe/src/command/workspace_renew.rs +++ b/module/move/willbe/src/command/workspace_renew.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use former::Former; @@ -17,6 +19,8 @@ mod private /// /// Create new workspace. /// + /// # Errors + /// qqq: doc // qqq : typed error pub fn workspace_renew( o : VerifiedCommand ) -> error::untyped::Result< () > // qqq : use typed error diff --git a/module/move/willbe/src/entity/channel.rs b/module/move/willbe/src/entity/channel.rs index 65fe6b7716..92aa9f95d7 100644 --- a/module/move/willbe/src/entity/channel.rs +++ b/module/move/willbe/src/entity/channel.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: { @@ -9,6 +11,7 @@ mod private use path::Path; use collection::HashSet; use error::untyped::{ Error }; + #[ allow( clippy::wildcard_imports ) ] use process_tools::process::*; /// The `Channel` enum represents different release channels for rust. @@ -51,6 +54,9 @@ mod private /// Retrieves a list of available channels. /// /// This function takes a path and returns a `Result` with a vector of strings representing the available channels. + /// + /// # Errors + /// qqq: doc // qqq : typed error pub fn available_channels< P >( path : P ) -> error::untyped::Result< HashSet< Channel > > where diff --git a/module/move/willbe/src/entity/code.rs b/module/move/willbe/src/entity/code.rs index 5c8418bad8..0faf0cdf27 100644 --- a/module/move/willbe/src/entity/code.rs +++ b/module/move/willbe/src/entity/code.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -17,7 +19,9 @@ mod private pub trait AsCode { /// Converts the object to its code representation. - fn as_code< 'a >( &'a self ) -> std::io::Result< Cow< 'a, str > >; + /// # Errors + /// qqq: doc + fn as_code( &self ) -> std::io::Result< Cow< '_, str > >; } /// A trait for retrieving an iterator over items of a source file. diff --git a/module/move/willbe/src/entity/dependency.rs b/module/move/willbe/src/entity/dependency.rs index 5d09c1cea0..128a946061 100644 --- a/module/move/willbe/src/entity/dependency.rs +++ b/module/move/willbe/src/entity/dependency.rs @@ -1,6 +1,7 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // use crates_tools::CrateArchive; @@ -25,6 +26,7 @@ mod private /// The file system path for a local path dependency. /// Only produced on cargo 1.51+ + #[ must_use ] pub fn crate_dir( &self ) -> Option< CrateDir > { match &self.inner.path @@ -35,12 +37,14 @@ mod private } /// Name as given in the Cargo.toml. + #[ must_use ] pub fn name( &self ) -> String { self.inner.name.clone() } /// The kind of dependency this is. + #[ must_use ] pub fn kind( &self ) -> DependencyKind { match self.inner.kind @@ -53,6 +57,7 @@ mod private } /// Required version + #[ must_use ] pub fn req( &self ) -> semver::VersionReq { self.inner.req.clone() @@ -114,7 +119,7 @@ mod private { Self { - name : value.name().into(), + name : value.name(), crate_dir : value.crate_dir(), // path : value.path().clone().map( | path | AbsolutePath::try_from( path ).unwrap() ), } @@ -161,10 +166,16 @@ mod private // qqq : for Bohdan : poor description /// Recursive implementation of the `list` function - pub fn _list< 'a > + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc + #[ allow( clippy::needless_pass_by_value, clippy::implicit_hasher ) ] + pub fn _list ( workspace : &Workspace, // aaa : for Bohdan : no mut // aaa : no mut - package : &Package< 'a >, + package : &Package< '_ >, graph : &mut collection::HashMap< CrateId, collection::HashSet< CrateId > >, opts : DependenciesOptions ) @@ -183,7 +194,7 @@ mod private let manifest_file = &package.manifest_file(); let package = workspace - .package_find_by_manifest( &manifest_file ) + .package_find_by_manifest( manifest_file ) .ok_or( format_err!( "Package not found in the workspace with path : `{}`", manifest_file.as_ref().display() ) )?; let deps : collection::HashSet< _ > = package @@ -229,11 +240,14 @@ mod private /// # Returns /// /// If the operation is successful, returns a vector of `PathBuf` objects, where each `PathBuf` represents the path to a local dependency of the specified package. + /// # Errors + /// qqq: doc // qqq : typed error? - pub fn list< 'a > + #[ allow( clippy::needless_pass_by_value ) ] + pub fn list ( workspace : &mut Workspace, - package : &Package< 'a >, + package : &Package< '_ >, opts : DependenciesOptions ) // qqq : use typed error diff --git a/module/move/willbe/src/entity/diff.rs b/module/move/willbe/src/entity/diff.rs index 08b0638b77..9f6f4b7709 100644 --- a/module/move/willbe/src/entity/diff.rs +++ b/module/move/willbe/src/entity/diff.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -73,6 +75,9 @@ mod private /// # Returns /// /// Returns a new instance of the struct with the excluded items removed from the internal report. + /// # Panics + /// qqq: doc + #[ must_use ] pub fn exclude< Is, I >( mut self, items : Is ) -> Self where Is : Into< HashSet< I > >, @@ -89,11 +94,12 @@ mod private Self( map ) } - /// Checks if there are any changes in the DiffItems. + /// Checks if there are any changes in the `DiffItems`. /// /// # Returns - /// * `true` if there are changes in any of the DiffItems. - /// * `false` if all DiffItems are the same. + /// * `true` if there are changes in any of the `DiffItems`. + /// * `false` if all `DiffItems` are the same. + #[ must_use ] pub fn has_changes( &self ) -> bool { !self.0.iter().all( |( _, item )| matches!( item, DiffItem::File( Diff::Same( () ) ) )) @@ -112,9 +118,9 @@ mod private { match item { - Diff::Same( _ ) => writeln!( f, " {}", path.display() )?, - Diff::Add( _ ) => writeln!( f, "+ {} NEW", path.to_string_lossy().green() )?, - Diff::Rem( _ ) => writeln!( f, "- {} REMOVED", path.to_string_lossy().red() )?, + Diff::Same( () ) => writeln!( f, " {}", path.display() )?, + Diff::Add( () ) => writeln!( f, "+ {} NEW", path.to_string_lossy().green() )?, + Diff::Rem( () ) => writeln!( f, "- {} REMOVED", path.to_string_lossy().red() )?, }; } DiffItem::Content( items ) => @@ -127,7 +133,7 @@ mod private { match item { - Diff::Same( t ) => write!( f, "| {}", t )?, + Diff::Same( t ) => write!( f, "| {t}" )?, Diff::Add( t ) => write!( f, "| + {}", t.green() )?, Diff::Rem( t ) => write!( f, "| - {}", t.red() )?, }; @@ -156,6 +162,9 @@ mod private /// # Returns /// /// A `DiffReport` struct, representing the unique and shared attributes of the two crate archives. + /// # Panics + /// qqq: doc + #[ must_use ] pub fn crate_diff( left : &CrateArchive, right : &CrateArchive ) -> DiffReport { let mut report = DiffReport::default(); diff --git a/module/move/willbe/src/entity/features.rs b/module/move/willbe/src/entity/features.rs index 300fa7ca2f..8212fdef42 100644 --- a/module/move/willbe/src/entity/features.rs +++ b/module/move/willbe/src/entity/features.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use collection::{ BTreeSet, HashSet }; use error::untyped::{ bail }; // xxx @@ -38,7 +40,10 @@ mod private /// let feature_combinations = features_powerset( &package, power, &exclude_features, &include_features, enabled_features, false, false ); /// // Use `feature_combinations` as needed. /// ``` - + /// + /// # Errors + /// qqq: doc + #[ allow( clippy::too_many_arguments ) ] pub fn features_powerset ( package : WorkspacePackageRef< '_ >, @@ -96,6 +101,7 @@ mod private } /// Calculate estimate for `features_powerset.length` + #[ must_use ] pub fn estimate_with ( n : usize, diff --git a/module/move/willbe/src/entity/files.rs b/module/move/willbe/src/entity/files.rs index d8941dfa27..b6cc1ac89a 100644 --- a/module/move/willbe/src/entity/files.rs +++ b/module/move/willbe/src/entity/files.rs @@ -1,6 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: diff --git a/module/move/willbe/src/entity/files/crate_dir.rs b/module/move/willbe/src/entity/files/crate_dir.rs index 7ea3424e56..7bbf133bfc 100644 --- a/module/move/willbe/src/entity/files/crate_dir.rs +++ b/module/move/willbe/src/entity/files/crate_dir.rs @@ -1,3 +1,7 @@ +#![ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] + + +#[ allow( clippy::wildcard_imports ) ] use crate::*; use entity:: @@ -34,6 +38,7 @@ impl CrateDir /// Returns inner type which is an absolute path. #[ inline( always ) ] + #[ must_use ] pub fn absolute_path( self ) -> AbsolutePath { self.0 @@ -41,6 +46,7 @@ impl CrateDir /// Returns path to manifest aka cargo file. #[ inline( always ) ] + #[ must_use ] pub fn manifest_file( self ) -> ManifestFile { self.into() diff --git a/module/move/willbe/src/entity/files/either.rs b/module/move/willbe/src/entity/files/either.rs index ef151d616c..0caa927f4f 100644 --- a/module/move/willbe/src/entity/files/either.rs +++ b/module/move/willbe/src/entity/files/either.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::wildcard_imports ) ] use crate::*; use core:: { @@ -22,7 +23,8 @@ pub struct EitherDirOrFile( data_type::Either< CrateDir, ManifestFile > ); impl EitherDirOrFile { - /// Returns inner type which is an data_type::Either< CrateDir, ManifestFile >. + /// Returns inner type which is an `data_type::Either`< `CrateDir`, `ManifestFile` >. + #[ must_use ] pub fn inner( self ) -> data_type::Either< CrateDir, ManifestFile > { self.0 @@ -75,6 +77,7 @@ impl Deref for EitherDirOrFile { type Target = Path; + #[ allow( clippy::explicit_deref_methods ) ] fn deref( &self ) -> &Self::Target { self.0.deref() @@ -83,6 +86,7 @@ impl Deref for EitherDirOrFile impl DerefMut for EitherDirOrFile { + #[ allow( clippy::explicit_deref_methods ) ] fn deref_mut( &mut self ) -> &mut Self::Target { self.0.deref_mut() diff --git a/module/move/willbe/src/entity/files/manifest_file.rs b/module/move/willbe/src/entity/files/manifest_file.rs index 78af49e41b..149b50a365 100644 --- a/module/move/willbe/src/entity/files/manifest_file.rs +++ b/module/move/willbe/src/entity/files/manifest_file.rs @@ -1,3 +1,6 @@ +#![ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] + +#[ allow( clippy::wildcard_imports ) ] use crate::*; use entity:: @@ -42,6 +45,7 @@ impl ManifestFile /// Returns inner type whicj is an absolute path. #[ inline( always ) ] + #[ must_use ] pub fn inner( self ) -> AbsolutePath { self.0 @@ -49,6 +53,7 @@ impl ManifestFile /// Returns path to crate dir. #[ inline( always ) ] + #[ must_use ] pub fn crate_dir( self ) -> CrateDir { self.into() diff --git a/module/move/willbe/src/entity/files/source_file.rs b/module/move/willbe/src/entity/files/source_file.rs index b895d3eec2..630f434006 100644 --- a/module/move/willbe/src/entity/files/source_file.rs +++ b/module/move/willbe/src/entity/files/source_file.rs @@ -1,3 +1,7 @@ +#![ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] + + +#[ allow( clippy::wildcard_imports ) ] use crate::*; use entity:: @@ -35,6 +39,7 @@ impl SourceFile /// Returns inner type which is an absolute path. #[ inline( always ) ] + #[ must_use ] pub fn inner( self ) -> AbsolutePath { self.0 @@ -229,15 +234,15 @@ impl CodeItems for SourceFile fn items( &self ) -> impl IterTrait< '_, syn::Item > { // xxx : use closures instead of expect - let content = fs::read_to_string( self.as_ref() ).expect( &format!( "Failed to parse file {self}" ) ); - let parsed : syn::File = syn::parse_file( &content ).expect( &format!( "Failed to parse file {self}" ) ); + let content = fs::read_to_string( self.as_ref() ).unwrap_or_else( | _ | panic!( "Failed to parse file {self}" ) ); + let parsed : syn::File = syn::parse_file( &content ).unwrap_or_else( | _ | panic!( "Failed to parse file {self}" ) ); parsed.items.into_iter() } } impl AsCode for SourceFile { - fn as_code< 'a >( &'a self ) -> std::io::Result< Cow< 'a, str > > + fn as_code( &self ) -> std::io::Result< Cow< '_, str > > { Ok( Cow::Owned( std::fs::read_to_string( self.as_ref() )? ) ) } diff --git a/module/move/willbe/src/entity/git.rs b/module/move/willbe/src/entity/git.rs index eeeddfd5a4..00ba0d6b2f 100644 --- a/module/move/willbe/src/entity/git.rs +++ b/module/move/willbe/src/entity/git.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::fmt; @@ -53,6 +55,9 @@ mod private } /// Performs a Git commit operation using the provided options + /// # Errors + /// qqq: doc + #[ allow( clippy::needless_pass_by_value ) ] pub fn perform_git_commit( o : GitOptions ) -> error::untyped::Result< ExtendedGitReport > // qqq : use typed error { diff --git a/module/move/willbe/src/entity/manifest.rs b/module/move/willbe/src/entity/manifest.rs index 5a0f7a58aa..89c688be5f 100644 --- a/module/move/willbe/src/entity/manifest.rs +++ b/module/move/willbe/src/entity/manifest.rs @@ -1,6 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -100,12 +102,16 @@ mod private } /// Returns path to `Cargo.toml`. + #[ must_use ] pub fn manifest_file( &self ) -> &AbsolutePath { &self.manifest_file } /// Path to directory where `Cargo.toml` located. + /// # Panics + /// qqq: doc + #[ must_use ] pub fn crate_dir( &self ) -> CrateDir { self.manifest_file.parent().unwrap().try_into().unwrap() @@ -113,6 +119,8 @@ mod private } /// Store manifest. + /// # Errors + /// qqq: doc pub fn store( &self ) -> io::Result< () > { fs::write( &self.manifest_file, self.data.to_string() )?; @@ -121,6 +129,7 @@ mod private } /// Check that the current manifest is the manifest of the package (can also be a virtual workspace). + #[ must_use ] pub fn package_is( &self ) -> bool { // let data = self.data.as_ref().ok_or_else( || ManifestError::EmptyManifestData )?; @@ -129,7 +138,8 @@ mod private } /// Check that module is local. - /// The package is defined as local if the `publish` field is set to `false' or the registers are specified. + /// The package is defined as local if the `publish` field is set to `false` or the registers are specified. + #[ must_use ] pub fn local_is( &self ) -> bool { // let data = self.data.as_ref().ok_or_else( || ManifestError::EmptyManifestData )?; @@ -137,7 +147,7 @@ mod private if data.get( "package" ).is_some() && data[ "package" ].get( "name" ).is_some() { let remote = data[ "package" ].get( "publish" ).is_none() - || data[ "package" ][ "publish" ].as_bool().or( Some( true ) ).unwrap(); + || data[ "package" ][ "publish" ].as_bool().unwrap_or( true ); return !remote; } @@ -146,6 +156,8 @@ mod private } /// Retrieves the repository URL of a package from its `Cargo.toml` file. + /// # Errors + /// qqq: doc // qqq : use typed error pub fn repo_url( crate_dir : &CrateDir ) -> error::untyped::Result< String > { @@ -168,7 +180,7 @@ mod private else { let report = tool::git::ls_remote_url( crate_dir.clone().absolute_path() )?; - url::repo_url_extract( &report.out.trim() ).ok_or_else( || format_err!( "Fail to extract repository url from git remote.") ) + url::repo_url_extract( report.out.trim() ).ok_or_else( || format_err!( "Fail to extract repository url from git remote.") ) } } else diff --git a/module/move/willbe/src/entity/package.rs b/module/move/willbe/src/entity/package.rs index 5e53b6ea19..4c5e3cd3e8 100644 --- a/module/move/willbe/src/entity/package.rs +++ b/module/move/willbe/src/entity/package.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -121,6 +123,9 @@ mod private { /// Path to `Cargo.toml` + /// # Panics + /// qqq: doc + #[ must_use ] pub fn manifest_file( &self ) -> ManifestFile { match self @@ -131,6 +136,9 @@ mod private } /// Path to folder with `Cargo.toml` + /// # Panics + /// qqq: doc + #[ must_use ] pub fn crate_dir( &self ) -> CrateDir { match self @@ -141,6 +149,10 @@ mod private } /// Package version + /// # Errors + /// qqq: doc + /// # Panics + /// qqq: doc pub fn version( &self ) -> Result< String, PackageError > { match self @@ -161,6 +173,7 @@ mod private } /// Check that module is local. + #[ must_use ] pub fn local_is( &self ) -> bool { match self @@ -179,6 +192,8 @@ mod private } /// Returns the `Manifest` + /// # Errors + /// qqq: doc pub fn manifest( &self ) -> Result< Manifest, PackageError > { match self @@ -205,14 +220,16 @@ mod private /// - `false` if there is no need to publish the package. /// /// Panics if the package is not loaded or local package is not packed. + /// # Errors + /// qqq: doc - pub fn publish_need< 'a >( package : &Package< 'a >, path : Option< path::PathBuf > ) -> Result< bool, PackageError > + pub fn publish_need( package : &Package< '_ >, path : Option< path::PathBuf > ) -> Result< bool, PackageError > { let name = package.name()?; let version = package.version()?; let local_package_path = path - .map( | p | p.join( format!( "package/{0}-{1}.crate", name, version ) ) ) - .unwrap_or( packed_crate::local_path( &name, &version, package.crate_dir() ).map_err( | _ | PackageError::LocalPath )? ); + .map( | p | p.join( format!( "package/{name}-{version}.crate" ) ) ) + .unwrap_or( packed_crate::local_path( name, &version, package.crate_dir() ).map_err( | _ | PackageError::LocalPath )? ); let local_package = CrateArchive::read( local_package_path ).map_err( | _ | PackageError::ReadArchive )?; let remote_package = match CrateArchive::download_crates_io( name, version ) diff --git a/module/move/willbe/src/entity/package_md_extension.rs b/module/move/willbe/src/entity/package_md_extension.rs index 29fe95b645..ab31564b83 100644 --- a/module/move/willbe/src/entity/package_md_extension.rs +++ b/module/move/willbe/src/entity/package_md_extension.rs @@ -1,27 +1,42 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Md's extension for workspace pub trait PackageMdExtension { /// Package name + /// # Errors + /// qqq: doc fn name( &self ) -> Result< &str, package::PackageError >; /// Stability + /// # Errors + /// qqq: doc fn stability( &self ) -> Result< action::readme_health_table_renew::Stability, package::PackageError >; /// Repository + /// # Errors + /// qqq: doc fn repository( &self ) -> Result< Option< String >, package::PackageError >; /// Discord url + /// # Errors + /// qqq: doc fn discord_url( &self ) -> Result< Option< String >, package::PackageError >; } impl < 'a > package::Package< 'a > { /// Package name + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc pub fn name( &self ) -> Result< &str, package::PackageError > { match self @@ -43,6 +58,9 @@ mod private } /// Stability + /// + /// # Errors + /// qqq: doc pub fn stability( &self ) -> Result< action::readme_health_table_renew::Stability, package::PackageError > { // aaa : for Petro : bad : first of all it should be in trait. also there is duplicated code @@ -78,6 +96,9 @@ mod private } /// Repository + /// + /// # Errors + /// qqq: doc pub fn repository( &self ) -> Result< Option< String >, package::PackageError > { match self @@ -93,7 +114,7 @@ mod private data[ "package" ] .get( "repository" ) .and_then( | r | r.as_str() ) - .map( | r | r.to_string()) + .map( std::string::ToString::to_string ) ) } Self::WorkspacePackageRef( package ) => @@ -104,6 +125,9 @@ mod private } /// Discord url + /// + /// # Errors + /// qqq: doc pub fn discord_url( &self ) -> Result< Option< String >, package::PackageError > { match self @@ -116,12 +140,12 @@ mod private self.package_metadata() .and_then( | m | m.get( "discord_url" ) ) .and_then( | url | url.as_str() ) - .map( | r | r.to_string() ) + .map( std::string::ToString::to_string ) ) } Self::WorkspacePackageRef( package ) => { - Ok( package.metadata()[ "discord_url" ].as_str().map( | url | url.to_string() ) ) + Ok( package.metadata()[ "discord_url" ].as_str().map( std::string::ToString::to_string ) ) } } } diff --git a/module/move/willbe/src/entity/packages.rs b/module/move/willbe/src/entity/packages.rs index 6dd4006db3..5525c8a99d 100644 --- a/module/move/willbe/src/entity/packages.rs +++ b/module/move/willbe/src/entity/packages.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: { @@ -16,6 +18,7 @@ mod private /// A configuration struct for specifying optional filters when using the /// `filter` function. It allows users to provide custom filtering /// functions for packages and dependencies. + #[ allow( clippy::type_complexity ) ] #[ derive( Default ) ] pub struct FilterMapOptions { diff --git a/module/move/willbe/src/entity/packed_crate.rs b/module/move/willbe/src/entity/packed_crate.rs index 77da22b98e..1cd95c7097 100644 --- a/module/move/willbe/src/entity/packed_crate.rs +++ b/module/move/willbe/src/entity/packed_crate.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -21,10 +23,13 @@ mod private /// /// # Returns : /// The local packed `.crate` file of the package + /// + /// # Errors + /// qqq: doc // qqq : typed error pub fn local_path< 'a >( name : &'a str, version : &'a str, crate_dir : CrateDir ) -> error::untyped::Result< PathBuf > { - let buf = format!( "package/{0}-{1}.crate", name, version ); + let buf = format!( "package/{name}-{version}.crate" ); let workspace = Workspace::try_from( crate_dir )?; let mut local_package_path = PathBuf::new(); @@ -37,6 +42,11 @@ mod private /// /// Get data of remote package from crates.io. /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc // qqq : typed error pub fn download< 'a >( name : &'a str, version : &'a str ) -> error::untyped::Result< Vec< u8 > > { @@ -45,7 +55,7 @@ mod private .timeout_write( Duration::from_secs( 5 ) ) .build(); let mut buf = String::new(); - write!( &mut buf, "https://static.crates.io/crates/{0}/{0}-{1}.crate", name, version )?; + write!( &mut buf, "https://static.crates.io/crates/{name}/{name}-{version}.crate" )?; let resp = agent.get( &buf[ .. ] ).call().context( "Get data of remote package" )?; diff --git a/module/move/willbe/src/entity/progress_bar.rs b/module/move/willbe/src/entity/progress_bar.rs index c9fef4cf07..db61b1f078 100644 --- a/module/move/willbe/src/entity/progress_bar.rs +++ b/module/move/willbe/src/entity/progress_bar.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { /// The `ProgressBar` structure is used to display progress indicators in the terminal. @@ -52,7 +53,8 @@ mod private /// # Returns /// /// A `ProgressBar` instance that can be used to update and display progress. - pub fn progress_bar< 'a >( &'a self, variants_len : u64 ) -> ProgressBar< 'a > + #[ must_use ] + pub fn progress_bar( &self, variants_len : u64 ) -> ProgressBar< '_ > { let progress_bar = { diff --git a/module/move/willbe/src/entity/publish.rs b/module/move/willbe/src/entity/publish.rs index f7cc9965c8..93af0e97fc 100644 --- a/module/move/willbe/src/entity/publish.rs +++ b/module/move/willbe/src/entity/publish.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::fmt; @@ -189,6 +191,7 @@ mod private .map_err( |( _, _e )| fmt::Error )?; let action::list::ListReport::Tree( list ) = list else { unreachable!() }; + #[ allow( clippy::items_after_statements ) ] fn callback( name_bump_report : &collection::HashMap< &String, ( String, String ) >, mut r : tool::ListNodeReport ) -> tool::ListNodeReport { if let Some(( old, new )) = name_bump_report.get( &r.name ) @@ -204,10 +207,10 @@ mod private let printer = list; let rep : Vec< tool::ListNodeReport > = printer.iter().map( | printer | printer.info.clone() ).collect(); let list: Vec< tool::ListNodeReport > = rep.into_iter().map( | r | callback( &name_bump_report, r ) ).collect(); - let printer : Vec< tool::TreePrinter > = list.iter().map( | rep | tool::TreePrinter::new( rep ) ).collect(); + let printer : Vec< tool::TreePrinter > = list.iter().map( tool::TreePrinter::new ).collect(); let list = action::list::ListReport::Tree( printer ); - writeln!( f, "{}", list )?; + writeln!( f, "{list}" )?; } Ok( () ) @@ -264,11 +267,11 @@ mod private } if let Some( exclude_dev_dependencies ) = &self.storage.exclude_dev_dependencies { - plan = plan.exclude_dev_dependencies( *exclude_dev_dependencies ) + plan = plan.exclude_dev_dependencies( *exclude_dev_dependencies ); } if let Some( commit_changes ) = &self.storage.commit_changes { - plan = plan.commit_changes( *commit_changes ) + plan = plan.commit_changes( *commit_changes ); } let plan = plan .channel( channel ) @@ -335,11 +338,11 @@ mod private return Ok( () ) } let info = get_info.as_ref().unwrap(); - write!( f, "{}", info )?; + write!( f, "{info}" )?; if let Some( bump ) = bump { - writeln!( f, "{}", bump )?; + writeln!( f, "{bump}" )?; } if let Some( add ) = add { @@ -371,7 +374,10 @@ mod private /// # Returns /// /// * `Result` - The result of the publishing operation, including information about the publish, version bump, and git operations. - + /// + /// # Errors + /// qqq: doc + #[ allow( clippy::option_map_unit_fn ) ] pub fn perform_package_publish( instruction : PackagePublishInstruction ) -> ResultWithReport< PublishReport, Error > { let mut report = PublishReport::default(); @@ -432,7 +438,7 @@ mod private if let Some( git_root ) = git_root.as_ref() { - let res = tool::git::push( &git_root, dry ).err_with_report( &report )?; + let res = tool::git::push( git_root, dry ).err_with_report( &report )?; report.push = Some( res ); } @@ -448,6 +454,9 @@ mod private /// # Returns /// /// Returns a `Result` containing a vector of `PublishReport` if successful, else an error. + /// + /// # Errors + /// qqq: doc pub fn perform_packages_publish( plan : PublishPlan ) -> error::untyped::Result< Vec< PublishReport > > // qqq : use typed error { diff --git a/module/move/willbe/src/entity/table.rs b/module/move/willbe/src/entity/table.rs index 38e789686c..a49acf6350 100644 --- a/module/move/willbe/src/entity/table.rs +++ b/module/move/willbe/src/entity/table.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { use std::fmt::{Display, Formatter}; @@ -13,13 +14,14 @@ mod private { fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result { - writeln!( f, "{}", self.inner.to_string() ) + writeln!( f, "{}", self.inner ) } } impl Table { /// Create an empty table. + #[ must_use ] pub fn new() -> Self { Self @@ -57,7 +59,7 @@ mod private fn default_format() -> prettytable::format::TableFormat { - let format = prettytable::format::FormatBuilder::new() + prettytable::format::FormatBuilder::new() .column_separator( ' ' ) .borders( ' ' ) .separators @@ -66,8 +68,7 @@ mod private prettytable::format::LineSeparator::new( '-', '+', '+', '+' ) ) .padding( 1, 1 ) - .build(); - format + .build() } /// Represent a table row made of cells. @@ -89,9 +90,11 @@ mod private } } + #[ allow( clippy::new_without_default ) ] impl Row { /// Create an row of length size, with empty strings stored. + #[ must_use ] pub fn new() -> Self { Self diff --git a/module/move/willbe/src/entity/test.rs b/module/move/willbe/src/entity/test.rs index b8b7b67227..4ec5fe190d 100644 --- a/module/move/willbe/src/entity/test.rs +++ b/module/move/willbe/src/entity/test.rs @@ -1,7 +1,10 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; + #[ allow( clippy::wildcard_imports ) ] use table::*; // qqq : for Bohdan no asterisk imports, but in special cases use std:: @@ -10,6 +13,7 @@ mod private sync, }; use colored::Colorize as _; + #[ allow( clippy::wildcard_imports ) ] use process_tools::process::*; use error:: { @@ -82,6 +86,10 @@ mod private /// `with_all_features` - If it's true - add to powerset one subset which contains all features. /// `with_none_features` - If it's true - add to powerset one empty subset. /// `variants_cap` - Maximum of subset in powerset + /// + /// # Errors + /// qqq: doc + #[ allow( clippy::needless_pass_by_value, clippy::too_many_arguments ) ] pub fn try_from< 'a > ( packages : impl core::iter::Iterator< Item = WorkspacePackageRef< 'a > >, @@ -148,7 +156,7 @@ mod private } all_features.extend( features ); } - let mut ff = Vec::from_iter( self.enabled_features.iter().cloned() ); + let mut ff: Vec< _ > = self.enabled_features.iter().cloned().collect(); for feature in all_features { if !ff.contains( &feature ) @@ -184,7 +192,7 @@ mod private } // aaa : for Petro : bad, DRY // aaa : replace with method - writeln!( f, "{}", table )?; + writeln!( f, "{table}" )?; Ok( () ) } } @@ -202,9 +210,10 @@ mod private /// `with_all_features` - If it's true - add to powerset one subset which contains all features. /// `with_none_features` - If it's true - add to powerset one empty subset. /// `variants_cap` - Maximum of subset in powerset - fn try_from< 'a > + #[ allow( clippy::too_many_arguments ) ] + fn try_from ( - package : WorkspacePackageRef< 'a >, + package : WorkspacePackageRef< '_ >, channels : &collection::HashSet< channel::Channel >, power : u32, include_features : &[ String ], @@ -241,8 +250,8 @@ mod private ( TestVariant { - channel : channel.clone(), - optimization : optimization.clone(), + channel : *channel, + optimization : *optimization, features : feature.clone(), } ); @@ -314,10 +323,11 @@ mod private /// Represents the options for the test. #[ derive( Debug, former::Former, Clone ) ] + #[ allow( clippy::struct_excessive_bools ) ] pub struct SingleTestOptions { /// Specifies the release channels for rust. - /// More details : https://rust-lang.github.io/rustup/concepts/channels.html#:~:text=Rust%20is%20released%20to%20three,releases%20are%20made%20every%20night. + /// More details : . channel : channel::Channel, /// Specifies the optimization for rust. optimization : optimization::Optimization, @@ -335,7 +345,7 @@ mod private temp_directory_path : Option< path::PathBuf >, /// A boolean indicating whether to perform a dry run or not. dry : bool, - /// RUST_BACKTRACE + /// `RUST_BACKTRACE` #[ former( default = true ) ] backtrace : bool, } @@ -373,6 +383,10 @@ mod private /// /// Returns a `Result` containing a `Report` if the command is executed successfully, /// or an error if the command fails to execute. + /// + /// # Errors + /// qqq: doc + #[ allow( clippy::needless_pass_by_value ) ] pub fn _run< P >( path : P, options : SingleTestOptions ) -> Result< Report, Report > // xxx where @@ -414,7 +428,7 @@ mod private /// Plan for testing pub plan : TestPlan, - /// `concurrent` - A usize value indicating how much test`s can be run at the same time. + /// `concurrent` - A usize value indicating how much test's can be run at the same time. pub concurrent : u32, /// `temp_path` - path to temp directory. @@ -430,6 +444,7 @@ mod private // aaa : for Petro : remove after Former fix // aaa : done + #[ allow( clippy::missing_fields_in_debug ) ] impl fmt::Debug for TestOptions { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> std::fmt::Result @@ -499,7 +514,7 @@ mod private } all_features.extend( features ); } - let mut ff = Vec::from_iter( self.enabled_features.iter().cloned() ); + let mut ff: Vec< _ > = self.enabled_features.iter().cloned().collect(); for feature in all_features { if !ff.contains( &feature ) @@ -537,8 +552,8 @@ mod private Err( report ) => { failed += 1; - let mut out = report.out.replace( "\n", "\n " ); - out.push_str( "\n" ); + let mut out = report.out.replace( '\n', "\n " ); + out.push( '\n' ); write!( f, " ❌ > {}\n\n{out}", report.command )?; "❌" }, @@ -555,7 +570,7 @@ mod private } // aaa : for Petro : bad, DRY // aaa : replace with method - writeln!( f, "{}", table )?; + writeln!( f, "{table}" )?; writeln!( f, " {}", generate_summary_message( failed, success ) )?; Ok( () ) @@ -617,7 +632,7 @@ mod private writeln!( f, "Successful :" )?; for report in &self.success_reports { - writeln!( f, "{}", report )?; + writeln!( f, "{report}" )?; } } if !self.failure_reports.is_empty() @@ -625,10 +640,11 @@ mod private writeln!( f, "Failure :" )?; for report in &self.failure_reports { - writeln!( f, "{}", report )?; + writeln!( f, "{report}" )?; } } writeln!( f, "Global report" )?; + #[ allow( clippy::cast_possible_wrap, clippy::cast_possible_truncation ) ] writeln!( f, " {}", generate_summary_message( self.failure_reports.len() as i32, self.success_reports.len() as i32 ) )?; Ok( () ) @@ -637,13 +653,17 @@ mod private /// `tests_run` is a function that runs tests on a given package with specified arguments. /// It returns a `TestReport` on success, or a `TestReport` and an `Error` on failure. + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc pub fn run( options : &PackageTestOptions< '_ > ) -> ResultWithReport< TestReport, TestError > // -> Result< TestReport, ( TestReport, TestError ) > { - let mut report = TestReport::default(); - report.dry = options.dry; - report.enabled_features = options.plan.enabled_features.clone(); + let report = TestReport { dry: options.dry, enabled_features: options.plan.enabled_features.clone(), ..Default::default() }; let report = sync::Arc::new( sync::Mutex::new( report ) ); let crate_dir = options.plan.crate_dir.clone(); @@ -678,7 +698,7 @@ mod private { let _s = { - let s = options.progress_bar.multi_progress.add( indicatif::ProgressBar::new_spinner().with_message( format!( "{}", variant ) ) ); + let s = options.progress_bar.multi_progress.add( indicatif::ProgressBar::new_spinner().with_message( format!( "{variant}" ) ) ); s.enable_steady_tick( std::time::Duration::from_millis( 100 ) ); s }; @@ -712,6 +732,11 @@ mod private } /// Run tests for given packages. + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc pub fn tests_run( args : &TestOptions ) -> ResultWithReport< TestsReport, TestError > // -> Result< TestsReport, ( TestsReport, TestError ) > @@ -720,8 +745,7 @@ mod private let multi_progress = progress_bar::MultiProgress::default(); #[ cfg( feature = "progress_bar" ) ] let mm = &multi_progress; - let mut report = TestsReport::default(); - report.dry = args.dry; + let report = TestsReport { dry: args.dry, ..Default::default() }; let report = sync::Arc::new( sync::Mutex::new( report ) ); let pool = rayon::ThreadPoolBuilder::new().use_current_thread().num_threads( args.concurrent as usize ).build().unwrap(); pool.scope diff --git a/module/move/willbe/src/entity/version.rs b/module/move/willbe/src/entity/version.rs index 7018f00481..085b7494ee 100644 --- a/module/move/willbe/src/entity/version.rs +++ b/module/move/willbe/src/entity/version.rs @@ -1,6 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use std:: @@ -17,7 +19,7 @@ mod private use package::Package; use { error::untyped::format_err, iter::Itertools }; - /// Wrapper for a SemVer structure + /// Wrapper for a `SemVer` structure #[ derive( Debug, Clone, Eq, PartialEq, Ord, PartialOrd ) ] pub struct Version( SemVersion ); @@ -55,7 +57,7 @@ mod private { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { - write!( f, "{}", self.0.to_string() ) + write!( f, "{}", self.0 ) } } @@ -64,6 +66,7 @@ mod private /// Bump a version with default strategy /// /// This function increases first not 0 number + #[ must_use ] pub fn bump( self ) -> Self { let mut ver = self.0; @@ -187,6 +190,9 @@ mod private /// /// Returns a result containing the extended bump report if successful. /// + /// + /// # Errors + /// qqq: doc // qqq : should be typed error, apply err_with // qqq : don't use 1-prameter Result pub fn bump( o : BumpOptions ) -> Result< ExtendedBumpReport > @@ -211,7 +217,7 @@ mod private { // let data = package_manifest.data.as_mut().unwrap(); let data = &mut package_manifest.data; - data[ "package" ][ "version" ] = value( &o.new_version.to_string() ); + data[ "package" ][ "version" ] = value( o.new_version.to_string() ); package_manifest.store()?; } report.changed_files = vec![ manifest_file ]; @@ -226,9 +232,9 @@ mod private let item = if let Some( item ) = data.get_mut( "package" ) { item } else if let Some( item ) = data.get_mut( "workspace" ) { item } else { return Err( format_err!( "{report:?}\nThe manifest nor the package and nor the workspace" ) ); }; - if let Some( dependency ) = item.get_mut( "dependencies" ).and_then( | ds | ds.get_mut( &name ) ) + if let Some( dependency ) = item.get_mut( "dependencies" ).and_then( | ds | ds.get_mut( name ) ) { - if let Some( previous_version ) = dependency.get( "version" ).and_then( | v | v.as_str() ).map( | v | v.to_string() ) + if let Some( previous_version ) = dependency.get( "version" ).and_then( | v | v.as_str() ).map( std::string::ToString::to_string ) { if previous_version.starts_with('~') { @@ -256,6 +262,12 @@ mod private /// # Returns /// /// Returns `Ok(())` if the version is reverted successfully. Returns `Err` with an error message if there is any issue with reverting the version. + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc // qqq : don't use 1-prameter Result pub fn revert( report : &ExtendedBumpReport ) -> error::untyped::Result< () > // qqq : use typed error { @@ -267,13 +279,13 @@ mod private { if let Some( dependency ) = item_maybe_with_dependencies.get_mut( "dependencies" ).and_then( | ds | ds.get_mut( name ) ) { - if let Some( current_version ) = dependency.get( "version" ).and_then( | v | v.as_str() ).map( | v | v.to_string() ) + if let Some( current_version ) = dependency.get( "version" ).and_then( | v | v.as_str() ).map( std::string::ToString::to_string ) { let version = &mut dependency[ "version" ]; if let Some( current_version ) = current_version.strip_prefix( '~' ) { if current_version != new_version { return Err( format_err!( "The current version of the package does not match the expected one. Expected: `{new_version}` Current: `{}`", version.as_str().unwrap_or_default() ) ); } - *version = value( format!( "~{}", old_version ) ); + *version = value( format!( "~{old_version}" ) ); } else { @@ -327,6 +339,12 @@ mod private /// # Returns : /// - `Ok` - the new version number as a string; /// - `Err` - if the manifest file cannot be read, written, parsed. + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc pub fn manifest_bump( manifest : &mut Manifest, dry : bool ) -> Result< BumpReport, manifest::ManifestError > { let mut report = BumpReport::default(); diff --git a/module/move/willbe/src/entity/workspace.rs b/module/move/willbe/src/entity/workspace.rs index 3fc37828fd..945e70ba23 100644 --- a/module/move/willbe/src/entity/workspace.rs +++ b/module/move/willbe/src/entity/workspace.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; // qqq : for Bohdan : bad @@ -97,6 +99,10 @@ mod private } /// Returns the path to workspace root + /// + /// # Panics + /// qqq: doc + #[ must_use ] pub fn workspace_root( &self ) -> CrateDir { // Safe because workspace_root.as_std_path() is always a path to a directory @@ -104,13 +110,17 @@ mod private } /// Returns the path to target directory + #[ must_use ] pub fn target_directory( &self ) -> &std::path::Path { self.metadata.target_directory.as_std_path() } /// Find a package by its manifest file path - pub fn package_find_by_manifest< 'a, P >( &'a self, manifest_file : P ) -> Option< WorkspacePackageRef< 'a > > + /// + /// # Panics + /// qqq: doc + pub fn package_find_by_manifest< P >( &self, manifest_file : P ) -> Option< WorkspacePackageRef< '_ > > where P : AsRef< std::path::Path >, { @@ -120,7 +130,8 @@ mod private } /// Filter of packages. - pub fn packages_which< 'a >( &'a self ) -> PackagesFilterFormer< 'a > + #[ must_use ] + pub fn packages_which( &self ) -> PackagesFilterFormer< '_ > { // PackagesFilter::new( self ) PackagesFilter::former().workspace( self ) @@ -208,12 +219,13 @@ mod private Self { workspace, - crate_dir : Default::default(), - manifest_file : Default::default(), + crate_dir : Box::default(), + manifest_file : Box::default(), } } #[ inline( always ) ] + #[ allow( clippy::unused_self ) ] pub fn iter( &'a self ) -> impl Iterator< Item = WorkspacePackageRef< 'a > > + Clone { @@ -247,9 +259,8 @@ mod private { if !formed.crate_dir.include( p ) { return false }; if !formed.manifest_file.include( p ) { return false }; - return true; + true }) - .clone() // .unwrap() // let filter_crate_dir = if Some( crate_dir ) = self.crate_dir diff --git a/module/move/willbe/src/entity/workspace_graph.rs b/module/move/willbe/src/entity/workspace_graph.rs index 9d129fdf07..11b592520f 100644 --- a/module/move/willbe/src/entity/workspace_graph.rs +++ b/module/move/willbe/src/entity/workspace_graph.rs @@ -1,8 +1,11 @@ mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Returns a graph of packages. + #[ allow( clippy::type_complexity ) ] + #[ must_use ] pub fn graph( workspace : &Workspace ) -> petgraph::Graph< String, String > { let packages = workspace.packages(); diff --git a/module/move/willbe/src/entity/workspace_md_extension.rs b/module/move/willbe/src/entity/workspace_md_extension.rs index a6d10dd9cb..afbc2442a9 100644 --- a/module/move/willbe/src/entity/workspace_md_extension.rs +++ b/module/move/willbe/src/entity/workspace_md_extension.rs @@ -1,6 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Md's extension for workspace @@ -15,7 +17,7 @@ mod private /// Return the repository url fn repository_url( &self ) -> Option< String >; - /// Return the workspace_name + /// Return the `workspace_name` fn workspace_name( &self ) -> Option< String >; } @@ -27,7 +29,7 @@ mod private .metadata .workspace_metadata[ "discord_url" ] .as_str() - .map( | url | url.to_string() ) + .map( std::string::ToString::to_string ) } fn master_branch( &self ) -> Option< String > @@ -37,7 +39,7 @@ mod private .workspace_metadata .get( "master_branch" ) .and_then( | b | b.as_str() ) - .map( | b | b.to_string() ) + .map( std::string::ToString::to_string ) } fn repository_url( &self ) -> Option< String > @@ -47,7 +49,7 @@ mod private .workspace_metadata .get( "repo_url" ) .and_then( | b | b.as_str() ) - .map( | b | b.to_string() ) + .map( std::string::ToString::to_string ) } fn workspace_name( &self ) -> Option< String > @@ -57,7 +59,7 @@ mod private .workspace_metadata .get( "workspace_name" ) .and_then( | b | b.as_str() ) - .map( | b | b.to_string() ) + .map( std::string::ToString::to_string ) } } diff --git a/module/move/willbe/src/entity/workspace_package.rs b/module/move/willbe/src/entity/workspace_package.rs index 6ecada7108..0cbb271103 100644 --- a/module/move/willbe/src/entity/workspace_package.rs +++ b/module/move/willbe/src/entity/workspace_package.rs @@ -1,5 +1,7 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; use macros::kw; use collection::BTreeMap; @@ -12,7 +14,7 @@ mod private // xxx : qqq : Deref, DerefMut, AsRef, AsMut - /// Facade for cargo_metadata::Package + /// Facade for `cargo_metadata::Package` #[ derive( Debug, Clone, Copy ) ] #[ repr( transparent ) ] pub struct WorkspacePackageRef< 'a > @@ -35,6 +37,7 @@ mod private impl< 'a > WorkspacePackageRef< 'a > { /// The name field as given in the Cargo.toml + #[ must_use ] pub fn name( &'a self ) -> &'a str { &self.inner.name @@ -56,12 +59,21 @@ mod private } /// Path to the manifest Cargo.toml + /// + /// # Errors + /// qqq: doc pub fn manifest_file( &self ) -> Result< ManifestFile, PathError > { self.inner.manifest_path.as_path().try_into() } /// Path to the directory with manifest Cargo.toml. + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: docs pub fn crate_dir( &self ) -> Result< CrateDir, PathError > { // SAFE because `manifest_path containing the Cargo.toml` @@ -69,6 +81,7 @@ mod private } /// The version field as specified in the Cargo.toml + #[ must_use ] pub fn version( &self ) -> semver::Version { self.inner.version.clone() @@ -77,6 +90,7 @@ mod private /// List of registries to which this package may be published (derived from the publish field). /// Publishing is unrestricted if None, and forbidden if the Vec is empty. /// This is always None if running with a version of Cargo older than 1.39. + #[ must_use ] pub fn publish( &self ) -> Option< &Vec< String > > { self.inner.publish.as_ref() @@ -105,18 +119,21 @@ mod private /// assert_eq!( package_metadata.some_value, 42 ); /// } /// ``` + #[ must_use ] pub fn metadata( &self ) -> &Value { &self.inner.metadata } /// The repository URL as specified in the Cargo.toml + #[ must_use ] pub fn repository( &self ) -> Option< &String > { self.inner.repository.as_ref() } /// Features provided by the crate, mapped to the features required by that feature. + #[ must_use ] pub fn features( &self ) -> &BTreeMap< String, Vec< String > > { &self.inner.features @@ -130,7 +147,7 @@ mod private self.inner.targets.iter().map( | target | { let src_path = &target.src_path; - let source : SourceFile = src_path.try_into().expect( &format!( "Illformed path to source file {src_path}" ) ); + let source : SourceFile = src_path.try_into().unwrap_or_else( | _ | panic!( "Illformed path to source file {src_path}" ) ); // println!( " -- {:?} {:?}", source, target.kind ); source }) @@ -166,7 +183,7 @@ mod private impl< 'a > AsCode for WorkspacePackageRef< 'a > { - fn as_code< 'b >( &'b self ) -> std::io::Result< Cow< 'b, str > > + fn as_code( &self ) -> std::io::Result< Cow< '_, str > > { let mut results : Vec< String > = Vec::new(); // zzz : introduce formatter @@ -178,9 +195,9 @@ mod private .as_ref() .with_extension( "" ) .file_name() - .expect( &format!( "Cant get file name of path {}", source.as_ref().display() ) ) + .unwrap_or_else( || panic!( "Cant get file name of path {}", source.as_ref().display() ) ) .to_string_lossy() - .replace( ".", "_" ); + .replace( '.', "_" ); if kw::is( &filename ) { @@ -190,7 +207,7 @@ mod private // qqq : xxx : use callbacks instead of expect results.push( format!( "// === Begin of File {}", source.as_ref().display() ) ); - results.push( format!( "mod {}\n{{\n", filename ) ); + results.push( format!( "mod {filename}\n{{\n" ) ); results.push( code ); results.push( "\n}".to_string() ); results.push( format!( "// === End of File {}", source.as_ref().display() ) ); diff --git a/module/move/willbe/src/lib.rs b/module/move/willbe/src/lib.rs index 27cf2d036a..a8a72e3d47 100644 --- a/module/move/willbe/src/lib.rs +++ b/module/move/willbe/src/lib.rs @@ -8,6 +8,7 @@ pub use mod_interface::mod_interface; /// Define a private namespace for all its items. mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; /// Takes the command line arguments and perform associated function(s). @@ -15,6 +16,9 @@ mod private /// It then terminates the program with an exit code of 1 to indicate an error due to the lack of input. /// /// Do not support interactive mode. + /// + /// # Errors + /// qqq: doc pub fn run( args : Vec< String > ) -> Result< (), error::untyped::Error > { #[ cfg( feature = "tracing" ) ] diff --git a/module/move/willbe/src/tool/cargo.rs b/module/move/willbe/src/tool/cargo.rs index 5a3974ddd9..a8f926860a 100644 --- a/module/move/willbe/src/tool/cargo.rs +++ b/module/move/willbe/src/tool/cargo.rs @@ -1,9 +1,11 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { + #[ allow( clippy::wildcard_imports ) ] use crate::*; - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::tool::*; use std::ffi::OsString; @@ -27,6 +29,7 @@ mod private /// The `PackOptions` struct encapsulates various options that can be configured when packaging a project, /// including the path to the project, the distribution channel, and various flags for controlling the behavior of the packaging process. #[ derive( Debug, Former, Clone ) ] + #[ allow( clippy::struct_excessive_bools ) ] pub struct PackOptions { /// The path to the project to be packaged. @@ -73,6 +76,7 @@ mod private impl PackOptions { + #[ allow( clippy::if_not_else ) ] fn to_pack_args( &self ) -> Vec< String > { [ "run".to_string(), self.channel.to_string(), "cargo".into(), "package".into() ] @@ -170,7 +174,7 @@ mod private command : format!( "{program} {}", options.join( " " ) ), out : String::new(), err : String::new(), - current_path: args.path.to_path_buf(), + current_path: args.path.clone(), error: Ok( () ), } ) @@ -248,7 +252,7 @@ mod private command : format!( "{program} {}", arguments.join( " " ) ), out : String::new(), err : String::new(), - current_path: args.path.to_path_buf(), + current_path: args.path.clone(), error: Ok( () ), } ) @@ -257,7 +261,7 @@ mod private { let mut results = Vec::with_capacity( args.retry_count + 1 ); let run_args : Vec< _ > = arguments.into_iter().map( OsString::from ).collect(); - for _ in 0 .. args.retry_count + 1 + for _ in 0 ..=args.retry_count { let result = process::Run::former() .bin_path( program ) diff --git a/module/move/willbe/src/tool/files.rs b/module/move/willbe/src/tool/files.rs index 95f19de887..5b70f48535 100644 --- a/module/move/willbe/src/tool/files.rs +++ b/module/move/willbe/src/tool/files.rs @@ -1,8 +1,9 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::tool::*; use std::path::{ Path, PathBuf }; @@ -10,8 +11,11 @@ mod private /// /// Find paths. /// + /// # Panics + /// qqq: doc /* xxx : check */ + #[ allow( clippy::useless_conversion ) ] pub fn find< P, S >( base_dir : P, patterns : &[ S ] ) -> Vec< PathBuf > where P : AsRef< Path >, @@ -27,6 +31,7 @@ mod private } /// Check if path is valid. + #[ must_use ] pub fn valid_is( path : &str ) -> bool { std::fs::metadata( path ).is_ok() diff --git a/module/move/willbe/src/tool/git.rs b/module/move/willbe/src/tool/git.rs index 9e240c804b..27c9743f4d 100644 --- a/module/move/willbe/src/tool/git.rs +++ b/module/move/willbe/src/tool/git.rs @@ -1,11 +1,14 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::tool::*; use std::ffi::OsString; use std::path::Path; + + #[ allow( clippy::wildcard_imports ) ] use process_tools::process::*; // use error::err; // qqq : group dependencies @@ -31,7 +34,7 @@ mod private Os : AsRef< [ O ] >, O : AsRef< str >, { - let objects = objects.as_ref().iter().map( | x | x.as_ref() ); + let objects = objects.as_ref().iter().map( std::convert::AsRef::as_ref ); // qqq : for Bohdan : don't enlarge length of lines artificially let ( program, args ) : ( _, Vec< _ > ) = ( "git", Some( "add" ).into_iter().chain( objects ).collect() ); @@ -164,6 +167,9 @@ mod private /// # Returns : /// This function returns a `Result` containing a `Report` if the command is executed successfully. The `Report` contains the command executed, the output /// git reset command wrapper + /// + /// # Errors + /// qqq: doc // qqq : should be typed error, apply err_with @@ -181,7 +187,7 @@ mod private .into_iter() .chain( if hard { Some( "--hard" ) } else { None } ) .map( String::from ) - .chain( Some( format!( "HEAD~{}", commits_count ) ) ) + .chain( Some( format!( "HEAD~{commits_count}" ) ) ) .collect() ); @@ -218,6 +224,9 @@ mod private /// # Returns /// /// A `Result` containing a `Report`, which represents the result of the command execution. + /// + /// # Errors + /// qqq: doc // qqq : should be typed error, apply err_with // qqq : don't use 1-prameter Result diff --git a/module/move/willbe/src/tool/graph.rs b/module/move/willbe/src/tool/graph.rs index dec62fdc9e..e7e06db908 100644 --- a/module/move/willbe/src/tool/graph.rs +++ b/module/move/willbe/src/tool/graph.rs @@ -1,7 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::*; // use crate::tool::*; @@ -21,6 +22,7 @@ mod private algo::toposort as pg_toposort, }; use petgraph::graph::NodeIndex; + #[ allow( clippy::wildcard_imports ) ] use petgraph::prelude::*; use error:: @@ -45,6 +47,11 @@ mod private /// /// Returns : /// The graph with all accepted packages + /// + /// # Panics + /// qqq: doc + #[ allow( clippy::implicit_hasher ) ] + #[ must_use ] pub fn construct< PackageIdentifier > ( packages : &HashMap @@ -92,6 +99,10 @@ mod private /// /// # Panics /// If there is a cycle in the dependency graph + /// + /// # Errors + /// qqq: doc + #[ allow( clippy::needless_pass_by_value ) ] pub fn toposort< 'a, PackageIdentifier : Clone + std::fmt::Debug > ( graph : Graph< &'a PackageIdentifier, &'a PackageIdentifier > @@ -123,6 +134,11 @@ mod private /// # Returns /// /// The function returns a vector of vectors, where each inner vector represents a group of nodes that can be executed in parallel. Tasks within each group are sorted in topological order. + /// + /// # Panics + /// qqq: doc + #[ must_use ] + #[ allow( clippy::needless_pass_by_value ) ] pub fn topological_sort_with_grouping< 'a, PackageIdentifier : Clone + std::fmt::Debug > ( graph : Graph< &'a PackageIdentifier, &'a PackageIdentifier > @@ -136,7 +152,7 @@ mod private } let mut roots = VecDeque::new(); - for ( node, °ree ) in in_degree.iter() + for ( node, °ree ) in &in_degree { if degree == 0 { @@ -194,6 +210,10 @@ mod private /// /// # Constraints /// * `N` must implement the `PartialEq` trait. + /// + /// # Panics + /// qqq: doc + #[ allow( clippy::single_match, clippy::map_entry ) ] pub fn subgraph< N, E >( graph : &Graph< N, E >, roots : &[ N ] ) -> Graph< NodeIndex, EdgeIndex > where N : PartialEq< N >, @@ -215,7 +235,7 @@ mod private } } - for ( _, sub_node_id ) in &node_map + for sub_node_id in node_map.values() { let node_id_graph = subgraph[ *sub_node_id ]; @@ -246,11 +266,18 @@ mod private /// # Returns /// /// A new `Graph` with the nodes that are not required to be published removed. + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc // qqq : for Bohdan : typed error - pub fn remove_not_required_to_publish< 'a > + #[ allow( clippy::single_match, clippy::needless_pass_by_value, clippy::implicit_hasher ) ] + pub fn remove_not_required_to_publish ( - package_map : &HashMap< String, Package< 'a > >, + package_map : &HashMap< String, Package< '_ > >, graph : &Graph< String, String >, roots : &[ String ], temp_path : Option< PathBuf >, diff --git a/module/move/willbe/src/tool/http.rs b/module/move/willbe/src/tool/http.rs index 81e13a2d74..f62f86005f 100644 --- a/module/move/willbe/src/tool/http.rs +++ b/module/move/willbe/src/tool/http.rs @@ -1,7 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::tool::*; use std:: @@ -16,6 +17,12 @@ mod private /// /// Get data of remote package. /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: docs + /// // qqq : typed error pub fn download< 'a >( name : &'a str, version : &'a str ) -> error::untyped::Result< Vec< u8 > > { @@ -24,7 +31,7 @@ mod private .timeout_write( Duration::from_secs( 5 ) ) .build(); let mut buf = String::new(); - write!( &mut buf, "https://static.crates.io/crates/{0}/{0}-{1}.crate", name, version )?; + write!( &mut buf, "https://static.crates.io/crates/{name}/{name}-{version}.crate" )?; let resp = agent.get( &buf[ .. ] ).call().context( "Get data of remote package" )?; diff --git a/module/move/willbe/src/tool/query.rs b/module/move/willbe/src/tool/query.rs index 4b8a14d10e..6724a0093f 100644 --- a/module/move/willbe/src/tool/query.rs +++ b/module/move/willbe/src/tool/query.rs @@ -1,7 +1,8 @@ /// Define a private namespace for all its items. +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::tool::*; use std:: @@ -36,10 +37,12 @@ mod private if let Ok( i ) = s.parse::< i32 >() { Ok( Value::Int( i ) ) - } else if let Ok( b ) = s.parse::< bool >() + } + else if let Ok( b ) = s.parse::< bool >() { Ok( Value::Bool( b ) ) - } else + } + else { let s = s.trim_matches( '\'' ); Ok( Value::String( s.to_string() ) ) @@ -85,6 +88,7 @@ mod private /// assert!( result.contains( &Value::Int( 2 ) ) ); /// assert!( result.contains( &Value::Int( 3 ) ) ); /// ``` + #[ must_use ] pub fn into_vec( self ) -> Vec< Value > { match self @@ -111,6 +115,8 @@ mod private /// assert_eq!( HashMap::from( [ ( "1".to_string(), Value::Int( 1 ) ), ( "2".to_string(),Value::Int( 2 ) ), ( "3".to_string(),Value::Int( 3 ) ) ] ), unnamed_map ); /// assert_eq!( HashMap::from( [ ( "var0".to_string(), Value::Int( 1 ) ), ( "1".to_string(),Value::Int( 2 ) ), ( "2".to_string(),Value::Int( 3 ) ) ] ), mixed_map ); /// ``` + #[ allow( clippy::needless_pass_by_value ) ] + #[ must_use ] pub fn into_map( self, names : Vec< String > ) -> HashMap< String, Value > { match self @@ -148,6 +154,12 @@ mod private /// expected_map.insert( "key".to_string(), Value::String( r#"hello\'test\'test"#.into() ) ); /// assert_eq!( parse( r#"{ key : 'hello\'test\'test' }"# ).unwrap().into_map( vec![] ), expected_map ); /// ``` + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc // qqq : use typed error pub fn parse( input_string : &str ) -> error::untyped::Result< ParseResult > { @@ -253,6 +265,7 @@ mod private } // qqq : use typed error + #[ allow( clippy::unnecessary_wraps ) ] fn parse_to_vec( input : Vec< String > ) -> error::untyped::Result< Vec< Value > > { Ok( input.into_iter().filter_map( | w | Value::from_str( w.trim() ).ok() ).collect() ) diff --git a/module/move/willbe/src/tool/repository.rs b/module/move/willbe/src/tool/repository.rs index c78d304661..7ec6fb7323 100644 --- a/module/move/willbe/src/tool/repository.rs +++ b/module/move/willbe/src/tool/repository.rs @@ -1,7 +1,7 @@ /// Define a private namespace for all its items. mod private { - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::tool::*; /// Searches for a README file in specific subdirectories of the given directory path. @@ -9,6 +9,9 @@ mod private /// This function attempts to find a README file in the following subdirectories: ".github", /// the root directory, and "./docs". It returns the path to the first found README file, or /// `None` if no README file is found in any of these locations. + /// + /// # Errors + /// qqq: doc pub fn readme_path( dir_path : &std::path::Path ) -> Result< std::path::PathBuf, std::io::Error > { if let Some( path ) = readme_in_dir_find( &dir_path.join( ".github" ) ) diff --git a/module/move/willbe/src/tool/template.rs b/module/move/willbe/src/tool/template.rs index 91c804c8ce..c8ac11af89 100644 --- a/module/move/willbe/src/tool/template.rs +++ b/module/move/willbe/src/tool/template.rs @@ -1,7 +1,7 @@ /// Define a private namespace for all its items. mod private { - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::tool::*; use std:: @@ -49,6 +49,9 @@ mod private /// # Returns /// /// A `Result` which is `Ok` if the files are created successfully, or an `Err` otherwise. + /// + /// # Errors + /// qqq: doc pub fn create_all( self, path : &path::Path ) -> error::untyped::Result< () > // qqq : use typed error { self.files.create_all( path, &self.values ) @@ -59,6 +62,7 @@ mod private /// # Returns /// /// A reference to `TemplateParameters`. + #[ must_use ] pub fn parameters( &self ) -> &TemplateParameters { &self.parameters @@ -71,7 +75,7 @@ mod private /// - `values`: The new `TemplateValues` to be set. pub fn set_values( &mut self, values : TemplateValues ) { - self.values = values + self.values = values; } /// Returns a reference to the template values. @@ -79,6 +83,7 @@ mod private /// # Returns /// /// A reference to `TemplateValues`. + #[ must_use ] pub fn get_values( &self ) -> &TemplateValues { &self.values @@ -130,6 +135,7 @@ mod private } /// Fetches mandatory parameters that are not set yet. + #[ must_use ] pub fn get_missing_mandatory( &self ) -> Vec< &str > { let values = self.get_values(); @@ -137,7 +143,7 @@ mod private .parameters() .list_mandatory() .into_iter() - .filter( | key | values.0.get( *key ).map( | val | val.as_ref() ).flatten().is_none() ) + .filter( | key | values.0.get( *key ).and_then( | val | val.as_ref() ).is_none() ) .collect() } } @@ -150,10 +156,13 @@ mod private /// Creates all files in provided path with values for required parameters. /// /// Consumes owner of the files. + /// + /// # Errors + /// qqq: doc fn create_all( self, path : &Path, values : &TemplateValues ) -> error::untyped::Result< () > // qqq : use typed error { let fsw = FileSystem; - for file in self.into_iter() + for file in self { file.create_file( &fsw, path, values )?; } @@ -172,17 +181,19 @@ mod private impl TemplateParameters { /// Extracts template values from props for parameters required for this template. + #[ must_use ] pub fn values_from_props( &self, props : &wca::executor::Props ) -> TemplateValues { let values = self.descriptors .iter() .map( | d | &d.parameter ) - .map( | param | ( param.clone(), props.get( param ).map( wca::Value::clone ) ) ) + .map( | param | ( param.clone(), props.get( param ).cloned() ) ) .collect(); TemplateValues( values ) } /// Get a list of all mandatory parameters. + #[ must_use ] pub fn list_mandatory( &self ) -> Vec< &str > { self.descriptors.iter().filter( | d | d.is_mandatory ).map( | d | d.parameter.as_str() ).collect() @@ -219,27 +230,28 @@ mod private /// Converts values to a serializable object. /// /// Currently only `String`, `Number`, and `Bool` are supported. + #[ must_use ] pub fn to_serializable( &self ) -> collection::BTreeMap< String, String > { self.0.iter().map ( | ( key, value ) | { - let value = value.as_ref().map + let value = value.as_ref().map_or ( + "___UNSPECIFIED___".to_string(), | value | { match value { wca::Value::String( val ) => val.to_string(), wca::Value::Number( val ) => val.to_string(), - wca::Value::Path( _ ) => "unsupported".to_string(), wca::Value::Bool( val ) => val.to_string(), + wca::Value::Path( _ ) | wca::Value::List( _ ) => "unsupported".to_string(), } } - ) - .unwrap_or( "___UNSPECIFIED___".to_string() ); + ); ( key.to_owned(), value ) } ) @@ -249,7 +261,7 @@ mod private /// Inserts new value if parameter wasn't initialized before. pub fn insert_if_empty( &mut self, key : &str, value : wca::Value ) { - if let None = self.0.get( key ).and_then( | v | v.as_ref() ) + if self.0.get( key ).and_then( | v | v.as_ref() ).is_none() { self.0.insert( key.into() , Some( value ) ); } @@ -258,7 +270,7 @@ mod private /// Interactively asks user to provide value for a parameter. pub fn interactive_if_empty( &mut self, key : &str ) { - if let None = self.0.get( key ).and_then( | v | v.as_ref() ) + if self.0.get( key ).and_then( | v | v.as_ref() ).is_none() { println! ("Parameter `{key}` is not set" ); let answer = wca::ask( "Enter value" ); @@ -299,7 +311,7 @@ mod private WriteMode::TomlExtend => { let instruction = FileReadInstruction { path : path.into() }; - if let Some(existing_contents) = fs.read( &instruction ).ok() + if let Ok( existing_contents ) = fs.read( &instruction ) { let document = contents.parse::< toml_edit::Document >().context( "Failed to parse template toml file" )?; let template_items = document.iter(); @@ -307,10 +319,10 @@ mod private let mut existing_document = existing_toml_contents.parse::< toml_edit::Document >().context( "Failed to parse existing toml file" )?; for ( template_key, template_item ) in template_items { - match existing_document.get_mut( &template_key ) + match existing_document.get_mut( template_key ) { - Some( item ) => *item = template_item.to_owned(), - None => existing_document[ &template_key ] = template_item.to_owned(), + Some( item ) => template_item.clone_into( item ), + None => template_item.clone_into( &mut existing_document[ template_key ] ), } } return Ok( existing_document.to_string() ); @@ -396,9 +408,13 @@ mod private pub trait FileSystemPort { /// Writing to file implementation. + /// # Errors + /// qqq: doc fn write( &self, instruction : &FileWriteInstruction ) -> error::untyped::Result< () >; // qqq : use typed error /// Reading from a file implementation. + /// # Errors + /// qqq: doc fn read( &self, instruction : &FileReadInstruction ) -> error::untyped::Result< Vec< u8 > >; // qqq : use typed error } diff --git a/module/move/willbe/src/tool/tree.rs b/module/move/willbe/src/tool/tree.rs index 3c1e0c670b..8525d0f2e0 100644 --- a/module/move/willbe/src/tool/tree.rs +++ b/module/move/willbe/src/tool/tree.rs @@ -1,3 +1,4 @@ +#[ allow( clippy::std_instead_of_alloc, clippy::std_instead_of_core ) ] mod private { use std::fmt::Write; @@ -26,7 +27,8 @@ mod private /// # Returns /// /// A new instance of `TreePrinter`. - pub fn new(info : &ListNodeReport) -> Self + #[ must_use ] + pub fn new(info : &ListNodeReport) -> Self { TreePrinter { @@ -44,15 +46,21 @@ mod private /// # Returns /// /// * A `Result` containing the formatted string or a `std::fmt::Error` if formatting fails. + /// + /// # Errors + /// qqq: doc + /// + /// # Panics + /// qqq: doc pub fn display_with_spacer( &self, spacer : &str ) -> Result< String, std::fmt::Error > { let mut f = String::new(); write!( f, "{}", self.info.name )?; if let Some( version ) = &self.info.version { write!( f, " {version}" )? } - if let Some( crate_dir ) = &self.info.crate_dir { write!( f, " {}", crate_dir )? } + if let Some( crate_dir ) = &self.info.crate_dir { write!( f, " {crate_dir}" )? } if self.info.duplicate { write!( f, "(*)" )? } - write!( f, "\n" )?; + writeln!( f )?; let mut new_spacer = format!( "{spacer}{} ", if self.info.normal_dependencies.len() < 2 { " " } else { self.symbols.down } ); @@ -72,7 +80,7 @@ mod private { let mut dev_dependencies_iter = self.info.dev_dependencies.iter(); let last = dev_dependencies_iter.next_back(); - write!( f, "{spacer}[dev-dependencies]\n" )?; + writeln!( f, "{spacer}[dev-dependencies]" )?; for dep in dev_dependencies_iter { write!( f, "{spacer}{}{} {}", self.symbols.tee, self.symbols.right, Self::display_with_spacer( &TreePrinter::new( dep ), &new_spacer )? )?; @@ -84,7 +92,7 @@ mod private { let mut build_dependencies_iter = self.info.build_dependencies.iter(); let last = build_dependencies_iter.next_back(); - write!( f, "{spacer}[build-dependencies]\n" )?; + writeln!( f, "{spacer}[build-dependencies]" )?; for dep in build_dependencies_iter { write!( f, "{spacer}{}{} {}", self.symbols.tee, self.symbols.right, Self::display_with_spacer( &TreePrinter::new( dep ), &new_spacer )? )?; @@ -146,15 +154,15 @@ mod private /// This field is a flag indicating whether the Node is a duplicate or not. pub duplicate : bool, /// A list that stores normal dependencies. - /// Each element in the list is also of the same 'ListNodeReport' type to allow + /// Each element in the list is also of the same '`ListNodeReport`' type to allow /// storage of nested dependencies. pub normal_dependencies : Vec< ListNodeReport >, /// A list that stores dev dependencies(dependencies required for tests or examples). - /// Each element in the list is also of the same 'ListNodeReport' type to allow + /// Each element in the list is also of the same '`ListNodeReport`' type to allow /// storage of nested dependencies. pub dev_dependencies : Vec< ListNodeReport >, /// A list that stores build dependencies. - /// Each element in the list is also of the same 'ListNodeReport' type to allow + /// Each element in the list is also of the same '`ListNodeReport`' type to allow /// storage of nested dependencies. pub build_dependencies : Vec< ListNodeReport >, } diff --git a/module/move/willbe/src/tool/url.rs b/module/move/willbe/src/tool/url.rs index 58c2792e4c..a7f76716c4 100644 --- a/module/move/willbe/src/tool/url.rs +++ b/module/move/willbe/src/tool/url.rs @@ -1,7 +1,7 @@ /// Define a private namespace for all its items. mod private { - #[ allow( unused_imports ) ] + #[ allow( unused_imports, clippy::wildcard_imports ) ] use crate::tool::*; use error::untyped:: @@ -11,15 +11,16 @@ mod private }; /// Extracts the repository URL from a full URL. + #[ must_use ] pub fn repo_url_extract( full_url : &str ) -> Option< String > { let parts : Vec< &str > = full_url.split( '/' ).collect(); - if parts.len() >= 4 && parts[ 0 ] == "https:" && parts[ 1 ] == "" && parts[ 2 ] == "github.com" + if parts.len() >= 4 && parts[ 0 ] == "https:" && parts[ 1 ].is_empty() && parts[ 2 ] == "github.com" { let user = parts[ 3 ]; let repo = parts[ 4 ]; - let repo_url = format!( "https://github.com/{}/{}", user, repo ); + let repo_url = format!( "https://github.com/{user}/{repo}" ); Some( repo_url ) } else @@ -29,8 +30,10 @@ mod private } /// Extracts the username and repository name from a given URL. + /// # Errors + /// qqq: doc // qqq : use typed error - pub fn git_info_extract( url : &String ) -> error::untyped::Result< String > + pub fn git_info_extract( url : &str ) -> error::untyped::Result< String > { let parts : Vec< &str > = url.split( '/' ).collect(); if parts.len() >= 2 diff --git a/module/move/willbe/tests/asset/single_module/Cargo.toml b/module/move/willbe/tests/asset/single_module/Cargo.toml index 7e5912d446..a78145c170 100644 --- a/module/move/willbe/tests/asset/single_module/Cargo.toml +++ b/module/move/willbe/tests/asset/single_module/Cargo.toml @@ -5,6 +5,7 @@ members = [ ] [workspace.metadata] +workspace_name = "single_module" master_branch = "test_branch" project_name = "test" repo_url = "https://github.com/Username/test" diff --git a/module/move/willbe/tests/inc/action_tests/readme_modules_headers_renew.rs b/module/move/willbe/tests/inc/action_tests/readme_modules_headers_renew.rs index 1d4d012d5d..eed7873ef5 100644 --- a/module/move/willbe/tests/inc/action_tests/readme_modules_headers_renew.rs +++ b/module/move/willbe/tests/inc/action_tests/readme_modules_headers_renew.rs @@ -32,7 +32,7 @@ fn tags_should_stay() let temp = arrange( "single_module" ); // Act - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); // _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); @@ -53,7 +53,7 @@ fn default_stability() let temp = arrange( "single_module" ); // Act - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -72,7 +72,7 @@ fn docs() let temp = arrange( "single_module" ); // Act - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -90,7 +90,7 @@ fn no_gitpod() let temp = arrange("single_module"); // Act - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open(temp.path().join("test_module").join("Readme.md")).unwrap(); let mut actual = String::new(); @@ -107,7 +107,7 @@ fn with_gitpod() let temp = arrange( "single_module_with_example" ); // Act - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "module" ).join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -125,7 +125,7 @@ fn discord() let temp = arrange( "single_module" ); // Act - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew(CrateDir::try_from(temp.path()).unwrap()).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -143,7 +143,7 @@ fn status() let temp = arrange( "single_module" ); // Act - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -161,13 +161,13 @@ fn idempotency() let temp = arrange( "single_module" ); // Act - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual1 = String::new(); _ = file.read_to_string( &mut actual1 ).unwrap(); drop( file ); - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual2 = String::new(); _ = file.read_to_string( &mut actual2 ).unwrap(); @@ -182,7 +182,7 @@ fn with_many_members_and_varius_config() { let temp = arrange( "three_packages" ); - _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_modules_headers_renew::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file_b = std::fs::File::open( temp.path().join( "b" ).join( "Readme.md" ) ).unwrap(); let mut file_c = std::fs::File::open( temp.path().join( "c" ).join( "Readme.md" ) ).unwrap();