From 5cef3a9b4dbc2836f6d6bb54896a2ea648b76693 Mon Sep 17 00:00:00 2001 From: Pylyv <70846394+Pylyv@users.noreply.github.com> Date: Sun, 10 Dec 2023 11:36:23 +0100 Subject: [PATCH] code: Solved latest raised clippy warnings - this solves #46 (#47) * code: Solved latest raised clippy warnings - this solves #46 * code: Forgot to run the Format command --- canyon_macros/src/utils/helpers.rs | 2 +- canyon_migrations/src/migrations/processor.rs | 7 ++++--- src/lib.rs | 2 +- tests/canyon_integration_tests.rs | 16 ++++++++-------- tests/constants.rs | 2 +- tests/crud/delete_operations.rs | 4 ++-- tests/crud/foreign_key_operations.rs | 18 +++++++++--------- tests/crud/insert_operations.rs | 4 ++-- tests/crud/querybuilder_operations.rs | 8 ++++---- tests/crud/select_operations.rs | 4 ++-- tests/crud/update_operations.rs | 4 ++-- tests/migrations/mod.rs | 2 +- 12 files changed, 37 insertions(+), 36 deletions(-) diff --git a/canyon_macros/src/utils/helpers.rs b/canyon_macros/src/utils/helpers.rs index 81ac7dcd..7022db2b 100644 --- a/canyon_macros/src/utils/helpers.rs +++ b/canyon_macros/src/utils/helpers.rs @@ -164,7 +164,7 @@ pub fn database_table_name_to_struct_ident(name: &str) -> Ident { first_iteration = false; } else { match char { - n if n == '_' => { + '_' => { previous_was_underscore = true; } char if char.is_ascii_lowercase() => { diff --git a/canyon_migrations/src/migrations/processor.rs b/canyon_migrations/src/migrations/processor.rs index aee9a89e..ac183460 100644 --- a/canyon_migrations/src/migrations/processor.rs +++ b/canyon_migrations/src/migrations/processor.rs @@ -1,5 +1,5 @@ -///! File that contains all the datatypes and logic to perform the migrations -///! over a target database +//! File that contains all the datatypes and logic to perform the migrations +//! over a target database use async_trait::async_trait; use canyon_crud::DatabaseType; use regex::Regex; @@ -95,6 +95,7 @@ impl MigrationsProcessor { } // Case when we need to compare the entity with the database contain + #[allow(clippy::unnecessary_unwrap)] if current_table_metadata.is_some() && current_column_metadata.is_some() { self.add_modify_or_remove_constraints( entity_name, @@ -643,7 +644,7 @@ impl MigrationsHelper { #[cfg(feature = "mssql")] fn get_datatype_from_column_metadata(current_column_metadata: &ColumnMetadata) -> String { // TODO Add all SQL Server text datatypes - if vec!["nvarchar", "varchar"] + if ["nvarchar", "varchar"] .contains(¤t_column_metadata.datatype.to_lowercase().as_str()) { let varchar_len = match ¤t_column_metadata.character_maximum_length { diff --git a/src/lib.rs b/src/lib.rs index 307d8b08..c74efbc5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -///! The root crate of the `Canyon-SQL` project. +//! The root crate of the `Canyon-SQL` project. /// /// Here it's where all the available functionalities and features /// reaches the top most level, grouping them and making them visible diff --git a/tests/canyon_integration_tests.rs b/tests/canyon_integration_tests.rs index 30687987..799a3747 100644 --- a/tests/canyon_integration_tests.rs +++ b/tests/canyon_integration_tests.rs @@ -1,15 +1,15 @@ +// Integration tests for the heart of a Canyon-SQL application, the CRUD operations. +/// +// This tests will tests mostly the whole source code of Canyon, due to its integration nature +/// +// Guide-style: Almost every operation in Canyon is `Result` wrapped (without the) unckecked +// variants of the `find_all` implementations. We will go to directly `.unwrap()` the results +// because, if there's something wrong in the code reported by the tests, we want to *panic* +// and abort the execution. extern crate canyon_sql; use std::error::Error; -///! Integration tests for the heart of a Canyon-SQL application, the CRUD operations. -/// -///! This tests will tests mostly the whole source code of Canyon, due to its integration nature -/// -/// Guide-style: Almost every operation in Canyon is `Result` wrapped (without the) unckecked -/// variants of the `find_all` implementations. We will go to directly `.unwrap()` the results -/// because, if there's something wrong in the code reported by the tests, we want to *panic* -/// and abort the execution. mod crud; mod migrations; diff --git a/tests/constants.rs b/tests/constants.rs index 26bea3fd..ad4d6ad4 100644 --- a/tests/constants.rs +++ b/tests/constants.rs @@ -1,4 +1,4 @@ -///! Constant values to share across the integration tests +//! Constant values to share across the integration tests #[cfg(feature = "postgres")] pub const PSQL_DS: &str = "postgres_docker"; diff --git a/tests/crud/delete_operations.rs b/tests/crud/delete_operations.rs index 31d1b0ef..5c1f5c1c 100644 --- a/tests/crud/delete_operations.rs +++ b/tests/crud/delete_operations.rs @@ -1,5 +1,5 @@ -///! Integration tests for the CRUD operations available in `Canyon` that -///! generates and executes *INSERT* statements +//! Integration tests for the CRUD operations available in `Canyon` that +//! generates and executes *INSERT* statements use canyon_sql::crud::CrudOperations; #[cfg(feature = "mysql")] diff --git a/tests/crud/foreign_key_operations.rs b/tests/crud/foreign_key_operations.rs index 21cae200..e6281f92 100644 --- a/tests/crud/foreign_key_operations.rs +++ b/tests/crud/foreign_key_operations.rs @@ -1,13 +1,13 @@ -///! Integration tests for the CRUD operations available in `Canyon` that -///! generates and executes *SELECT* statements based on a entity -///! annotated with the `#[foreign_key(... args)]` annotation looking -///! for the related data with some entity `U` that acts as is parent, where `U` -///! impls `ForeignKeyable` (isn't required, but it won't unlock the -///! reverse search features parent -> child, only the child -> parent ones). +// Integration tests for the CRUD operations available in `Canyon` that +// generates and executes *SELECT* statements based on a entity +// annotated with the `#[foreign_key(... args)]` annotation looking +// for the related data with some entity `U` that acts as is parent, where `U` +// impls `ForeignKeyable` (isn't required, but it won't unlock the +// reverse search features parent -> child, only the child -> parent ones). /// -///! Names of the foreign key methods are autogenerated for the direct and -///! reverse side of the implementations. -///! For more info: TODO -> Link to the docs of the foreign key chapter +// Names of the foreign key methods are autogenerated for the direct and +// reverse side of the implementations. +// For more info: TODO -> Link to the docs of the foreign key chapter use canyon_sql::crud::CrudOperations; #[cfg(feature = "mssql")] diff --git a/tests/crud/insert_operations.rs b/tests/crud/insert_operations.rs index 898182b6..13e2747e 100644 --- a/tests/crud/insert_operations.rs +++ b/tests/crud/insert_operations.rs @@ -1,5 +1,5 @@ -///! Integration tests for the CRUD operations available in `Canyon` that -///! generates and executes *INSERT* statements +//! Integration tests for the CRUD operations available in `Canyon` that +//! generates and executes *INSERT* statements use canyon_sql::crud::CrudOperations; #[cfg(feature = "mysql")] diff --git a/tests/crud/querybuilder_operations.rs b/tests/crud/querybuilder_operations.rs index f4d03f38..7fba112e 100644 --- a/tests/crud/querybuilder_operations.rs +++ b/tests/crud/querybuilder_operations.rs @@ -3,11 +3,11 @@ use crate::constants::MYSQL_DS; #[cfg(feature = "mssql")] use crate::constants::SQL_SERVER_DS; -///! Tests for the QueryBuilder available operations within Canyon. +// Tests for the QueryBuilder available operations within Canyon. /// -///! QueryBuilder are the way of obtain more flexibility that with -///! the default generated queries, essentially for build the queries -///! with the SQL filters +// QueryBuilder are the way of obtain more flexibility that with +// the default generated queries, essentially for build the queries +// with the SQL filters /// use canyon_sql::{ crud::CrudOperations, diff --git a/tests/crud/select_operations.rs b/tests/crud/select_operations.rs index 76d263f2..f3342c02 100644 --- a/tests/crud/select_operations.rs +++ b/tests/crud/select_operations.rs @@ -5,8 +5,8 @@ use crate::constants::MYSQL_DS; #[cfg(feature = "mssql")] use crate::constants::SQL_SERVER_DS; -///! Integration tests for the CRUD operations available in `Canyon` that -///! generates and executes *SELECT* statements +// Integration tests for the CRUD operations available in `Canyon` that +/// generates and executes *SELECT* statements use crate::Error; use canyon_sql::crud::CrudOperations; diff --git a/tests/crud/update_operations.rs b/tests/crud/update_operations.rs index 18283cb7..dfc4af15 100644 --- a/tests/crud/update_operations.rs +++ b/tests/crud/update_operations.rs @@ -1,6 +1,6 @@ use crate::tests_models::league::*; -///! Integration tests for the CRUD operations available in `Canyon` that -///! generates and executes *UPDATE* statements +// Integration tests for the CRUD operations available in `Canyon` that +/// generates and executes *UPDATE* statements use canyon_sql::crud::CrudOperations; #[cfg(feature = "mysql")] diff --git a/tests/migrations/mod.rs b/tests/migrations/mod.rs index 01260fb3..9ece4aac 100644 --- a/tests/migrations/mod.rs +++ b/tests/migrations/mod.rs @@ -1,6 +1,6 @@ #![allow(unused_imports)] use crate::constants; -///! Integration tests for the migrations feature of `Canyon-SQL` +/// Integration tests for the migrations feature of `Canyon-SQL` use canyon_sql::crud::Transaction; #[cfg(feature = "migrations")] use canyon_sql::migrations::handler::Migrations;