From 3645df27b6541064d48074bbd88ebce070a2a02a Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 17 Nov 2023 21:38:17 +0100 Subject: [PATCH] Stop Clippy from enforcing `# Errors` and `# Panics` sections in GraphQL descriptions --- Makefile | 1 + juniper_codegen/src/graphql_interface/attr.rs | 2 ++ juniper_codegen/src/graphql_object/attr.rs | 2 ++ .../integration/tests/codegen_interface_attr_trait.rs | 7 +++++++ tests/integration/tests/codegen_object_attr.rs | 4 ++++ tests/integration/tests/codegen_subscription_attr.rs | 4 ++++ tests/integration/tests/common/mod.rs | 11 +++++++++++ tests/integration/tests/issue_914.rs | 2 ++ 8 files changed, 33 insertions(+) diff --git a/Makefile b/Makefile index eab74dae..50fabaa5 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ cargo.fmt: cargo.lint: cargo clippy --workspace --all-features -- -D warnings + cargo clippy -p juniper_integration_tests --tests --all-features -- -D warnings # Release Rust crate. diff --git a/juniper_codegen/src/graphql_interface/attr.rs b/juniper_codegen/src/graphql_interface/attr.rs index cf8cef01..7f844ef8 100644 --- a/juniper_codegen/src/graphql_interface/attr.rs +++ b/juniper_codegen/src/graphql_interface/attr.rs @@ -136,6 +136,8 @@ fn expand_on_trait( }; Ok(quote! { + // Omit enforcing `# Errors` and `# Panics` sections in GraphQL descriptions. + #[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)] #ast #generated_code }) diff --git a/juniper_codegen/src/graphql_object/attr.rs b/juniper_codegen/src/graphql_object/attr.rs index 5b0f941a..9b919418 100644 --- a/juniper_codegen/src/graphql_object/attr.rs +++ b/juniper_codegen/src/graphql_object/attr.rs @@ -127,6 +127,8 @@ where }; Ok(quote! { + // Omit enforcing `# Errors` and `# Panics` sections in GraphQL descriptions. + #[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)] #ast #generated_code }) diff --git a/tests/integration/tests/codegen_interface_attr_trait.rs b/tests/integration/tests/codegen_interface_attr_trait.rs index fe57ff0d..c30dd2d5 100644 --- a/tests/integration/tests/codegen_interface_attr_trait.rs +++ b/tests/integration/tests/codegen_interface_attr_trait.rs @@ -1,5 +1,9 @@ //! Tests for `#[graphql_interface]` macro placed on a trait. +// Assert that `#[graphql_interface]` macro placed on a trait stops Clippy from enforcing `# Errors` +// and `# Panics` sections in GraphQL descriptions. +#![deny(clippy::missing_errors_doc, clippy::missing_panics_doc)] + pub mod common; use juniper::{ @@ -2370,6 +2374,7 @@ mod explicit_custom_context { #[graphql_object(impl = CharacterValue, context = CustomContext)] impl Droid { + #[allow(clippy::needless_lifetimes)] // intentionally async fn id<'a>(&'a self) -> &'a str { &self.id } @@ -2378,6 +2383,7 @@ mod explicit_custom_context { &self.primary_function } + #[allow(clippy::needless_lifetimes)] // intentionally async fn info<'b>(&'b self) -> &'b str { &self.primary_function } @@ -2678,6 +2684,7 @@ mod executor { &self.home_planet } + #[allow(clippy::needless_lifetimes)] // intentionally async fn info<'b>(&'b self, _arg: prelude::Option) -> &'b str { &self.home_planet } diff --git a/tests/integration/tests/codegen_object_attr.rs b/tests/integration/tests/codegen_object_attr.rs index 44cbc5d2..1c821040 100644 --- a/tests/integration/tests/codegen_object_attr.rs +++ b/tests/integration/tests/codegen_object_attr.rs @@ -1,5 +1,9 @@ //! Tests for `#[graphql_object]` macro. +// Assert that `#[graphql_object]` macro placed on a `impl` stops Clippy from enforcing `# Errors` +// and `# Panics` sections in GraphQL descriptions. +#![deny(clippy::missing_errors_doc, clippy::missing_panics_doc)] + pub mod common; use juniper::{ diff --git a/tests/integration/tests/codegen_subscription_attr.rs b/tests/integration/tests/codegen_subscription_attr.rs index e46f0725..6a564c22 100644 --- a/tests/integration/tests/codegen_subscription_attr.rs +++ b/tests/integration/tests/codegen_subscription_attr.rs @@ -1,5 +1,9 @@ //! Tests for `#[graphql_subscription]` macro. +// Assert that `#[graphql_subscription]` macro placed on a `impl` stops Clippy from enforcing +// `# Errors` and `# Panics` sections in GraphQL descriptions. +#![deny(clippy::missing_errors_doc, clippy::missing_panics_doc)] + pub mod common; use std::pin::Pin; diff --git a/tests/integration/tests/common/mod.rs b/tests/integration/tests/common/mod.rs index 6bc9e9d4..aae6a04c 100644 --- a/tests/integration/tests/common/mod.rs +++ b/tests/integration/tests/common/mod.rs @@ -41,6 +41,17 @@ pub mod util { /// Extracts a single next value from the result returned by /// [`juniper::resolve_into_stream()`] and transforms it into a regular /// [`Value`]. + /// + /// # Errors + /// + /// Propagates the `input` [`GraphQLError`], if any. + /// + /// # Panics + /// + /// If the `input` [`Value`] doesn't represent a [`Value::Object`] containing a [`Stream`]. + /// + /// [`Stream`]: futures::Stream + #[allow(clippy::type_complexity)] pub async fn extract_next( input: Result<(Value>, Vec>), GraphQLError>, ) -> Result<(Value, Vec>), GraphQLError> { diff --git a/tests/integration/tests/issue_914.rs b/tests/integration/tests/issue_914.rs index bebede51..4886f645 100644 --- a/tests/integration/tests/issue_914.rs +++ b/tests/integration/tests/issue_914.rs @@ -1,6 +1,8 @@ //! Checks that multiple fragments on sub types don't override each other. //! See [#914](https://github.com/graphql-rust/juniper/issues/914) for details. +#![allow(clippy::disallowed_names)] + use juniper::{graphql_object, graphql_vars, EmptyMutation, EmptySubscription, GraphQLObject}; struct Query;