Skip to content

Commit

Permalink
Fix clippy warnings - 1 (#967)
Browse files Browse the repository at this point in the history
* Fix clippy warnings

* cargo fmt

* Fix clippy warnings

* cargo fmt
  • Loading branch information
billy1624 authored Aug 12, 2022
1 parent 0d94941 commit 43495de
Show file tree
Hide file tree
Showing 58 changed files with 107 additions and 85 deletions.
25 changes: 25 additions & 0 deletions build-tools/rustclippy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -e
if [ -d ./build-tools ]; then
targets=(
"Cargo.toml"
"sea-orm-cli/Cargo.toml"
"sea-orm-codegen/Cargo.toml"
"sea-orm-macros/Cargo.toml"
"sea-orm-migration/Cargo.toml"
"sea-orm-rocket/Cargo.toml"
)

for target in "${targets[@]}"; do
echo "cargo clippy --manifest-path ${target} --fix --allow-dirty --allow-staged"
cargo clippy --manifest-path "${target}" --fix --allow-dirty --allow-staged
done

examples=(`find examples -type f -name 'Cargo.toml'`)
for example in "${examples[@]}"; do
echo "cargo clippy --manifest-path ${example} --fix --allow-dirty --allow-staged"
cargo clippy --manifest-path "${example}" --fix --allow-dirty --allow-staged
done
else
echo "Please execute this script from the repository root."
fi
2 changes: 1 addition & 1 deletion examples/actix3_example/entity/src/post.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
2 changes: 1 addition & 1 deletion examples/actix_example/entity/src/post.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
2 changes: 1 addition & 1 deletion examples/axum_example/entity/src/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/example_cake.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cake")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/example_cake_filling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl EntityName for Entity {
}
}

#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model {
pub cake_id: i32,
pub filling_id: i32,
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/example_filling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl EntityName for Entity {
}
}

#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model {
pub id: i32,
pub name: String,
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/example_fruit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl EntityName for Entity {
}
}

#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model {
pub id: i32,
pub name: String,
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod form {
use sea_orm::entity::prelude::*;

#[derive(
Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, DeriveActiveModelBehavior,
Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel, DeriveActiveModelBehavior,
)]
pub struct Model {
pub id: i32,
Expand Down
12 changes: 6 additions & 6 deletions examples/basic/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ pub async fn all_about_select(db: &DbConn) -> Result<(), DbErr> {

println!("===== =====\n");

find_all_stream(&db).await.unwrap();
find_all_stream(db).await.unwrap();

println!("===== =====\n");

find_first_page(&db).await.unwrap();
find_first_page(db).await.unwrap();

println!("===== =====\n");

find_num_pages(&db).await.unwrap();
find_num_pages(db).await.unwrap();

Ok(())
}
Expand Down Expand Up @@ -180,15 +180,15 @@ async fn find_many_to_many(db: &DbConn) -> Result<(), DbErr> {
}

async fn all_about_select_json(db: &DbConn) -> Result<(), DbErr> {
find_all_json(&db).await?;
find_all_json(db).await?;

println!("===== =====\n");

find_together_json(&db).await?;
find_together_json(db).await?;

println!("===== =====\n");

count_fruits_by_cake_json(&db).await?;
count_fruits_by_cake_json(db).await?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion examples/graphql_example/entity/src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use async_graphql::*;
use sea_orm::{entity::prelude::*, DeleteMany};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize, SimpleObject)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize, SimpleObject)]
#[sea_orm(table_name = "notes")]
#[graphql(concrete(name = "Note", params()))]
pub struct Model {
Expand Down
1 change: 0 additions & 1 deletion examples/graphql_example/migration/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use sea_orm_migration::prelude::*;
use std::path::PathBuf;

#[cfg(debug_assertions)]
use dotenv::dotenv;
Expand Down
2 changes: 1 addition & 1 deletion examples/jsonrpsee_example/entity/src/post.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
2 changes: 1 addition & 1 deletion examples/poem_example/entity/src/post.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
2 changes: 1 addition & 1 deletion examples/rocket_example/entity/src/post.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rocket::serde::{Deserialize, Serialize};
use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize, FromForm)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize, FromForm)]
#[serde(crate = "rocket::serde")]
#[sea_orm(table_name = "posts")]
pub struct Model {
Expand Down
2 changes: 1 addition & 1 deletion examples/salvo_example/entity/src/post.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
2 changes: 1 addition & 1 deletion examples/tonic_example/entity/src/post.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "posts")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
8 changes: 4 additions & 4 deletions sea-orm-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Cli {
pub command: Commands,
}

#[derive(Subcommand, PartialEq, Debug)]
#[derive(Subcommand, PartialEq, Eq, Debug)]
pub enum Commands {
#[clap(about = "Codegen related commands")]
#[clap(arg_required_else_help = true)]
Expand All @@ -35,7 +35,7 @@ pub enum Commands {
},
}

#[derive(Subcommand, PartialEq, Debug)]
#[derive(Subcommand, PartialEq, Eq, Debug)]
pub enum MigrateSubcommands {
#[clap(about = "Initialize migration directory")]
Init,
Expand Down Expand Up @@ -81,7 +81,7 @@ pub enum MigrateSubcommands {
},
}

#[derive(Subcommand, PartialEq, Debug)]
#[derive(Subcommand, PartialEq, Eq, Debug)]
pub enum GenerateSubcommands {
#[clap(about = "Generate entity")]
#[clap(arg_required_else_help = true)]
Expand Down Expand Up @@ -190,7 +190,7 @@ pub enum GenerateSubcommands {
},
}

#[derive(ArgEnum, Copy, Clone, Debug, PartialEq)]
#[derive(ArgEnum, Copy, Clone, Debug, PartialEq, Eq)]
pub enum DateTimeCrate {
Chrono,
Time,
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-codegen/src/entity/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct OutputFile {
pub content: String,
}

#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub enum WithSerde {
None,
Serialize,
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-migration/src/migrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use sea_schema::{mysql::MySql, postgres::Postgres, probe::SchemaProbe, sqlite::S

use super::{seaql_migrations, MigrationTrait, SchemaManager};

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
/// Status of migration
pub enum MigrationStatus {
/// Not yet applied
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-migration/src/seaql_migrations.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "seaql_migrations")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl MigrationTrait for Migration {
mod cake {
use sea_orm_migration::sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "cake")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-rocket/lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use rocket::serde::{Deserialize, Serialize};
/// For general information on configuration in Rocket, see [`rocket::config`].
/// For higher-level details on configuring a database, see the [crate-level
/// docs](crate#configuration).
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(crate = "rocket::serde")]
pub struct Config {
/// Database-specific connection and configuration URL.
Expand Down
2 changes: 1 addition & 1 deletion src/database/db_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub type DbConn = DatabaseConnection;

/// The type of database backend for real world databases.
/// This is enabled by feature flags as specified in the crate documentation
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum DatabaseBackend {
/// A MySQL backend
MySql,
Expand Down
2 changes: 1 addition & 1 deletion src/database/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ mod tests {
};
use pretty_assertions::assert_eq;

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct MyErr(String);

impl std::error::Error for MyErr {}
Expand Down
12 changes: 6 additions & 6 deletions src/entity/active_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ mod tests {

#[test]
fn active_enum_string() {
#[derive(Debug, PartialEq, EnumIter)]
#[derive(Debug, PartialEq, Eq, EnumIter)]
pub enum Category {
Big,
Small,
Expand Down Expand Up @@ -176,7 +176,7 @@ mod tests {
}
}

#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(
rs_type = "String",
db_type = "String(Some(1))",
Expand Down Expand Up @@ -234,7 +234,7 @@ mod tests {
fn active_enum_derive_signed_integers() {
macro_rules! test_num_value_int {
($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)]
pub enum $ident {
#[sea_orm(num_value = -10)]
Expand All @@ -251,7 +251,7 @@ mod tests {

macro_rules! test_fallback_int {
($ident: ident, $fallback_type: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)]
#[repr(i32)]
pub enum $ident {
Expand Down Expand Up @@ -300,7 +300,7 @@ mod tests {
fn active_enum_derive_unsigned_integers() {
macro_rules! test_num_value_uint {
($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)]
pub enum $ident {
#[sea_orm(num_value = 1)]
Expand All @@ -315,7 +315,7 @@ mod tests {

macro_rules! test_fallback_uint {
($ident: ident, $fallback_type: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)]
#[repr($fallback_type)]
pub enum $ident {
Expand Down
4 changes: 2 additions & 2 deletions src/entity/base_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ mod tests {
use crate as sea_orm;
use crate::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "hello")]
pub struct Model {
#[sea_orm(primary_key)]
Expand All @@ -898,7 +898,7 @@ mod tests {
use crate as sea_orm;
use crate::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "hello", schema_name = "world")]
pub struct Model {
#[sea_orm(primary_key)]
Expand Down
Loading

0 comments on commit 43495de

Please sign in to comment.