Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

cargo sqlx prepare #507

cargo sqlx prepare

cargo sqlx prepare #507

GitHub Actions / clippy succeeded Oct 27, 2023 in 0s

clippy

16 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 16
Note 0
Help 0

Versions

  • rustc 1.73.0 (cc66ad468 2023-10-03)
  • cargo 1.73.0 (9c4383fb5 2023-08-26)
  • clippy 0.1.73 (cc66ad4 2023-10-03)

Annotations

Check warning on line 194 in src/routes/v3/users.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/routes/v3/users.rs:194:67
    |
194 |         filter_authorized_projects(projects, Some(&current_user), &pool).await?;
    |                                                                   ^^^^^ help: change this to: `pool`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 194 in src/routes/v3/users.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/routes/v3/users.rs:194:51
    |
194 |         filter_authorized_projects(projects, Some(&current_user), &pool).await?;
    |                                                   ^^^^^^^^^^^^^ help: change this to: `current_user`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 192 in src/routes/v3/users.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/routes/v3/users.rs:192:77
    |
192 |     let projects = db_models::Project::get_many_ids(&project_ids, &***pool, &redis).await?;
    |                                                                             ^^^^^^ help: change this to: `redis`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

Check warning on line 189 in src/routes/v3/users.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `ProjectId` which implements the `Copy` trait

warning: using `clone` on type `ProjectId` which implements the `Copy` trait
   --> src/routes/v3/users.rs:189:23
    |
189 |             } => Some(project_id.clone()),
    |                       ^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*project_id`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check warning on line 190 in src/routes/v3/users.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `.filter_map` can be written more simply using `.map`

warning: this `.filter_map` can be written more simply using `.map`
   --> src/routes/v3/users.rs:183:23
    |
183 |       let project_ids = events
    |  _______________________^
184 | |         .iter()
185 | |         .filter_map(|e| match &e.event_data {
186 | |             EventData::ProjectCreated {
...   |
189 | |             } => Some(project_id.clone()),
190 | |         })
    | |__________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map
    = note: `#[warn(clippy::unnecessary_filter_map)]` on by default

Check warning on line 438 in src/routes/v3/oauth_clients.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`

warning: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
   --> src/routes/v3/oauth_clients.rs:438:39
    |
438 |     let ids: Vec<OAuthClientId> = ids.into_iter().map(|i| (*i).into()).collect();
    |                                       ^^^^^^^^^ help: call directly: `iter`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref

Check warning on line 83 in src/routes/v3/follow.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7)
  --> src/routes/v3/follow.rs:74:1
   |
74 | / pub async fn unfollow<T, TId, Fut1, Fut2>(
75 | |     req: HttpRequest,
76 | |     target_id: web::Path<String>,
77 | |     pool: web::Data<PgPool>,
...  |
82 | |     error_word: &str,
83 | | ) -> Result<HttpResponse, ApiError>
   | |___________________________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments

Check warning on line 38 in src/routes/v3/follow.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7)
  --> src/routes/v3/follow.rs:29:1
   |
29 | / pub async fn follow<T, TId, Fut1, Fut2>(
30 | |     req: HttpRequest,
31 | |     target_id: web::Path<String>,
32 | |     pool: web::Data<PgPool>,
...  |
37 | |     error_word: &str,
38 | | ) -> Result<HttpResponse, ApiError>
   | |___________________________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
   = note: `#[warn(clippy::too_many_arguments)]` on by default

Check warning on line 908 in src/routes/v2/project_creation.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

redundant closure

warning: redundant closure
   --> src/routes/v2/project_creation.rs:908:17
    |
908 |                 |org| CreatorId::Organization(org),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `CreatorId::Organization`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

Check warning on line 851 in src/routes/v2/project_creation.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

useless conversion to the same type: `models::organizations::OrganizationId`

warning: useless conversion to the same type: `models::organizations::OrganizationId`
   --> src/routes/v2/project_creation.rs:851:71
    |
851 |             organization: project_create_data.organization_id.map(|x| x.into()),
    |                                                                       ^^^^^^^^ help: consider removing `.into()`: `x`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `#[warn(clippy::useless_conversion)]` on by default

Check warning on line 83 in src/database/models/oauth_client_item.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`

warning: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
  --> src/database/models/oauth_client_item.rs:83:23
   |
83 |         let ids = ids.into_iter().map(|id| id.0).collect_vec();
   |                       ^^^^^^^^^ help: call directly: `iter`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref

Check warning on line 282 in src/database/models/event_item.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`

warning: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
   --> src/database/models/event_item.rs:282:10
    |
282 |         .into_iter()
    |          ^^^^^^^^^ help: call directly: `iter`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
    = note: `#[warn(clippy::into_iter_on_ref)]` on by default

Check warning on line 211 in src/database/models/event_item.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

question mark operator is useless here

warning: question mark operator is useless here
   --> src/database/models/event_item.rs:179:9
    |
179 | /         Ok(sqlx::query_as!(
180 | |             RawEvent,
181 | |             r#"
182 | |             SELECT 
...   |
210 | |         .map(|r| r.try_into())
211 | |         .collect::<Result<Vec<_>, _>>()?)
    | |_________________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
    = note: `#[warn(clippy::needless_question_mark)]` on by default
help: try removing question mark and `Ok()`
    |
179 ~         sqlx::query_as!(
180 +             RawEvent,
181 +             r#"
182 +             SELECT 
183 +                 id,
184 +                 target_id,
185 +                 target_id_type as "target_id_type: _",
186 +                 triggerer_id,
187 +                 triggerer_id_type as "triggerer_id_type: _",
188 +                 event_type as "event_type: _",
189 +                 metadata,
190 +                 created
191 +             FROM events e
192 +             WHERE 
193 +                 (target_id, target_id_type, event_type) 
194 +                 = ANY(SELECT * FROM UNNEST ($1::bigint[], $2::text[], $3::text[]))
195 +             OR
196 +                 (triggerer_id, triggerer_id_type, event_type) 
197 +                 = ANY(SELECT * FROM UNNEST ($4::bigint[], $5::text[], $6::text[]))
198 +             ORDER BY created DESC
199 +             "#,
200 +             &target_ids[..],
201 +             &target_id_types[..] as &[IdType],
202 +             &target_event_types[..] as &[EventType],
203 +             &triggerer_ids[..],
204 +             &triggerer_id_types[..] as &[IdType],
205 +             &triggerer_event_types[..] as &[EventType]
206 +         )
207 +         .fetch_all(exec)
208 +         .await?
209 +         .into_iter()
210 +         .map(|r| r.try_into())
211 +         .collect::<Result<Vec<_>, _>>()
    |

Check warning on line 144 in src/database/models/event_item.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

redundant closure

warning: redundant closure
   --> src/database/models/event_item.rs:144:21
    |
144 |                     |c| Ok(c),
    |                     ^^^^^^^^^ help: replace the closure with the function itself: `Ok`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
    = note: `#[warn(clippy::redundant_closure)]` on by default

Check warning on line 26 in src/auth/checks.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `Option<&User>` which implements the `Copy` trait

warning: using `clone` on type `Option<&User>` which implements the `Copy` trait
  --> src/auth/checks.rs:26:44
   |
26 |             .map(|c| c.validate_authorized(user_option.clone()))
   |                                            ^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `user_option`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
   = note: `#[warn(clippy::clone_on_copy)]` on by default

Check warning on line 27 in src/auth/checks.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

`.map().collect()` can be replaced with `.try_for_each()`

warning: `.map().collect()` can be replaced with `.try_for_each()`
  --> src/auth/checks.rs:25:9
   |
25 | /         self.into_iter()
26 | |             .map(|c| c.validate_authorized(user_option.clone()))
27 | |             .collect()
   | |______________________^ help: try: `self.into_iter().try_for_each(|c| c.validate_authorized(user_option.clone()))`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_collect_result_unit
   = note: `#[warn(clippy::map_collect_result_unit)]` on by default