Skip to content

Commit b1b545e

Browse files
authored
chore: warn on clippy::allow_attributes; fix clippy warnings (#363)
1 parent bc69ab3 commit b1b545e

File tree

13 files changed

+63
-24
lines changed

13 files changed

+63
-24
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ rust_2018_idioms = { level = "warn", priority = -1 }
4747
all = { level = "deny", priority = -1 }
4848
pedantic = "warn"
4949
future_not_send = "warn"
50+
allow_attributes = "warn"
5051

5152
[workspace.dependencies]
5253
ahash = { version = "0.8.11", default-features = false }
@@ -104,8 +105,8 @@ proc-macro2 = { version = "1", default-features = false }
104105
quote = { version = "1", default-features = false }
105106
rand = { version = "0.9", default-features = false }
106107
rustversion = "1"
107-
redis = { version = "0.29.1", default-features = false }
108-
deadpool-redis = { version = "0.20.0", default-features = false }
108+
redis = { version = "0.29.1", default-features = false }
109+
deadpool-redis = { version = "0.20.0", default-features = false }
109110
schemars = { version = "0.8.22", default-features = false }
110111
sea-query = { version = "0.32", default-features = false }
111112
sea-query-binder = { version = "0.7", default-features = false }

cot-cli/src/migration_generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ impl DynMigration for Migration {
12631263
/// This is used to generate migration files.
12641264
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12651265
// this is not frequently used, so we don't mind extra memory usage
1266-
#[allow(clippy::large_enum_variant)]
1266+
#[expect(clippy::large_enum_variant)]
12671267
pub enum DynDependency {
12681268
Migration { app: String, migration: String },
12691269
Model { model_type: syn::Type },

cot/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub type Result<T> = std::result::Result<T, DatabaseError>;
120120
note = "annotate `{Self}` with the `#[cot::db::model]` attribute"
121121
)]
122122
pub trait Model: Sized + Send + 'static {
123-
#[allow(clippy::doc_markdown)] // UPPER_SNAKE_CASE
123+
#[expect(clippy::doc_markdown, reason = "UPPER_SNAKE_CASE")]
124124
/// A helper structure for the fields of the model.
125125
///
126126
/// This structure should a constant [`FieldRef`](query::FieldRef) instance

cot/src/db/fields.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,12 @@ macro_rules! impl_db_field_with_postgres_int_cast {
170170

171171
#[cfg(feature = "postgres")]
172172
fn from_postgres(value: PostgresValueRef<'_>) -> Result<Self> {
173-
#[allow(clippy::cast_possible_truncation)]
174-
#[allow(clippy::cast_sign_loss)]
173+
#[allow(
174+
clippy::allow_attributes,
175+
clippy::cast_possible_truncation,
176+
clippy::cast_sign_loss,
177+
reason = "needed for casting from larger to smaller integer types"
178+
)]
175179
value.get::<$src_ty>().map(|v| v as $dest_ty)
176180
}
177181
}
@@ -183,8 +187,12 @@ macro_rules! impl_db_field_with_postgres_int_cast {
183187

184188
#[cfg(feature = "postgres")]
185189
fn from_postgres(value: PostgresValueRef<'_>) -> Result<Self> {
186-
#[allow(clippy::cast_possible_truncation)]
187-
#[allow(clippy::cast_sign_loss)]
190+
#[allow(
191+
clippy::allow_attributes,
192+
clippy::cast_possible_truncation,
193+
clippy::cast_sign_loss,
194+
reason = "needed for casting from larger to smaller integer types"
195+
)]
188196
value
189197
.get::<Option<$src_ty>>()
190198
.map(|v| v.map(|v| v as $dest_ty))

cot/src/form/fields.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ mod tests {
12211221
}
12221222

12231223
#[cot::test]
1224-
#[allow(clippy::float_cmp)]
1224+
#[expect(clippy::float_cmp)]
12251225
async fn float_field_clean_value() {
12261226
let mut field = FloatField::<f32>::with_options(
12271227
FormFieldOptions {

cot/src/handler.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ macro_rules! impl_request_handler {
8080
Fut: Future<Output = R> + Send,
8181
R: IntoResponse,
8282
{
83-
#[allow(non_snake_case)]
83+
#[allow(
84+
clippy::allow_attributes,
85+
non_snake_case,
86+
reason = "for the case where there are no params"
87+
)]
8488
async fn handle(&self, request: Request) -> Result<Response> {
85-
#[allow(unused_variables, unused_mut)] // for the case where there are no params
89+
#[allow(
90+
clippy::allow_attributes,
91+
unused_variables,
92+
unused_mut,
93+
reason = "for the case where there are no params"
94+
)]
8695
let (mut parts, _body) = request.into_parts();
8796

8897
$(
@@ -106,9 +115,17 @@ macro_rules! impl_request_handler_from_request {
106115
Fut: Future<Output = R> + Send,
107116
R: IntoResponse,
108117
{
109-
#[expect(non_snake_case)]
118+
#[allow(
119+
clippy::allow_attributes,
120+
non_snake_case,
121+
reason = "for the case where there are no FromRequestParts params"
122+
)]
110123
async fn handle(&self, request: Request) -> Result<Response> {
111-
#[allow(unused_mut)] // for the case where there are no FromRequestParts params
124+
#[allow(
125+
clippy::allow_attributes,
126+
unused_mut,
127+
reason = "for the case where there are no FromRequestParts params"
128+
)]
112129
let (mut parts, body) = request.into_parts();
113130

114131
$(

cot/src/openapi.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,11 @@ macro_rules! impl_as_openapi_operation {
512512
R: for<'a> Future<Output = Response> + Send,
513513
Response: ApiOperationResponse,
514514
{
515-
#[allow(non_snake_case)]
515+
#[allow(
516+
clippy::allow_attributes,
517+
non_snake_case,
518+
reason = "for the case where there are no FromRequestParts params"
519+
)]
516520
fn as_api_operation(
517521
&self,
518522
route_context: &RouteContext<'_>,

cot/src/request/path_params_deserializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ mod tests {
649649
macro_rules! test_deserialize_value {
650650
($test_name:ident, $ty:ty, $value:literal, $expected:literal) => {
651651
#[test]
652-
#[allow(clippy::float_cmp)]
652+
#[allow(clippy::allow_attributes, clippy::float_cmp)]
653653
fn $test_name() {
654654
let path_params = create_path_params([("some_name", $value)]);
655655
let deserializer = PathParamsDeserializer::new(&path_params);

cot/src/router.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,11 @@ where
862862
#[macro_export]
863863
macro_rules! reverse {
864864
($request:expr, $view_name:literal $(, $($key:ident = $value:expr),*)?) => {{
865-
#[allow(unused_imports)] // allow using either `Request` or `Urls` objects
865+
#[allow(
866+
clippy::allow_attributes,
867+
unused_imports,
868+
reason = "allow using either `Request` or `Urls` objects"
869+
)]
866870
use $crate::request::RequestExt;
867871
let (app_name, view_name) = $crate::router::split_view_name($view_name);
868872
let app_name = app_name.or_else(|| $request.app_name());

cot/src/router/path.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,10 @@ impl ReverseParamMap {
256256
#[doc(hidden)]
257257
#[macro_export]
258258
macro_rules! reverse_param_map {
259+
() => {{
260+
$crate::router::path::ReverseParamMap::new()
261+
}};
259262
($($key:ident = $value:expr),*) => {{
260-
#[allow(unused_mut)] // for the case when there are no parameters
261263
let mut map = $crate::router::path::ReverseParamMap::new();
262264
$( map.insert(stringify!($key), &$value); )*
263265
map

0 commit comments

Comments
 (0)