diff --git a/dprint_plugin/src/config.rs b/dprint_plugin/src/config.rs index 6c6c7df..cd24846 100644 --- a/dprint_plugin/src/config.rs +++ b/dprint_plugin/src/config.rs @@ -114,17 +114,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "always" => Some(Comma::Always), - "never" => Some(Comma::Never), - "noTrailing" => Some(Comma::NoTrailing), - "onlySingleLine" => Some(Comma::OnlySingleLine), + .map(|option_value| match option_value { + "always" => Comma::Always, + "never" => Comma::Never, + "noTrailing" => Comma::NoTrailing, + "onlySingleLine" => Comma::OnlySingleLine, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "directives.comma".into(), message: "invalid value for config `directives.comma`".into(), }); - Some(Comma::Never) + Comma::Never } }) .or(Some(Comma::Never)), @@ -134,17 +134,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "always" => Some(Comma::Always), - "never" => Some(Comma::Never), - "noTrailing" => Some(Comma::NoTrailing), - "onlySingleLine" => Some(Comma::OnlySingleLine), + .map(|option_value| match option_value { + "always" => Comma::Always, + "never" => Comma::Never, + "noTrailing" => Comma::NoTrailing, + "onlySingleLine" => Comma::OnlySingleLine, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "enumValuesDefinition.comma".into(), message: "invalid value for config `enumValuesDefinition.comma`".into(), }); - Some(Comma::Never) + Comma::Never } }) .or(Some(Comma::Never)), @@ -154,17 +154,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "always" => Some(Comma::Always), - "never" => Some(Comma::Never), - "noTrailing" => Some(Comma::NoTrailing), - "onlySingleLine" => Some(Comma::OnlySingleLine), + .map(|option_value| match option_value { + "always" => Comma::Always, + "never" => Comma::Never, + "noTrailing" => Comma::NoTrailing, + "onlySingleLine" => Comma::OnlySingleLine, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "fieldsDefinition.comma".into(), message: "invalid value for config `fieldsDefinition.comma`".into(), }); - Some(Comma::Never) + Comma::Never } }) .or(Some(Comma::Never)), @@ -174,17 +174,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "always" => Some(Comma::Always), - "never" => Some(Comma::Never), - "noTrailing" => Some(Comma::NoTrailing), - "onlySingleLine" => Some(Comma::OnlySingleLine), + .map(|option_value| match option_value { + "always" => Comma::Always, + "never" => Comma::Never, + "noTrailing" => Comma::NoTrailing, + "onlySingleLine" => Comma::OnlySingleLine, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "inputFieldsDefinition.comma".into(), message: "invalid value for config `inputFieldsDefinition.comma`".into(), }); - Some(Comma::Never) + Comma::Never } }) .or(Some(Comma::Never)), @@ -232,17 +232,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "always" => Some(Comma::Always), - "never" => Some(Comma::Never), - "noTrailing" => Some(Comma::NoTrailing), - "onlySingleLine" => Some(Comma::OnlySingleLine), + .map(|option_value| match option_value { + "always" => Comma::Always, + "never" => Comma::Never, + "noTrailing" => Comma::NoTrailing, + "onlySingleLine" => Comma::OnlySingleLine, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "schemaDefinition.comma".into(), message: "invalid value for config `schemaDefinition.comma`".into(), }); - Some(Comma::Never) + Comma::Never } }) .or(Some(Comma::Never)), @@ -252,17 +252,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "always" => Some(Comma::Always), - "never" => Some(Comma::Never), - "noTrailing" => Some(Comma::NoTrailing), - "onlySingleLine" => Some(Comma::OnlySingleLine), + .map(|option_value| match option_value { + "always" => Comma::Always, + "never" => Comma::Never, + "noTrailing" => Comma::NoTrailing, + "onlySingleLine" => Comma::OnlySingleLine, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "schemaExtension.comma".into(), message: "invalid value for config `schemaExtension.comma`".into(), }); - Some(Comma::Never) + Comma::Never } }) .or(Some(Comma::Never)), @@ -272,17 +272,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "always" => Some(Comma::Always), - "never" => Some(Comma::Never), - "noTrailing" => Some(Comma::NoTrailing), - "onlySingleLine" => Some(Comma::OnlySingleLine), + .map(|option_value| match option_value { + "always" => Comma::Always, + "never" => Comma::Never, + "noTrailing" => Comma::NoTrailing, + "onlySingleLine" => Comma::OnlySingleLine, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "selectionSet.comma".into(), message: "invalid value for config `selectionSet.comma`".into(), }); - Some(Comma::Never) + Comma::Never } }) .or(Some(Comma::Never)), @@ -400,17 +400,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "prefer" => Some(SingleLine::Prefer), - "smart" => Some(SingleLine::Smart), - "never" => Some(SingleLine::Never), + .map(|option_value| match option_value { + "prefer" => SingleLine::Prefer, + "smart" => SingleLine::Smart, + "never" => SingleLine::Never, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "enumValuesDefinition.singleLine".into(), message: "invalid value for config `enumValuesDefinition.singleLine`" .into(), }); - Some(SingleLine::Never) + SingleLine::Never } }) .or(Some(SingleLine::Never)), @@ -420,16 +420,16 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "prefer" => Some(SingleLine::Prefer), - "smart" => Some(SingleLine::Smart), - "never" => Some(SingleLine::Never), + .map(|option_value| match option_value { + "prefer" => SingleLine::Prefer, + "smart" => SingleLine::Smart, + "never" => SingleLine::Never, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "fieldsDefinition.singleLine".into(), message: "invalid value for config `fieldsDefinition.singleLine`".into(), }); - Some(SingleLine::Never) + SingleLine::Never } }) .or(Some(SingleLine::Never)), @@ -458,17 +458,17 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "prefer" => Some(SingleLine::Prefer), - "smart" => Some(SingleLine::Smart), - "never" => Some(SingleLine::Never), + .map(|option_value| match option_value { + "prefer" => SingleLine::Prefer, + "smart" => SingleLine::Smart, + "never" => SingleLine::Never, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "inputFieldsDefinition.singleLine".into(), message: "invalid value for config `inputFieldsDefinition.singleLine`" .into(), }); - Some(SingleLine::Never) + SingleLine::Never } }) .or(Some(SingleLine::Never)), @@ -514,16 +514,16 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "prefer" => Some(SingleLine::Prefer), - "smart" => Some(SingleLine::Smart), - "never" => Some(SingleLine::Never), + .map(|option_value| match option_value { + "prefer" => SingleLine::Prefer, + "smart" => SingleLine::Smart, + "never" => SingleLine::Never, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "schemaDefinition.singleLine".into(), message: "invalid value for config `schemaDefinition.singleLine`".into(), }); - Some(SingleLine::Never) + SingleLine::Never } }) .or(Some(SingleLine::Never)), @@ -533,16 +533,16 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "prefer" => Some(SingleLine::Prefer), - "smart" => Some(SingleLine::Smart), - "never" => Some(SingleLine::Never), + .map(|option_value| match option_value { + "prefer" => SingleLine::Prefer, + "smart" => SingleLine::Smart, + "never" => SingleLine::Never, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "schemaExtension.singleLine".into(), message: "invalid value for config `schemaExtension.singleLine`".into(), }); - Some(SingleLine::Never) + SingleLine::Never } }) .or(Some(SingleLine::Never)), @@ -552,16 +552,16 @@ pub(crate) fn resolve_config( &mut diagnostics, ) .as_deref() - .and_then(|option_value| match option_value { - "prefer" => Some(SingleLine::Prefer), - "smart" => Some(SingleLine::Smart), - "never" => Some(SingleLine::Never), + .map(|option_value| match option_value { + "prefer" => SingleLine::Prefer, + "smart" => SingleLine::Smart, + "never" => SingleLine::Never, _ => { diagnostics.push(ConfigurationDiagnostic { property_name: "selectionSet.singleLine".into(), message: "invalid value for config `selectionSet.singleLine`".into(), }); - Some(SingleLine::Never) + SingleLine::Never } }) .or(Some(SingleLine::Never)), diff --git a/pretty_graphql/tests/fmt.rs b/pretty_graphql/tests/fmt.rs index 47e92be..6a47822 100644 --- a/pretty_graphql/tests/fmt.rs +++ b/pretty_graphql/tests/fmt.rs @@ -43,7 +43,7 @@ fn fmt_snapshot() { } fn run_format_test(path: &Path, input: &str, options: &FormatOptions) -> String { - let output = format_text(&input, &options) + let output = format_text(input, options) .map_err(|err| format!("failed to format '{}': {:?}", path.display(), err)) .unwrap(); @@ -53,7 +53,7 @@ fn run_format_test(path: &Path, input: &str, options: &FormatOptions) -> String path.display() ); - let regression_format = format_text(&output, &options) + let regression_format = format_text(&output, options) .map_err(|err| { format!( "syntax error in stability test '{}': {:?}",