Skip to content

Commit

Permalink
Stop Clippy from enforcing # Errors and # Panics sections in Grap…
Browse files Browse the repository at this point in the history
…hQL descriptions
  • Loading branch information
tyranron committed Nov 17, 2023
1 parent 813c0d1 commit 3645df2
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions juniper_codegen/src/graphql_interface/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
2 changes: 2 additions & 0 deletions juniper_codegen/src/graphql_object/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/tests/codegen_interface_attr_trait.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -2678,6 +2684,7 @@ mod executor {
&self.home_planet
}

#[allow(clippy::needless_lifetimes)] // intentionally
async fn info<'b>(&'b self, _arg: prelude::Option<i32>) -> &'b str {
&self.home_planet
}
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/tests/codegen_object_attr.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/tests/codegen_subscription_attr.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S: ScalarValue>(
input: Result<(Value<ValuesStream<'_, S>>, Vec<ExecutionError<S>>), GraphQLError>,
) -> Result<(Value<S>, Vec<ExecutionError<S>>), GraphQLError> {
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/tests/issue_914.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 3645df2

Please sign in to comment.