Commit 3c52b722 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

New clippy fixes

parent 68d2b546
Pipeline #929 failed with stages
in 6 minutes and 34 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 -A clippy::option-as-ref-deref -A clippy::or-fun-call
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 -A clippy::or-fun-call -A clippy::comparison-to-empty -A clippy::unnecessary-wraps -A clippy::result-unit-err
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
......
......@@ -587,8 +587,7 @@ pub fn signup<T: MedalConnection>(conn: &T, session_token: Option<String>, signu
pub fn signupdata(query_string: Option<String>) -> json_val::Map<String, json_val::Value> {
let mut data = json_val::Map::new();
if let Some(query) = query_string {
if query.starts_with("status=") {
let status: &str = &query[7..];
if let Some(status) = query.strip_prefix("status=") {
if ["EmailTaken", "UsernameTaken", "UserLoggedIn", "EmptyFields"].contains(&status) {
data.insert((status).to_string(), to_json(&true));
}
......@@ -978,8 +977,7 @@ pub fn show_profile<T: MedalConnection>(conn: &T, session_token: &str, user_id:
data.insert("ownprofile".into(), to_json(&true));
if let Some(query) = query_string {
if query.starts_with("status=") {
let status: &str = &query[7..];
if let Some(status) = query.strip_prefix("status=") {
if ["NothingChanged",
"DataChanged",
"PasswordChanged",
......@@ -1043,8 +1041,7 @@ pub fn show_profile<T: MedalConnection>(conn: &T, session_token: &str, user_id:
data.insert("ownprofile".into(), to_json(&false));
if let Some(query) = query_string {
if query.starts_with("status=") {
let status: &str = &query[7..];
if let Some(status) = query.strip_prefix("status=") {
if ["NothingChanged", "DataChanged", "PasswordChanged", "PasswordMissmatch"].contains(&status) {
data.insert((status).to_string(), to_json(&true));
}
......@@ -1063,8 +1060,8 @@ pub enum ProfileStatus {
PasswordChanged,
PasswordMissmatch,
}
impl std::convert::Into<String> for ProfileStatus {
fn into(self) -> String { format!("{:?}", self) }
impl From<ProfileStatus> for String {
fn from(s: ProfileStatus) -> String { format!("{:?}", s) }
}
pub fn edit_profile<T: MedalConnection>(conn: &T, session_token: &str, user_id: Option<i32>, csrf_token: &str,
......
......@@ -65,9 +65,9 @@ use webfw_iron::start_server;
use config::Config;
use structopt::StructOpt;
use std::path::{Path, PathBuf};
use std::path::Path;
fn read_contest(p: &PathBuf) -> Option<Contest> {
fn read_contest(p: &Path) -> Option<Contest> {
use std::fs::File;
use std::io::Read;
......@@ -81,7 +81,7 @@ fn read_contest(p: &PathBuf) -> Option<Contest> {
}
fn get_all_contest_info(task_dir: &str) -> Vec<Contest> {
fn walk_me_recursively(p: &PathBuf, contests: &mut Vec<Contest>) {
fn walk_me_recursively(p: &Path, contests: &mut Vec<Contest>) {
if let Ok(paths) = std::fs::read_dir(p) {
for path in paths {
let p = path.unwrap().path();
......@@ -92,7 +92,7 @@ fn get_all_contest_info(task_dir: &str) -> Vec<Contest> {
if p.file_name().unwrap().to_string_lossy().to_string().ends_with(".yaml") {
read_contest(p).map(|contest| contests.push(contest));
};
};
}
let mut contests = Vec::new();
match std::fs::read_dir(task_dir) {
......
......@@ -99,7 +99,7 @@ impl AfterMiddleware for ErrorShower {
Ok(match response.status {
Some(s) => {
let n = s.to_u16();
if n >= 400 && n <= 599 {
if (400..=599).contains(&n) {
response.set((mime!(Text / Html),
format!("<h1>{} {}</h1>", n, s.canonical_reason().unwrap_or("(Unknown error)"))))
} else {
......
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