Commit 1d61279e authored by Robert Czechowski's avatar Robert Czechowski

Fix clippy complaints / update clippy lints to ignore / format code

parent 04eea1df
Pipeline #741 failed with stage
in 6 minutes and 43 seconds
......@@ -20,7 +20,7 @@ format: src/db_conn_postgres.rs
cargo +nightly fmt
clippy: src/db_conn_postgres.rs
cargo clippy --all-targets --features 'complete debug' -- -D warnings -A clippy::type-complexity -A clippy::option-map-unit-fn -A clippy::len-zero
cargo clippy --all-targets --features 'complete debug' -- -D warnings -A clippy::type-complexity -A clippy::option-map-unit-fn -A clippy::len-zero -A clippy::option-as-ref-deref
src/db_conn_postgres.rs: src/db_conn_warning_header.txt src/db_conn_sqlite_new.header.rs src/db_conn_postgres.header.rs src/db_conn.base.rs
cd src; ./generate_connectors.sh
......
......@@ -750,8 +750,7 @@ pub fn add_group<T: MedalConnection>(conn: &T, session_token: &str, csrf_token:
let groupcode = helpers::make_group_code();
// TODO: check for collisions
let mut group =
Group { id: None, name, groupcode, tag, admin: session.id, members: Vec::new() };
let mut group = Group { id: None, name, groupcode, tag, admin: session.id, members: Vec::new() };
conn.add_group(&mut group);
......@@ -1164,7 +1163,7 @@ pub fn admin_delete_user<T: MedalConnection>(conn: &T, user_id: i32, session_tok
if session.csrf_token != csrf_token {
return Err(MedalError::CsrfCheckFailed);
}
let parts = conn.get_all_participations_complete(user_id);
let groups = conn.get_groups(user_id);
......@@ -1230,7 +1229,7 @@ pub fn admin_delete_group<T: MedalConnection>(conn: &T, group_id: i32, session_t
if session.csrf_token != csrf_token {
return Err(MedalError::CsrfCheckFailed);
}
let group = conn.get_group_complete(group_id).unwrap(); // TODO handle error
let mut data = json_val::Map::new();
......@@ -1302,8 +1301,7 @@ pub fn admin_delete_participation<T: MedalConnection>(conn: &T, user_id: i32, co
}
let user = conn.get_user_by_id(user_id).ok_or(MedalError::AccessDenied)?;
let _part =
conn.get_participation(&user.session_token.unwrap(), contest_id).ok_or(MedalError::AccessDenied)?;
let _part = conn.get_participation(&user.session_token.unwrap(), contest_id).ok_or(MedalError::AccessDenied)?;
let data = json_val::Map::new();
conn.delete_participation(user_id, contest_id);
......
......@@ -1306,7 +1306,7 @@ impl MedalConnection for Connection {
AND session = $2";
self.execute(query, &[&contest_id, &user_id]).unwrap();
}
fn get_search_users(&self,
(s_id, s_firstname, s_lastname, s_logincode, s_groupcode, s_pms_id): (Option<i32>,
Option<String>,
......
......@@ -1418,7 +1418,7 @@ impl MedalConnection for Connection {
AND session = $2";
self.execute(query, &[&contest_id, &user_id]).unwrap();
}
fn get_search_users(&self,
(s_id, s_firstname, s_lastname, s_logincode, s_groupcode, s_pms_id): (Option<i32>,
Option<String>,
......
......@@ -1418,7 +1418,7 @@ impl MedalConnection for Connection {
AND session = ?2";
self.execute(query, &[&contest_id, &user_id]).unwrap();
}
fn get_search_users(&self,
(s_id, s_firstname, s_lastname, s_logincode, s_groupcode, s_pms_id): (Option<i32>,
Option<String>,
......
......@@ -315,19 +315,12 @@ impl SessionUser {
impl Taskgroup {
pub fn new(name: String, positionalnumber: Option<i32>) -> Self {
Taskgroup { id: None,
contest: 0,
name,
active: true,
positionalnumber,
tasks: Vec::new() }
Taskgroup { id: None, contest: 0, name, active: true, positionalnumber, tasks: Vec::new() }
}
}
impl Task {
pub fn new(location: String, stars: i32) -> Self {
Task { id: None, taskgroup: 0, location, stars }
}
pub fn new(location: String, stars: i32) -> Self { Task { id: None, taskgroup: 0, location, stars } }
}
pub trait OptionSession {
......
......@@ -603,7 +603,7 @@ fn submission<C>(req: &mut Request) -> IronResult<Response>
let result = with_conn![core::load_submission, C, req, task_id, &session_token, subtask];
match result {
Ok(data) => Ok(Response::with((status::Ok, mime!(Application / Json), data.to_string()))),
Ok(data) => Ok(Response::with((status::Ok, mime!(Application / Json), data))),
Err(_) => Ok(Response::with((status::BadRequest, mime!(Application / Json), "{}".to_string()))),
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment