Skip to content

Commit

Permalink
Fix clippy lint
Browse files Browse the repository at this point in the history
  • Loading branch information
juhaku committed Feb 18, 2023
1 parent 959f7cb commit 937db4c
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 28 deletions.
2 changes: 1 addition & 1 deletion utoipa-gen/src/component/schema/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Parse for XmlAttr {
let wrapped_attribute = group.parse::<Ident>().map_err(|error| {
Error::new(
error.span(),
format!("unexpected attribute, expected: name, {}", error),
format!("unexpected attribute, expected: name, {error}"),
)
})?;
if wrapped_attribute != "name" {
Expand Down
4 changes: 2 additions & 2 deletions utoipa-gen/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Parse for PathAttr<'_> {
let ident = input.parse::<Ident>().map_err(|error| {
syn::Error::new(
error.span(),
format!("{}, {}", EXPECTED_ATTRIBUTE_MESSAGE, error),
format!("{EXPECTED_ATTRIBUTE_MESSAGE}, {error}"),
)
})?;
let attribute_name = &*ident.to_string();
Expand Down Expand Up @@ -277,7 +277,7 @@ impl PathOperation {
pub fn from_ident(ident: &Ident) -> Self {
match ident.to_string().as_str().parse::<PathOperation>() {
Ok(operation) => operation,
Err(error) => abort!(ident.span(), format!("{}", error)),
Err(error) => abort!(ident.span(), format!("{error}")),
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions utoipa-gen/src/path/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,7 @@ impl Parse for ValueParameter<'_> {
input.parse().map_err(|error| {
Error::new(
error.span(),
format!(
"unexpected token, expected type such as String, {}",
error
),
format!("unexpected token, expected type such as String, {error}"),
)
})
})?),
Expand Down Expand Up @@ -395,7 +392,7 @@ impl Parse for ParameterIn {
.map(ToString::to_string)
.collect::<Vec<_>>()
.join(", ");
format!("unexpected in, expected one of: {}", variants)
format!("unexpected in, expected one of: {variants}")
}
let style = input.parse::<Ident>()?;

Expand Down
6 changes: 3 additions & 3 deletions utoipa-gen/src/path/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Parse for ResponseTuple<'_> {
let ident = input.parse::<Ident>().map_err(|error| {
Error::new(
error.span(),
format!("{}, {}", EXPECTED_ATTRIBUTE_MESSAGE, error),
format!("{EXPECTED_ATTRIBUTE_MESSAGE}, {error}"),
)
})?;
let attribute_name = &*ident.to_string();
Expand Down Expand Up @@ -790,7 +790,7 @@ impl Parse for Header {
header.value_type = Some(input.parse().map_err(|error| {
Error::new(
error.span(),
format!("unexpected token, expected type such as String, {}", error),
format!("unexpected token, expected type such as String, {error}"),
)
})?);
}
Expand All @@ -805,7 +805,7 @@ impl Parse for Header {
.map_err(|error| {
Error::new(
error.span(),
format!("unexpected attribute, expected: description, {}", error),
format!("unexpected attribute, expected: description, {error}"),
)
})
.and_then(|ident| {
Expand Down
7 changes: 3 additions & 4 deletions utoipa-swagger-ui/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ use zip::{result::ZipError, ZipArchive};
const SWAGGER_UI_DIST_ZIP: &str = "swagger-ui-4.15.5";

fn main() {
println!("cargo:rerun-if-changed=res/{}.zip", SWAGGER_UI_DIST_ZIP);
println!("cargo:rerun-if-changed=res/{SWAGGER_UI_DIST_ZIP}.zip");
println!(
"cargo:rustc-env=UTOIPA_SWAGGER_UI_VERSION={}",
SWAGGER_UI_DIST_ZIP
"cargo:rustc-env=UTOIPA_SWAGGER_UI_VERSION={SWAGGER_UI_DIST_ZIP}"
);

let target_dir = env::var("OUT_DIR").unwrap();
println!("cargo:rustc-env=UTOIPA_SWAGGER_DIR={}", &target_dir);

let swagger_ui_zip = File::open(
["res", &format!("{}.zip", SWAGGER_UI_DIST_ZIP)]
["res", &format!("{SWAGGER_UI_DIST_ZIP}.zip")]
.iter()
.collect::<PathBuf>(),
)
Expand Down
4 changes: 1 addition & 3 deletions utoipa-swagger-ui/src/oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,7 @@ ui.initOAuth({
});"#;
assert!(
file.contains(expected),
"expected file to contain {}, was {}",
expected,
file
"expected file to contain {expected}, was {file}"
)
}
}
6 changes: 2 additions & 4 deletions utoipa/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,7 @@ mod tests {

assert_eq!(
serialized, raw_json,
"expected serialized json to match raw: \nserialized: \n{} \nraw: \n{}",
serialized, raw_json
"expected serialized json to match raw: \nserialized: \n{serialized} \nraw: \n{raw_json}"
);
Ok(())
}
Expand Down Expand Up @@ -567,8 +566,7 @@ mod tests {

assert_eq!(
serialized, expected,
"expected serialized json to match raw: \nserialized: \n{} \nraw: \n{}",
serialized, expected
"expected serialized json to match raw: \nserialized: \n{serialized} \nraw: \n{expected}"
);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion utoipa/src/openapi/request_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ mod tests {
)
.build();
let serialized = serde_json::to_string_pretty(&request_body)?;
println!("serialized json:\n {}", serialized);
println!("serialized json:\n {serialized}");
assert_json_eq!(
request_body,
json!({
Expand Down
2 changes: 1 addition & 1 deletion utoipa/src/openapi/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ mod tests {
)
.build();
let serialized = serde_json::to_string_pretty(&request_body)?;
println!("serialized json:\n {}", serialized);
println!("serialized json:\n {serialized}");
assert_json_eq!(
request_body,
json!({
Expand Down
7 changes: 3 additions & 4 deletions utoipa/src/openapi/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ macro_rules! to_array_builder {
}

/// Create an _`empty`_ [`Schema`] that serializes to _`null`_.
///
///
/// Can be used in places where an item can be serialized as `null`. This is used with unit type
/// enum variants and tuple unit types.
pub fn empty() -> Schema {
Expand Down Expand Up @@ -1198,7 +1198,7 @@ mod tests {
.build();

let serialized = serde_json::to_string_pretty(&openapi)?;
println!("serialized json:\n {}", serialized);
println!("serialized json:\n {serialized}");

let value = serde_json::to_value(&openapi)?;
let credential = get_json_path(&value, "components.schemas.Credential.properties");
Expand Down Expand Up @@ -1359,8 +1359,7 @@ mod tests {
let value_string = serde_json::to_string(&json_value).unwrap();
assert_eq!(
value_string, expected,
"value string != expected string, {} != {}",
value_string, expected
"value string != expected string, {value_string} != {expected}"
);
}

Expand Down

0 comments on commit 937db4c

Please sign in to comment.