From 44fed91e17d7ed08edba775c33b463886f22a0fd Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 11 Sep 2019 12:23:11 +0200 Subject: [PATCH] more clippy fixups mostly indentation changes, view with `-w` Signed-off-by: Wolfgang Bumiller --- src/api_schema/format.rs | 13 +++++------- src/api_schema/schema.rs | 44 +++++++++++++++++---------------------- src/client/http_client.rs | 2 +- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/api_schema/format.rs b/src/api_schema/format.rs index e4277bd7..2af0be85 100644 --- a/src/api_schema/format.rs +++ b/src/api_schema/format.rs @@ -51,8 +51,7 @@ pub fn wrap_text(initial_indent: &str, subsequent_indent: &str, text: &str, colu } pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String { - - let type_text = match schema { + match schema { Schema::Null => String::from(""), // should not happen Schema::String(_) => String::from(""), Schema::Boolean(_) => String::from(""), @@ -66,9 +65,7 @@ pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> S }, Schema::Object(_) => String::from(""), Schema::Array(_) => String::from(""), - }; - - type_text + } } pub fn get_property_description( @@ -229,14 +226,14 @@ fn dump_api_return_schema(schema: &Schema) -> String { fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> Option { match def { - MethodDefinition::None => return None, + MethodDefinition::None => None, MethodDefinition::Simple(simple_method) => { let param_descr = dump_api_parameters(&simple_method.parameters); let return_descr = dump_api_return_schema(&simple_method.returns); let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr); - return Some(res); + Some(res) } MethodDefinition::Async(async_method) => { let method = if method == "POST" { "UPLOAD" } else { method }; @@ -247,7 +244,7 @@ fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> O let return_descr = dump_api_return_schema(&async_method.returns); let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr); - return Some(res); + Some(res) } } } diff --git a/src/api_schema/schema.rs b/src/api_schema/schema.rs index 38d9a44b..a7875575 100644 --- a/src/api_schema/schema.rs +++ b/src/api_schema/schema.rs @@ -417,12 +417,10 @@ fn parse_property_string(value_str: &str, schema: &Schema) -> Result = key_val.splitn(2, '=').collect(); if kv.len() == 2 { param_list.push((kv[0].into(), kv[1].into())); + } else if let Some(key) = object_schema.default_key { + param_list.push((key.into(), kv[0].into())); } else { - if let Some(key) = object_schema.default_key { - param_list.push((key.into(), kv[0].into())); - } else { - bail!("Value without key, but schema does not define a default key."); - } + bail!("Value without key, but schema does not define a default key."); } } @@ -511,24 +509,22 @@ pub fn parse_parameter_strings(data: &Vec<(String, String)>, schema: &ObjectSche } } } - } else { - if additional_properties { - match params[key] { - Value::Null => { - params[key] = Value::String(value.to_owned()); - }, - Value::String(ref old) => { - params[key] = Value::Array( - vec![Value::String(old.to_owned()), Value::String(value.to_owned())]); - } - Value::Array(ref mut array) => { - array.push(Value::String(value.to_string())); - } - _ => errors.push(format_err!("parameter '{}': expected array - type missmatch", key)), + } else if additional_properties { + match params[key] { + Value::Null => { + params[key] = Value::String(value.to_owned()); + }, + Value::String(ref old) => { + params[key] = Value::Array( + vec![Value::String(old.to_owned()), Value::String(value.to_owned())]); } - } else { - errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key)); + Value::Array(ref mut array) => { + array.push(Value::String(value.to_string())); + } + _ => errors.push(format_err!("parameter '{}': expected array - type missmatch", key)), } + } else { + errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key)); } } @@ -638,10 +634,8 @@ pub fn verify_json_object(data: &Value, schema: &ObjectSchema) -> Result<(), Err } _ => verify_json(value, prop_schema)?, } - } else { - if !additional_properties { - bail!("property '{}': schema does not allow additional properties.", key); - } + } else if !additional_properties { + bail!("property '{}': schema does not allow additional properties.", key); } } diff --git a/src/client/http_client.rs b/src/client/http_client.rs index b3d5d779..85b71ffc 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -494,7 +494,7 @@ impl Drop for BackupReader { impl BackupReader { pub fn new(h2: H2Client, canceller: Canceller) -> Arc { - Arc::new(Self { h2, canceller: canceller }) + Arc::new(Self { h2, canceller }) } pub async fn get(