Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Mar 10, 2023
1 parent d644217 commit 74b437d
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 25 deletions.
16 changes: 16 additions & 0 deletions build-tools/rustclippy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

if [ ! -d ./build-tools ]; then

echo "Please execute this script from the repository root."
exit 1

fi

crates=(`find . -type f -name 'Cargo.toml'`)
for crate in "${crates[@]}"; do
echo "cargo clippy --manifest-path ${crate} --fix --allow-dirty --allow-staged"
cargo clippy --manifest-path "${crate}" --fix --allow-dirty --allow-staged
done
6 changes: 3 additions & 3 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn parse_database_url(database_url: &str) -> Result<url::Url, url::ParseErro
// information from a particular database
let database_name = url
.path_segments()
.expect(format!("There is no database name as part of the url path: {}", url).as_str())
.unwrap_or_else(|| panic!("There is no database name as part of the url path: {}", url))
.next()
.unwrap();

Expand Down Expand Up @@ -109,7 +109,7 @@ async fn main() {
let ignore_tables = args
.ignore_tables
.unwrap_or_else(|| "seaql_migrations".into());
let ignore_tables: Vec<&str> = ignore_tables.split(",").collect();
let ignore_tables: Vec<&str> = ignore_tables.split(',').collect();

let hidden_tables = args.hidden_tables.unwrap_or(true);

Expand All @@ -120,7 +120,7 @@ async fn main() {
.into_iter()
.filter(|(key, _)| {
if hidden_tables {
!key.starts_with("_")
!key.starts_with('_')
} else {
true
}
Expand Down
6 changes: 3 additions & 3 deletions examples/mysql/src/entities/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ impl seaography::EntityOrderBy<Entity> for OrderBy {
} else {
stmt
};
let stmt = if let Some(order_by) = self.last_update {

if let Some(order_by) = self.last_update {
match order_by {
seaography::OrderByEnum::Asc => {
stmt.order_by(Column::LastUpdate, sea_orm::query::Order::Asc)
Expand All @@ -249,8 +250,7 @@ impl seaography::EntityOrderBy<Entity> for OrderBy {
}
} else {
stmt
};
stmt
}
}
}
impl seaography::EnhancedEntity for Entity {
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lazy_static! {

#[handler]
async fn graphql_playground() -> impl IntoResponse {
Html(playground_source(GraphQLPlaygroundConfig::new(&*ENDPOINT)))
Html(playground_source(GraphQLPlaygroundConfig::new(&ENDPOINT)))
}

#[tokio::main]
Expand Down
8 changes: 4 additions & 4 deletions examples/mysql/tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ pub async fn get_schema() -> Schema<QueryRoot, EmptyMutation, EmptySubscription>
},
tokio::spawn,
);
let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription)


Schema::build(QueryRoot, EmptyMutation, EmptySubscription)
.data(database)
.data(orm_dataloader)
.finish();

schema
.finish()
}

pub fn assert_eq(a: Response, b: &str) {
Expand Down
2 changes: 1 addition & 1 deletion examples/postgres/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lazy_static! {

#[handler]
async fn graphql_playground() -> impl IntoResponse {
Html(playground_source(GraphQLPlaygroundConfig::new(&*ENDPOINT)))
Html(playground_source(GraphQLPlaygroundConfig::new(&ENDPOINT)))
}

#[tokio::main]
Expand Down
8 changes: 4 additions & 4 deletions examples/postgres/tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ pub async fn get_schema() -> Schema<QueryRoot, EmptyMutation, EmptySubscription>
},
tokio::spawn,
);
let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription)


Schema::build(QueryRoot, EmptyMutation, EmptySubscription)
.data(database)
.data(orm_dataloader)
.finish();

schema
.finish()
}

pub fn assert_eq(a: Response, b: &str) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sqlite/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lazy_static! {

#[handler]
async fn graphql_playground() -> impl IntoResponse {
Html(playground_source(GraphQLPlaygroundConfig::new(&*ENDPOINT)))
Html(playground_source(GraphQLPlaygroundConfig::new(&ENDPOINT)))
}

#[tokio::main]
Expand Down
8 changes: 4 additions & 4 deletions examples/sqlite/tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ pub async fn get_schema() -> Schema<QueryRoot, EmptyMutation, EmptySubscription>
},
tokio::spawn,
);
let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription)


Schema::build(QueryRoot, EmptyMutation, EmptySubscription)
.data(database)
.data(orm_dataloader)
.finish();

schema
.finish()
}

pub fn assert_eq(a: Response, b: &str) {
Expand Down
6 changes: 3 additions & 3 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub async fn write_project<P: AsRef<Path>>(
depth_limit: Option<usize>,
complexity_limit: Option<usize>,
) -> Result<()> {
std::fs::create_dir_all(&path.as_ref().join("src/entities"))?;
std::fs::create_dir_all(path.as_ref().join("src/entities"))?;

writer::write_cargo_toml(path, crate_name, &sql_library, framework)?;
writer::write_cargo_toml(path, crate_name, sql_library, framework)?;

let src_path = &path.as_ref().join("src");

Expand All @@ -54,7 +54,7 @@ pub async fn write_project<P: AsRef<Path>>(

std::process::Command::new("cargo")
.arg("fmt")
.current_dir(&path)
.current_dir(path)
.spawn()?
.wait()?;

Expand Down
1 change: 0 additions & 1 deletion generator/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub fn generate_query_root(
) -> Result<TokenStream, crate::error::Error> {
let items: Vec<_> = entities_hashmap
.keys()
.into_iter()
.filter(|entity| {
entity.ne(&&"mod.rs".to_string())
&& entity.ne(&&"prelude.rs".to_string())
Expand Down

0 comments on commit 74b437d

Please sign in to comment.