Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/fix clippy errors #2056

Merged
merged 20 commits into from
Jan 10, 2024

Conversation

shogo-nakano-desu
Copy link
Contributor

@shogo-nakano-desu shogo-nakano-desu commented Jan 10, 2024

Changes

Fix clippy errors and warnings. This is a follow up PR of #2030

clippy.toml Outdated
@@ -0,0 +1 @@
allow-unwrap-in-tests = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added this file to configure clippy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be a #![allow(clippy::unwrap_used, clippy::expect_used)] directive in test files would be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that. It might be better because clippy config file like clippy.toml is unstable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed
889d250

@shogo-nakano-desu shogo-nakano-desu marked this pull request as ready for review January 10, 2024 13:14
@@ -345,7 +345,6 @@ pub mod tests_cfg;
mod util;

pub use database::*;
pub use driver::*;
Copy link
Member

@tyt2y3 tyt2y3 Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing this line, I think we should add #[allow(clippy::unused_xxx)], because the content of the re-export depends on feature flags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed
138b9dc

I will add #[allow(clippy::unused_xxx)] later because I could not see clippy error in my local somehow...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added #[allow(unused_imports)]
20dc881

@@ -2,7 +2,6 @@ use crate::{
ColumnTrait, EntityTrait, IdenStatic, Iterable, QueryTrait, Select, SelectTwo, SelectTwoMany,
};
use core::marker::PhantomData;
pub use sea_query::JoinType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can confirm this is already exported in query.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it is not exported so I have reverted this change. e4f4a12

@@ -15,7 +15,6 @@ pub use combine::{SelectA, SelectB};
pub use delete::*;
pub use helper::*;
pub use insert::*;
pub use join::*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file contains only impl, so nothing to export

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, do we need to keep pub use join::*;?

@@ -36,6 +36,7 @@ impl std::fmt::Debug for SqlxMySqlPoolConnection {

impl SqlxMySqlConnector {
/// Check if the URI provided corresponds to `mysql://` for a MySQL database
#[cfg(feature = "mock")]
Copy link
Member

@tyt2y3 tyt2y3 Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what confuses me, this accepts method should be in the public API, why does clippy think it's redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is because the accepts method is not used from anywhere in this workspace except for mock. But if we want this method to be public, we need #[allow(unused_variables)] instead so I will replace them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove feature flag and I put #[allow(unused_variables)] instead
09f845a

@tyt2y3 tyt2y3 changed the base branch from master to clippy January 10, 2024 15:32
Copy link
Member

@tyt2y3 tyt2y3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I will make some tweaks

@tyt2y3 tyt2y3 merged commit 691c893 into SeaQL:clippy Jan 10, 2024
31 checks passed
@shogo-nakano-desu
Copy link
Contributor Author

Thank you so much for your review. I will check your PR and would like to learn from it:)

tyt2y3 pushed a commit that referenced this pull request Jan 10, 2024
* chore: add clippy config file

* refactor: fix clippy errors and wornings of runtime-async-std-native-tls,sqlx-all

* refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres

* chore: format

* refactor: fix clippy

* fix: import path

* refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres

* fix: revert some space and comma removal

* fix: revert some space and comma removal

* refactor: add feature flag

* fix: import path

* test: remove mismatch feature flag

* test: remove mismatch feature flag

* chore: add proper feature flag

* chore: remove feature flag

* refactor: remove clippy.toml file

* fix: re-export driver

* fix: re-export JoinType

* fix: remove feature flag

* chore: add #[allow(unused_imports)] for driver
tyt2y3 added a commit that referenced this pull request Jan 10, 2024
* chore: add clippy config file

* refactor: fix clippy errors and wornings of runtime-async-std-native-tls,sqlx-all

* refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres

* chore: format

* refactor: fix clippy

* fix: import path

* refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres

* fix: revert some space and comma removal

* fix: revert some space and comma removal

* refactor: add feature flag

* fix: import path

* test: remove mismatch feature flag

* test: remove mismatch feature flag

* chore: add proper feature flag

* chore: remove feature flag

* refactor: remove clippy.toml file

* fix: re-export driver

* fix: re-export JoinType

* fix: remove feature flag

* chore: add #[allow(unused_imports)] for driver

Co-authored-by: Shogo Nakano <61229807+shogo-nakano-desu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants